Skip to content
On this page

Type definitions ​

Introduction ​

This page describes the types in iztro. Internationalized types are defined in i18n, while the other types are defined in types.

Import internationalized types with the following code:

ts
import { HeavenlyStemName } from "iztro/lib/i18n";

To import other types, use:

ts
import { Palace } from "iztro/lib/data/types";

Tips

If you find an error or an unsuitable choice in the translations or type definitions, please open an issue. Thank you!

Internationalized types ​

To support internationalized input and output, iztro defines localized values for its parameters and results. You can pass a value in any supported language: for example, a HeavenlyStemName can be 甲, 갑 or jia.

For example, when calling getHoroscopeStar(), you can pass the Chinese names of the Heavenly Stems(天干) and Earthly Branches(地支) as arguments:

ts
import { getHoroscopeStar } from "iztro/lib/star";

getHoroscopeStar("甲", "子", "decadal");

You can also pass names in other supported languages, or mix languages in the same call:

ts
import { getHoroscopeStar } from "iztro/lib/star";

getHoroscopeStar("갑", "zi", "decadal");

The output uses the language you select, regardless of the languages used in the input. Set the output language before calling the method:

ts
import { setLanguage } from "iztro/lib/i18n";

setLanguage("ko-KR");

const horoscopeStar = getHoroscopeStar("甲", "zi", "decadal");

The output of horoscopeStar will then be in Korean.

horoscopeStar output result
json
[
  [
    {
      "name": "록존(십년)",
      "type": "lucun",
      "scope": "decadal"
    },
    {
      "name": "천마(십년)",
      "type": "tianma",
      "scope": "decadal"
    }
  ],
  [
    {
      "name": "경양(십년)",
      "type": "tough",
      "scope": "decadal"
    },
    {
      "name": "홍란(십년)",
      "type": "flower",
      "scope": "decadal"
    }
  ],
  [],
  [
    {
      "name": "문창(십년)",
      "type": "soft",
      "scope": "decadal"
    }
  ],
  [],
  [
    {
      "name": "천월(십년)",
      "type": "soft",
      "scope": "decadal"
    }
  ],
  [],
  [
    {
      "name": "문곡(십년)",
      "type": "soft",
      "scope": "decadal"
    },
    {
      "name": "천희(십년)",
      "type": "flower",
      "scope": "decadal"
    }
  ],
  [],
  [],
  [],
  [
    {
      "name": "천괴(십년)",
      "type": "soft",
      "scope": "decadal"
    },
    {
      "name": "타라(십년)",
      "type": "tough",
      "scope": "decadal"
    }
  ]
]

HeavenlyStemName ​

Defines the names of the ten Heavenly Stems(十天干).

甲 | 乙 | 丙 | 丁 | 戊 | 己 | 庚 | 辛 | 壬 | 癸


EarthlyBranchName ​

Defines the twelve Earthly Branches(十二地支). The standard romanization of the Earthly Branch woo(午) and the Heavenly Stem wu(戊) is “wu” in both cases. To avoid a naming conflict in multilingual input, the library represents the branch woo(午) as woo.

子 | 丑 | 寅 | 卯 | 辰 | 巳 | 午 | 未 | 申 | 酉 | 戌 | 亥


PalaceName ​

Defines the Name of Zi Wei Dou Shu(紫微斗數) palaces(宮位).

命宫 | 身宫 | 兄弟 | 夫妻 | 子女 | 财帛 | 疾厄 | 迁移 | 仆役 | 官禄 | 田宅 | 福德 | 父母 | 来因


Brightness ​

Defines star(星曜) brightness.

"" | 庙 | 旺 | 得 | 利 | 平 | 不 | 陷


Mutagen ​

Defines the name of four transformation stars(四化星) in Zi Wei Dou Shu(紫微斗數)

禄 | 权 | 科 | 忌


StarName ​

Defines the names of stars(星曜) in Zi Wei Dou Shu(紫微斗數), including transit stars(流曜).

^2.6.1 The English names for warrior(武曲) and breaker(歲破) are warrior and breaker, respectively.

