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AACrC,4DAA4D;AAC5D,8DAA8D;AAC9D,8DAA8D;AAC9D,gEAAgE;AAEhE,sCAAsC;AACtC,gEAAgE;AAChE,gEAAgE;AAChE,iEAAiE;AAEjE,iBAAiB;AACjB,QAAQ;AACR,sEAAsE;AACtE,gBAAgB;AAChB,8BAA8B;AAC9B,IAAI;AAEJ,yBAAyB;AACzB,+EAA+E","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\n// let item: ListItem = new ListItemA\n// console.log(\"typeId =\" + (item as any).__assignableTypes)\n// console.log(AbilityAType.isInstanceOf(item)) // expect true\n// console.log(AbilityBType.isInstanceOf(item)) // expect true\n// console.log(AbilityCType.isInstanceOf(item))  // expect false\n\n// let item2: ListItem = new ListItemB\n// console.log(AbilityCType.isInstanceOf(item2))  // expect true\n// console.log(AbilityAType.isInstanceOf(item2))  // expect true\n// console.log(AbilityBType.isInstanceOf(item2))  // expect false\n\n// // throw Error\n// try {\n//   Type.declare<ListItemD>(\"ListItemD\", ListItemCType, AbilityCType)\n// } catch (e) {\n//   // console.log(e.message)\n// }\n\n// //another isInstanceOf\n// console.log(Type.isInstanceOf<AbilityB>(\"AbilityB\", item2))  // expect false\n"]}