UNPKG

2.53 kBSource Map (JSON)View Raw
1{"version":3,"file":"type-operator.js","sourceRoot":"","sources":["../../../../src/lib/models/types/type-operator.ts"],"names":[],"mappings":";;AAAA,yCAAkC;AAUlC,MAAa,gBAAiB,SAAQ,eAAI;IAYtC,YAAY,MAAY;QACpB,KAAK,EAAE,CAAC;QATH,SAAI,GAAW,cAAc,CAAC;QAM9B,aAAQ,GAAG,OAAO,CAAC;QAIxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAOD,KAAK;QACD,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;IAQD,MAAM,CAAC,IAAsB;QACzB,IAAI,CAAC,CAAC,IAAI,YAAY,gBAAgB,CAAC,EAAE;YACrC,OAAO,KAAK,CAAC;SAChB;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAKD,QAAQ;QACJ,MAAM,MAAM,GAAQ,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAChC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACvC,OAAO,MAAM,CAAC;IAClB,CAAC;IAKD,QAAQ;QACJ,OAAO,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;IACxD,CAAC;CACJ;AAxDD,4CAwDC","sourcesContent":["import { Type } from './abstract';\n\n/**\n * Represents a type operator type.\n *\n * ~~~\n * class A {}\n * class B<T extends keyof A> {}\n * ~~~\n */\nexport class TypeOperatorType extends Type {\n /**\n * The type name identifier.\n */\n readonly type: string = 'typeOperator';\n\n target: Type;\n\n // currently, there is only one type operator, this is always \"keyof\"\n // but, if more types will be added in the future we are ready.\n readonly operator = 'keyof';\n\n constructor(target: Type) {\n super();\n this.target = target;\n }\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n clone(): Type {\n return new TypeOperatorType(this.target.clone());\n }\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: TypeOperatorType): boolean {\n if (!(type instanceof TypeOperatorType)) {\n return false;\n }\n\n return type.target.equals(this.target);\n }\n\n /**\n * Return a raw object representation of this type.\n */\n toObject(): any {\n const result: any = super.toObject();\n result.operator = this.operator;\n result.target = this.target.toObject();\n return result;\n }\n\n /**\n * Return a string representation of this type.\n */\n toString() {\n return `${this.operator} ${this.target.toString()}`;\n }\n}\n"]}
\No newline at end of file