紫微 | 天机 | 太阳 | 武曲 | 天同 | 廉贞 | 天府 | 太阴 | 贪狼 | 巨门 | 天相 | 天梁 | 七杀 | 破军 | 左辅 | 右弼 | 文昌 | 文曲 | 禄存 | 天马 | 擎羊 | 陀罗 | 火星 | 铃星 | 天魁 | 天钺 | 地空 | 地劫 | 劫杀 | 天空 | 天刑 | 天姚 | 解神 | 阴煞 | 天喜 | 天官 | 天福 | 天哭 | 天虚 | 龙池 | 凤阁 | 红鸾 | 孤辰 | 寡宿 | 蜚廉 | 破碎 | 台辅 | 封诰 | 天巫 | 天月 | 三台 | 八座 | 恩光 | 天贵 | 天才 | 天寿 | 截空 | 旬中 | 旬空 | 空亡 | 截路 | 月德 | 天伤 | 天使 | 天厨 | 长生 | 沐浴 | 冠带 | 临官 | 帝旺 | 衰 | 病 | 死 | 墓 | 绝 | 胎 | 养 | 博士 | 力士 | 青龙 | 小耗 | 将军 | 奏书 | 飞廉 | 喜神 | 病符 | 大耗 | 岁破 | 伏兵 | 官府 | 岁建 | 晦气 | 丧门 | 贯索 | 官符 | 龙德 | 白虎 | 天德 | 吊客 | 将星 | 攀鞍 | 岁驿 | 息神 | 华盖 | 劫煞 | 灾煞 | 天煞 | 指背 | 咸池 | 月煞 | 亡神 | 运魁 | 运钺 | 运昌 | 运曲 | 运鸾 | 运喜 | 运禄 | 运羊 | 运陀 | 运马 | 流魁 | 流钺 | 流昌 | 流曲 | 流鸾 | 流喜 | 流禄 | 流羊 | 流陀 | 流马 | 年解 | 月魁 | 月钺 | 月昌 | 月曲 | 月鸾 | 月喜 | 月禄 | 月羊 | 月陀 | 月马 | 日魁 | 日钺 | 日昌 | 日曲 | 日鸾 | 日喜 | 日禄 | 日羊 | 日陀 | 日马 | 时魁 | 时钺 | 时昌 | 时曲 | 时鸾 | 时喜 | 时禄 | 时羊 | 时陀 | 时马

Alias of the same name stars ^2.6.1

When two stars(星曜) share the same Korean or Vietnamese name, use an alias qualified with Chinese characters to identify the intended star precisely. These aliases are accepted only as input; translated output still uses the original names.

  • Korean: 천상(天相), 천상(天傷), 천월(天鉞), 천월(天月), 겁살(劫殺), 겁살(劫煞), 비렴(蜚廉), 비렴(飛廉), 관부(官府), 관부(官符)
  • Vietnamese: Kiếp Sát(劫殺), Kiếp Sát(劫煞), Phi Liêm(蜚廉), Phi Liêm(飛廉)

FiveElementsClassName ​

Defines the name of Five Elements Class(五行局) in Zi Wei Dou Shu(紫微斗數)

水二局 | 木三局 | 金四局 | 土五局 | 火六局


GenderName ​

Defines the names used for gender.

男 | 女

Common types ​

Language ​

ts
export type Language = `zh-CN` | `zh-TW` | `en-US` | `ko-KR` | `ja-JP` | `vi-VN`;

Defines the supported language values:

  • zh-CN: Simplified Chinese
  • zh-TW: Traditional Chinese
  • en-US:English
  • ko-KR:한국어
  • ja-JP: Japanese
  • vi-VN: Vietnamese

Scope ​

ts
export type Scope = "origin" | "decadal" | "yearly";

Defines the scope of stars(星曜), distinguishing natal stars(本命星曜) from transit stars(流曜):

  • origin: natal stars(本命星曜)
  • decadal: decadal-cycle stars(大限星曜)
  • yearly: yearly transit stars(流年星曜)

StarType ​

