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AI,GAAa,IAAI,SAAS,CAAA;AAClC,OAAO,CAAC,GAAG,CAAC,UAAU,GAAI,IAAY,CAAC,iBAAiB,CAAC,CAAA;AACzD,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA,CAAC,cAAc;AAC3D,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA,CAAC,cAAc;AAC3D,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA,CAAE,eAAe;AAE7D,IAAI,KAAK,GAAa,IAAI,SAAS,CAAA;AACnC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA,CAAE,cAAc;AAC7D,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA,CAAE,cAAc;AAC7D,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA,CAAE,eAAe;AAE9D,cAAc;AACd,IAAI;IACF,WAAI,CAAC,OAAO,CAAY,WAAW,EAAE,aAAa,EAAE,YAAY,CAAC,CAAA;CAClE;AAAC,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;CACvB;AAED,sBAAsB;AACtB,OAAO,CAAC,GAAG,CAAC,WAAI,CAAC,YAAY,CAAW,UAAU,EAAE,KAAK,CAAC,CAAC,CAAA,CAAE,eAAe","file":"","sourceRoot":"/","sourcesContent":["\nimport {NominalTypeSupported, Type} from \"./Type\";\n\n//// test codes/////////\n\ninterface AbilityA extends NominalTypeSupported {\n  a: string\n}\nlet AbilityAType = Type.declare<AbilityA>(\"AbilityA\")\n\ninterface AbilityB extends NominalTypeSupported {\n  b: string\n}\nlet AbilityBType = Type.declare<AbilityB>(\"AbilityB\")\n\ninterface AbilityC extends AbilityA {\n}\nlet AbilityCType = Type.declare<AbilityC>(\"AbilityC\", AbilityAType)\n\n///////////////////////\nclass ListItem { }\n\nclass ListItemA extends ListItem implements AbilityA, AbilityB {\n  __assignableTypes: string = ListItemAType.assignableTypes\n\n  a: string = \"\";\n  b: string = \"\";\n}\n// 类型对象的规则: T=类型, self_id=T的id, superTypes: extends 或 implments的 (NominalTypeSupported) T\nlet ListItemAType = Type.declare<ListItemA>(\"ListItemA\", AbilityAType, AbilityBType)\n\n\nclass ListItemB extends ListItem implements AbilityC {\n  __assignableTypes: string = ListItemBType.assignableTypes;\n  a: string = \"\";\n}\nlet ListItemBType = Type.declare<ListItemB>(\"ListItemB\", AbilityCType)\n\nclass ListItemC extends ListItemA {\n  __assignableTypes: string = ListItemCType.assignableTypes\n}\nlet ListItemCType = Type.declare<ListItemC>(\"ListItemC\", ListItemAType)\n\nclass ListItemD extends ListItemC implements AbilityC {\n  __assignableTypes: string = ListItemDType.assignableTypes\n}\nlet ListItemDType = Type.declare<ListItemD>(\"ListItemD\", ListItemCType, AbilityCType)\n\n\nlet item: ListItem = new ListItemA\nconsole.log(\"typeId =\" + (item as any).__assignableTypes)\nconsole.log(AbilityAType.isInstanceOf(item)) // expect true\nconsole.log(AbilityBType.isInstanceOf(item)) // expect true\nconsole.log(AbilityCType.isInstanceOf(item))  // expect false\n\nlet item2: ListItem = new ListItemB\nconsole.log(AbilityCType.isInstanceOf(item2))  // expect true\nconsole.log(AbilityAType.isInstanceOf(item2))  // expect true\nconsole.log(AbilityBType.isInstanceOf(item2))  // expect false\n\n// throw Error\ntry {\n  Type.declare<ListItemD>(\"ListItemD\", ListItemCType, AbilityCType)\n} catch (e) {\n  console.log(e.message)\n}\n\n//another isInstanceOf\nconsole.log(Type.isInstanceOf<AbilityB>(\"AbilityB\", item2))  // expect false\n"]}