ts
export type StarType =
  | "major"
  | "soft"
  | "tough"
  | "adjective"
  | "flower"
  | "helper"
  | "lucun"
  | "tianma";

Defines star(星曜) Type. Although romance stars(桃花星) and considery(解神) (including considery(Y)(年解)) are miscellaneous stars(雜曜), they have special significance in chart interpretation and are therefore classified separately. The two auxiliary stars money(祿存) and horse(天馬) also have distinct roles, so each has its own category:

  • major: major stars(主星)
  • soft: auspicious stars(吉星)
  • tough: malefic stars(煞星)
  • adjective: miscellaneous stars(雜曜)
  • flower: romance stars(桃花)
  • helper:considery(解神)
  • lucun:money(祿存)
  • tianma:horse(天馬)

Stars(星曜) ​

Star ​

ts
export type Star = {
  name: StarName;
  type: StarType;
  scope: Scope;
  brightness?: Brightness;
  mutagen?: Mutagen;
};

Defines the data structure for stars(星曜).

PropertiesMeaningType
nameStar name(星曜名稱)StarName
typeStar type(星曜類型)StarType
scopeScopeScope
brightnessStar brightnessBrightness
mutagenfour transformations(四化)Mutagen

Palaces(宮位) ​

SoulAndBody ​

ts
export type SoulAndBody = {
  soulIndex: number;
  bodyIndex: number;
  heavenlyStemOfSoul: HeavenlyStemName;
  earthlyBranchOfSoul: EarthlyBranchName;
};

Defines the positions of the soul(命宮) and body(身宮) palaces.

PropertiesMeaningType
soulIndexsoul(命宮) indexnumber
bodyIndexbody(身宮) indexnumber
heavenlyStemOfSoulHeavenly Stem of the soul palace(命宮天干)HeavenlyStemName
earthlyBranchOfSoulEarthly Branch of the soul palace(命宮地支)EarthlyBranchName

Palace ​

ts
export type Palace = {
  name: PalaceName;
  isBodyPalace: boolean;
  isOriginalPalace: boolean;
  heavenlyStem: HeavenlyStemName;
  earthlyBranch: EarthlyBranchName;
  majorStars: Star[];
  minorStars: Star[];
  adjectiveStars: Star[];
  changsheng12: StarName;
  boshi12: StarName;
  jiangqian12: StarName;
  suiqian12: StarName;
  decadal: Decadal;
  ages: number[];
};

Defines the data structure for palaces(宮位).

PropertiesMeaningType
namePalace name(宮位名稱)PalaceName
isBodyPalaceWhether this is the body palace(身宮)boolean
isOriginalPalaceWhether this is the origin palace(來因宮)boolean
heavenlyStemPalace Heavenly Stem(宮位天干)HeavenlyStemName
earthlyBranchPalace Earthly Branch(宮位地支)EarthlyBranchName
majorStarsmajor stars(主星)Star[]
minorStarsauxiliary stars(輔星)Star[]
adjectiveStarsmiscellaneous stars(雜曜)Star[]
changsheng12Twelve growth-stage starsStarName
boshi12Twelve Doctor-cycle stars(博士十二神)StarName
jiangqian12Twelve yearly General-front starsStarName
suiqian12Twelve yearly Year-front starsStarName
decadaldecadal(大限)Decadal
agesage(小限)number[]

SurroundedPalaces ​

ts
export type SurroundedPalaces = {
  target: IFunctionalPalace;
  opposite: IFunctionalPalace;
  wealth: IFunctionalPalace;
  career: IFunctionalPalace;
};

Defines an object containing the trine and opposite palaces(三方四正).

PropertiesMeaningType
targettarget palaceIFunctionalPalace
oppositeopposite palaceIFunctionalPalace
wealthWealth position(財帛位)IFunctionalPalace
careerCareer position(官祿位)IFunctionalPalace

Horoscope periods(運限) ​

HoroscopeItem ​

ts
export type HoroscopeItem = {
  index: number;
  name: string;
  heavenlyStem: HeavenlyStemName;
  earthlyBranch: EarthlyBranchName;
  palaceNames: PalaceName[];
  mutagen: StarName[];
  stars?: Star[][];
};

Defines the data structure used for individual horoscope periods(運限).

PropertiesMeaningType
indexIndex of the corresponding palacenumber
name ^1.2.3Horoscope-period name(運限名稱)string
heavenlyStemHoroscope-period Heavenly Stem(運限天干)HeavenlyStemName
earthlyBranchHoroscope-period Earthly Branch(運限地支)EarthlyBranchName
palaceNamesTwelve palaces of the horoscope period(運限十二宮)PalaceName[]
mutagenfour transformation stars(四化星)StarName[]
starstransit stars(流曜)Star[][]

Decadal ​

ts
export type Decadal = {
  range: [number, number];
  heavenlyStem: HeavenlyStemName;
  earthlyBranch: EarthlyBranchName;
};

Defines the chart’s decadal(大限) data. This type is mainly used in Palace.

PropertiesMeaningType
rangeDecadal-period starting and ending ages [starting age, ending age][number, number]
heavenlyStemDecadal-period Heavenly Stem(大限天干)HeavenlyStemName
earthlyBranchDecadal-period Earthly Branch(大限地支)EarthlyBranchName

DecadalHoroscope ​

ts
export type DecadalHoroscope = HoroscopeItem & {
  palaceName: PalaceName;
  ageRange: [number, number];
  yearRange: [number, number];
};

Defines a decadal-cycle(大限) list item returned by decadalList().

PropertiesMeaningType
palaceNameNatal palace occupied by the decadal period(大限所在本命宮位)PalaceName
ageRangeDecadal-period starting and ending nominal ages(虛歲)[number, number]
yearRangeDecadal-period starting and ending years[number, number]

This type also contains all attributes of HoroscopeItem.


YearlyHoroscope ​

ts
export type YearlyHoroscope = HoroscopeItem & {
  age: number;
  year: number;
};

Defines a yearly-cycle(流年) list item returned by yearlyList().

PropertiesMeaningType
ageNominal age corresponding to the annual period(流年虛歲)number
yearYear of the annual period(流年年份)number

This type also contains all attributes of HoroscopeItem.


MonthlyHoroscope ​

ts
export type MonthlyHoroscope = YearlyHoroscope & {
  month: number;
  isLeapMonth: boolean;
  part: 'normal' | 'first' | 'second';
  dayRange: [number, number];
};

Defines a monthly-cycle(流月) list item returned by monthlyList().

PropertiesMeaningType
monthLunar month, the first month is 1number
isLeapMonthIs it a leap month?boolean
partOrdinary month, first half of leap month or second half of leap month'normal' | 'first' | 'second'
dayRangeThe corresponding lunar date range for this item[number, number]

This type contains all properties of both YearlyHoroscope and HoroscopeItem.


Horoscope ​

ts
export type Horoscope = {
  lunarDate: string;
  solarDate: string;
  decadal: HoroscopeItem;
  age: {
    index: number;
    nominalAge: number;
  };
  yearly: HoroscopeItem & {
    yearlyDecStar: {
      jiangqian12: StarName[];
      suiqian12: StarName[]
      }
    };
  monthly: HoroscopeItem;
  daily: HoroscopeItem;
  hourly: HoroscopeItem;
};

Defines a horoscope-period(運限) object containing decadal(大限), yearly(流年), monthly(流月), daily(流日), and hourly(流時) data.

PropertiesMeaningType
lunarDateLunar-calendar datestring
solarDateGregorian datestring
decadaldecadal(大限)HoroscopeItem
ageage(小限){ index: number, nominalAge: number }
yearlyyearly(流年)HoroscopeItem & { yearlyDecStar: { jiangqian12: StarName[]; suiqian12: StarName[] } }
monthlymonthly(流月)HoroscopeItem
dailydaily(流日)HoroscopeItem
hourlyhourly(流時)HoroscopeItem

Chart(星盤) ​

Astrolabe ​

ts
export type Astrolabe = {
  gender: GenderName;
  solarDate: string;
  lunarDate: string;
  chineseDate: string;
  rawDates: {
    lunarDate: LunarDate;
    chineseDate: HeavenlyStemAndEarthlyBranchDate;
  };
  time: string;
  timeRange: string;
  sign: string;
  zodiac: string;
  earthlyBranchOfSoulPalace: EarthlyBranchName;
  earthlyBranchOfBodyPalace: EarthlyBranchName;
  soul: StarName;
  body: StarName;
  fiveElementsClass: FiveElementsClassName;
  palaces: IFunctionalPalace[];
};

Defines a chart(星盤) object.

PropertiesMeaningType
gendergender ^2.0.3GenderName
solarDateGregorian datestring
lunarDateLunar-calendar datestring
chineseDateDate expressed using Heavenly Stems and Earthly Branches(干支)string
rawDatesRaw date data for future use by internal methods{ lunarDate: LunarDate, chineseDate: HeavenlyStemAndEarthlyBranchDate }
timeTraditional double-hour(時辰)string
timeRangeClock-time range corresponding to the traditional double-hourstring
signWestern zodiac sign(星座)string
zodiacChinese zodiac animal(生肖)string
earthlyBranchOfSoulPalaceEarthly Branch of the soul palace(命宮地支)EarthlyBranchName
earthlyBranchOfBodyPalaceEarthly Branch of the body palace(身宮地支)EarthlyBranchName
soulSoul ruler star(命主)StarName
bodyBody ruler star(身主)StarName
fiveElementsClassFive Elements Class(五行局)FiveElementsClassName
palacesData for the twelve palaces(十二宮)IFunctionalPalace[]

Configuration and plugins ^2.3.0 ​

ConfigMutagens ​

Defines the four transformations(四化) parameter in the global configuration.

ts
type ConfigMutagens = Partial<Record<HeavenlyStemName, StarName[]>>;

ConfigBrightness ​

Defines the brightness parameter in the global configuration.

ts
type ConfigBrightness = Partial<Record<StarName, Brightness[]>>;

Config ​

Defines chart-calculation settings. Use astro.config() to set defaults for subsequently generated charts, or withOptions({ config }) to override the settings for just the chart being generated. Existing charts retain the settings used at their creation (^2.6.2).

ts
type Config = {
  // 星曜四化配置
  mutagens?: ConfigMutagens;
  // 星曜亮度配置
  brightness?: ConfigBrightness;
  // 年分割点配置
  yearDivide?: 'normal' | 'exact';
  // 运限分割点配置(^v2.4.3)
  horoscopeDivide?: 'normal' | 'exact';
  // 小限分割点配置,normal为以自然年分界,birthday为生日分界(^v2.4.5)
  // 默认为 normal
  ageDivide?: 'normal' | 'birthday';
  // 晚子时配置,current 时晚子时算当日,forward 时晚子时算次日(^v2.5.2)
  // 默认为 forward
  dayDivide?: 'current' | 'forward';
  // 安星方法,default 为通行版本,zhongzhou 为中州派版本(^v2.5.0)
  // 默认为 default
  algorithm?: 'default' | 'zhongzhou';
};

For yearDivide and horoscopeDivide, normal uses the first day of the first Chinese lunar month as the year boundary, while exact uses the solar term Start of Spring(立春).

dayDivide only controls which calendar day the late Zi hour(晚子時) belongs to (timeIndex is 12): forward assigns it to the following day, and current assigns it to the current day.

AstroType ^2.5.0 ​

Defines the chart type used by the Zhongzhou school(中州派).

ts
type AstroType = 'heaven' | 'earth' | 'human';
valueDescription
heavenNatal chart(天盤), the default
earthEarth chart(地盤): derive the Five Elements Class from the body palace's stem and branch, and use that palace as the soul palace.
humanHuman chart(人盤): derive the Five Elements Class from the spirit palace's stem and branch, and use that palace as the soul palace.

Plugin ​

Defines the plugin type. A plugin is simply a function.

ts
type Plugin = () => void;

Tips

A plugin function implicitly receives a this parameter of type T extends FunctionalAstrolabe. See Plugins for details on creating one.

© 2025 iztro.com All rights reserved.
Related site: 紫微派