@typespec/compiler 0.44.0-dev.9 → 0.45.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/checker.d.ts +7 -9
- package/dist/core/checker.d.ts.map +1 -1
- package/dist/core/checker.js +43 -25
- package/dist/core/checker.js.map +1 -1
- package/dist/core/cli/args.d.ts.map +1 -1
- package/dist/core/cli/args.js +3 -2
- package/dist/core/cli/args.js.map +1 -1
- package/dist/core/decorator-utils.d.ts +1 -0
- package/dist/core/decorator-utils.d.ts.map +1 -1
- package/dist/core/decorator-utils.js +5 -1
- package/dist/core/decorator-utils.js.map +1 -1
- package/dist/core/helpers/type-name-utils.d.ts.map +1 -1
- package/dist/core/helpers/type-name-utils.js +9 -6
- package/dist/core/helpers/type-name-utils.js.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +5 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/messages.d.ts +30 -2
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +8 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/path-utils.d.ts +10 -0
- package/dist/core/path-utils.d.ts.map +1 -1
- package/dist/core/path-utils.js +116 -1
- package/dist/core/path-utils.js.map +1 -1
- package/dist/core/program.d.ts +4 -0
- package/dist/core/program.d.ts.map +1 -1
- package/dist/core/program.js +13 -7
- package/dist/core/program.js.map +1 -1
- package/dist/core/projector.d.ts.map +1 -1
- package/dist/core/projector.js +18 -7
- package/dist/core/projector.js.map +1 -1
- package/dist/core/semantic-walker.d.ts.map +1 -1
- package/dist/core/semantic-walker.js +15 -4
- package/dist/core/semantic-walker.js.map +1 -1
- package/dist/core/type-utils.d.ts +9 -2
- package/dist/core/type-utils.d.ts.map +1 -1
- package/dist/core/type-utils.js +19 -3
- package/dist/core/type-utils.js.map +1 -1
- package/dist/core/types.d.ts +23 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/emitter-framework/builders/object-builder.d.ts +1 -1
- package/dist/emitter-framework/builders/object-builder.d.ts.map +1 -1
- package/dist/emitter-framework/builders/object-builder.js +11 -2
- package/dist/emitter-framework/builders/object-builder.js.map +1 -1
- package/dist/emitter-framework/type-emitter.d.ts.map +1 -1
- package/dist/emitter-framework/type-emitter.js +0 -1
- package/dist/emitter-framework/type-emitter.js.map +1 -1
- package/dist/formatter/print/printer.js +1 -1
- package/dist/formatter/print/printer.js.map +1 -1
- package/dist/lib/decorators.d.ts +10 -10
- package/dist/lib/decorators.d.ts.map +1 -1
- package/dist/lib/decorators.js +83 -19
- package/dist/lib/decorators.js.map +1 -1
- package/dist/manifest.js +2 -2
- package/dist/server/serverlib.d.ts.map +1 -1
- package/dist/server/serverlib.js +9 -6
- package/dist/server/serverlib.js.map +1 -1
- package/dist/testing/test-server-host.d.ts +3 -1
- package/dist/testing/test-server-host.d.ts.map +1 -1
- package/dist/testing/test-server-host.js +3 -1
- package/dist/testing/test-server-host.js.map +1 -1
- package/lib/decorators.tsp +112 -4
- package/lib/lib.tsp +24 -1
- package/package.json +4 -4
package/dist/core/checker.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TypeNameOptions } from "./helpers/index.js";
|
|
2
2
|
import { Program, ProjectedProgram } from "./program.js";
|
|
3
|
-
import { BooleanLiteral, BooleanLiteralNode, Diagnostic, DiagnosticTarget, ErrorType, FunctionType, IdentifierNode, IntrinsicScalarName, JsSourceFileNode, LiteralNode, LiteralType, Model, ModelProperty, Namespace, NamespaceStatementNode, NeverType, Node, NumericLiteral, NumericLiteralNode, ProjectionNode, ProjectionStatementNode, Scalar, StringLiteral, StringLiteralNode, Sym, Type,
|
|
3
|
+
import { BooleanLiteral, BooleanLiteralNode, Diagnostic, DiagnosticTarget, ErrorType, FunctionType, IdentifierNode, IntrinsicScalarName, JsSourceFileNode, LiteralNode, LiteralType, Model, ModelProperty, Namespace, NamespaceStatementNode, NeverType, Node, NumericLiteral, NumericLiteralNode, ProjectionNode, ProjectionStatementNode, Scalar, StdTypeName, StdTypes, StringLiteral, StringLiteralNode, Sym, Type, TypeReferenceNode, TypeSpecScriptNode, UnknownType, VoidType } from "./types.js";
|
|
4
|
+
export type CreateTypeProps = Omit<Type, "isFinished" | keyof TypePrototype>;
|
|
4
5
|
export interface Checker {
|
|
5
6
|
typePrototype: TypePrototype;
|
|
6
7
|
getTypeForNode(node: Node): Type;
|
|
@@ -30,8 +31,10 @@ export interface Checker {
|
|
|
30
31
|
project(target: Type, projection: ProjectionNode, args?: (Type | string | number | boolean)[]): Type;
|
|
31
32
|
resolveIdentifier(node: IdentifierNode): Sym | undefined;
|
|
32
33
|
resolveCompletions(node: IdentifierNode): Map<string, TypeSpecCompletionItem>;
|
|
33
|
-
createType<T>(typeDef: T): T & TypePrototype
|
|
34
|
-
|
|
34
|
+
createType<T extends Type extends any ? CreateTypeProps : never>(typeDef: T): T & TypePrototype & {
|
|
35
|
+
isFinished: boolean;
|
|
36
|
+
};
|
|
37
|
+
createAndFinishType<T extends Type extends any ? CreateTypeProps : never>(typeDef: T): T & TypePrototype;
|
|
35
38
|
finishType<T extends Type>(typeDef: T): T;
|
|
36
39
|
createFunctionType(fn: (...args: Type[]) => Type): FunctionType;
|
|
37
40
|
createLiteralType(value: string, node?: StringLiteralNode): StringLiteral;
|
|
@@ -87,11 +90,6 @@ export interface TypeSpecCompletionItem {
|
|
|
87
90
|
*/
|
|
88
91
|
label?: string;
|
|
89
92
|
}
|
|
90
|
-
type StdTypeName = IntrinsicScalarName | "Array" | "Record" | "object";
|
|
91
|
-
type StdTypes = {
|
|
92
|
-
Array: Model;
|
|
93
|
-
Record: Model;
|
|
94
|
-
} & Record<IntrinsicScalarName, Scalar>;
|
|
95
93
|
export declare function createChecker(program: Program): Checker;
|
|
96
94
|
/**
|
|
97
95
|
* If the input is anonymous (or the provided filter removes properties)
|
|
@@ -133,6 +131,6 @@ export declare function getOverriddenProperty(property: ModelProperty): ModelPro
|
|
|
133
131
|
* Properties that are overridden are not enumerated.
|
|
134
132
|
*/
|
|
135
133
|
export declare function walkPropertiesInherited(model: Model): Generator<ModelProperty, void, unknown>;
|
|
136
|
-
export declare function finishTypeForProgram<T extends Type>(program: Program, typeDef: T
|
|
134
|
+
export declare function finishTypeForProgram<T extends Type>(program: Program, typeDef: T): T;
|
|
137
135
|
export {};
|
|
138
136
|
//# sourceMappingURL=checker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../../core/checker.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAqC,MAAM,oBAAoB,CAAC;AAGxF,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AASzD,OAAO,EAIL,cAAc,EACd,kBAAkB,EAQlB,UAAU,EACV,gBAAgB,EAKhB,SAAS,EAKT,YAAY,EAEZ,cAAc,EAId,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,WAAW,EAOX,KAAK,EAGL,aAAa,EAKb,SAAS,EACT,sBAAsB,EACtB,SAAS,EACT,IAAI,EAEJ,cAAc,EACd,kBAAkB,EAiBlB,cAAc,EAGd,uBAAuB,EAIvB,MAAM,EAEN,aAAa,EACb,iBAAiB,EACjB,GAAG,EAYH,IAAI,
|
|
1
|
+
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../../core/checker.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAqC,MAAM,oBAAoB,CAAC;AAGxF,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AASzD,OAAO,EAIL,cAAc,EACd,kBAAkB,EAQlB,UAAU,EACV,gBAAgB,EAKhB,SAAS,EAKT,YAAY,EAEZ,cAAc,EAId,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,WAAW,EAOX,KAAK,EAGL,aAAa,EAKb,SAAS,EACT,sBAAsB,EACtB,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,SAAS,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,UAAU,aAAa;IACrB,WAAW,EAAE,uBAAuB,EAAE,CAAC;IACvC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAAC;CAC5D;AAED,6CAA6C;AAC7C,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,GAAG,CAAC;IAET;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAaD,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAgnJvD;AAqFD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,OAAO,GAC5C,KAAK,CAyEP;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,GAAG,gBAAgB,EACnC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,OAAO,GAC3C,KAAK,CAmCP;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS,CAcxF;AAED;;;;;;;GAOG;AACH,wBAAiB,uBAAuB,CAAC,KAAK,EAAE,KAAK,2CAapD;AAYD,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAEpF"}
|
package/dist/core/checker.js
CHANGED
|
@@ -733,12 +733,13 @@ export function createChecker(program) {
|
|
|
733
733
|
compilerAssert(false, `Unexpected checker error. symbolLinks.instantiations was not defined for ${SyntaxKind[templateNode.kind]}`);
|
|
734
734
|
}
|
|
735
735
|
}
|
|
736
|
-
const
|
|
736
|
+
const mapper = createTypeMapper(params, args, parentMapper);
|
|
737
|
+
const cached = (_a = symbolLinks.instantiations) === null || _a === void 0 ? void 0 : _a.get(mapper.args);
|
|
737
738
|
if (cached) {
|
|
738
739
|
return cached;
|
|
739
740
|
}
|
|
740
741
|
if (instantiateTempalates) {
|
|
741
|
-
return instantiateTemplate(symbolLinks.instantiations, templateNode, params,
|
|
742
|
+
return instantiateTemplate(symbolLinks.instantiations, templateNode, params, mapper);
|
|
742
743
|
}
|
|
743
744
|
else {
|
|
744
745
|
return errorType;
|
|
@@ -753,11 +754,10 @@ export function createChecker(program) {
|
|
|
753
754
|
* twice at the same time, or if template parameters from more than one template
|
|
754
755
|
* are ever in scope at once.
|
|
755
756
|
*/
|
|
756
|
-
function instantiateTemplate(instantiations, templateNode, params,
|
|
757
|
-
const mapper = createTypeMapper(params, args, parentMapper);
|
|
757
|
+
function instantiateTemplate(instantiations, templateNode, params, mapper) {
|
|
758
758
|
const type = getTypeForNode(templateNode, mapper);
|
|
759
|
-
if (!instantiations.get(args)) {
|
|
760
|
-
instantiations.set(args, type);
|
|
759
|
+
if (!instantiations.get(mapper.args)) {
|
|
760
|
+
instantiations.set(mapper.args, type);
|
|
761
761
|
}
|
|
762
762
|
if (type.kind === "Model") {
|
|
763
763
|
type.templateNode = templateNode;
|
|
@@ -948,7 +948,8 @@ export function createChecker(program) {
|
|
|
948
948
|
properties.set(prop.name, newPropType);
|
|
949
949
|
}
|
|
950
950
|
}
|
|
951
|
-
|
|
951
|
+
linkMapper(intersection, mapper);
|
|
952
|
+
return finishType(intersection);
|
|
952
953
|
}
|
|
953
954
|
function checkArrayExpression(node, mapper) {
|
|
954
955
|
const elementType = getTypeForNode(node.elementType, mapper);
|
|
@@ -1077,13 +1078,14 @@ export function createChecker(program) {
|
|
|
1077
1078
|
const name = node.id.sv;
|
|
1078
1079
|
let decorators = [];
|
|
1079
1080
|
// Is this a definition or reference?
|
|
1080
|
-
let parameters, returnType;
|
|
1081
|
+
let parameters, returnType, sourceOperation;
|
|
1081
1082
|
if (node.signature.kind === SyntaxKind.OperationSignatureReference) {
|
|
1082
1083
|
// Attempt to resolve the operation
|
|
1083
1084
|
const baseOperation = checkOperationIs(node, node.signature.baseOperation, mapper);
|
|
1084
1085
|
if (!baseOperation) {
|
|
1085
1086
|
return errorType;
|
|
1086
1087
|
}
|
|
1088
|
+
sourceOperation = baseOperation;
|
|
1087
1089
|
// Reference the same return type and create the parameters type
|
|
1088
1090
|
parameters = cloneType(baseOperation.parameters);
|
|
1089
1091
|
returnType = baseOperation.returnType;
|
|
@@ -1102,22 +1104,26 @@ export function createChecker(program) {
|
|
|
1102
1104
|
parameters,
|
|
1103
1105
|
returnType,
|
|
1104
1106
|
decorators,
|
|
1107
|
+
sourceOperation,
|
|
1105
1108
|
interface: parentInterface,
|
|
1106
1109
|
});
|
|
1107
1110
|
decorators.push(...checkDecorators(operationType, node, mapper));
|
|
1108
1111
|
operationType.parameters.namespace = namespace;
|
|
1109
1112
|
const parent = node.parent;
|
|
1113
|
+
linkMapper(operationType, mapper);
|
|
1110
1114
|
if (parent.kind === SyntaxKind.InterfaceStatement) {
|
|
1111
1115
|
if (shouldCreateTypeForTemplate(parent, mapper) &&
|
|
1112
1116
|
shouldCreateTypeForTemplate(node, mapper)) {
|
|
1113
|
-
finishType(operationType
|
|
1117
|
+
finishType(operationType);
|
|
1114
1118
|
}
|
|
1115
1119
|
}
|
|
1116
1120
|
else {
|
|
1117
1121
|
if (shouldCreateTypeForTemplate(node, mapper)) {
|
|
1118
|
-
finishType(operationType
|
|
1122
|
+
finishType(operationType);
|
|
1123
|
+
}
|
|
1124
|
+
if (mapper === undefined) {
|
|
1125
|
+
namespace === null || namespace === void 0 ? void 0 : namespace.operations.set(name, operationType);
|
|
1119
1126
|
}
|
|
1120
|
-
namespace === null || namespace === void 0 ? void 0 : namespace.operations.set(name, operationType);
|
|
1121
1127
|
}
|
|
1122
1128
|
if (links) {
|
|
1123
1129
|
linkType(links, operationType, mapper);
|
|
@@ -1684,6 +1690,7 @@ export function createChecker(program) {
|
|
|
1684
1690
|
linkType(links, type, mapper);
|
|
1685
1691
|
const isBase = checkModelIs(node, node.is, mapper);
|
|
1686
1692
|
if (isBase) {
|
|
1693
|
+
type.sourceModel = isBase;
|
|
1687
1694
|
checkDeprecated(isBase, node.is);
|
|
1688
1695
|
// copy decorators
|
|
1689
1696
|
decorators.push(...isBase.decorators);
|
|
@@ -1728,8 +1735,9 @@ export function createChecker(program) {
|
|
|
1728
1735
|
mutate(sym).type = prop;
|
|
1729
1736
|
}
|
|
1730
1737
|
}
|
|
1738
|
+
linkMapper(type, mapper);
|
|
1731
1739
|
if (shouldCreateTypeForTemplate(node, mapper)) {
|
|
1732
|
-
finishType(type
|
|
1740
|
+
finishType(type);
|
|
1733
1741
|
}
|
|
1734
1742
|
const indexer = getIndexer(program, type);
|
|
1735
1743
|
if (type.name === "Array" && isInTypeSpecNamespace(type)) {
|
|
@@ -2192,8 +2200,9 @@ export function createChecker(program) {
|
|
|
2192
2200
|
}
|
|
2193
2201
|
type.decorators = checkDecorators(type, prop, mapper);
|
|
2194
2202
|
const parentTemplate = getParentTemplateNode(prop);
|
|
2203
|
+
linkMapper(type, mapper);
|
|
2195
2204
|
if (!parentTemplate || shouldCreateTypeForTemplate(parentTemplate, mapper)) {
|
|
2196
|
-
finishType(type
|
|
2205
|
+
finishType(type);
|
|
2197
2206
|
}
|
|
2198
2207
|
return type;
|
|
2199
2208
|
}
|
|
@@ -2395,8 +2404,9 @@ export function createChecker(program) {
|
|
|
2395
2404
|
if (mapper === undefined) {
|
|
2396
2405
|
(_a = type.namespace) === null || _a === void 0 ? void 0 : _a.scalars.set(type.name, type);
|
|
2397
2406
|
}
|
|
2407
|
+
linkMapper(type, mapper);
|
|
2398
2408
|
if (shouldCreateTypeForTemplate(node, mapper)) {
|
|
2399
|
-
finishType(type
|
|
2409
|
+
finishType(type);
|
|
2400
2410
|
}
|
|
2401
2411
|
if (isInTypeSpecNamespace(type)) {
|
|
2402
2412
|
stdTypes[type.name] = type;
|
|
@@ -2493,7 +2503,8 @@ export function createChecker(program) {
|
|
|
2493
2503
|
enumType.namespace = namespace;
|
|
2494
2504
|
(_a = enumType.namespace) === null || _a === void 0 ? void 0 : _a.enums.set(enumType.name, enumType);
|
|
2495
2505
|
enumType.decorators = checkDecorators(enumType, node, mapper);
|
|
2496
|
-
|
|
2506
|
+
linkMapper(enumType, mapper);
|
|
2507
|
+
finishType(enumType);
|
|
2497
2508
|
}
|
|
2498
2509
|
return links.type;
|
|
2499
2510
|
}
|
|
@@ -2542,8 +2553,9 @@ export function createChecker(program) {
|
|
|
2542
2553
|
for (const [key, value] of ownMembers) {
|
|
2543
2554
|
interfaceType.operations.set(key, value);
|
|
2544
2555
|
}
|
|
2556
|
+
linkMapper(interfaceType, mapper);
|
|
2545
2557
|
if (shouldCreateTypeForTemplate(node, mapper)) {
|
|
2546
|
-
finishType(interfaceType
|
|
2558
|
+
finishType(interfaceType);
|
|
2547
2559
|
}
|
|
2548
2560
|
if (mapper === undefined) {
|
|
2549
2561
|
(_a = interfaceType.namespace) === null || _a === void 0 ? void 0 : _a.interfaces.set(interfaceType.name, interfaceType);
|
|
@@ -2590,8 +2602,9 @@ export function createChecker(program) {
|
|
|
2590
2602
|
});
|
|
2591
2603
|
unionType.decorators = checkDecorators(unionType, node, mapper);
|
|
2592
2604
|
checkUnionVariants(unionType, node, variants, mapper);
|
|
2605
|
+
linkMapper(unionType, mapper);
|
|
2593
2606
|
if (shouldCreateTypeForTemplate(node, mapper)) {
|
|
2594
|
-
finishType(unionType
|
|
2607
|
+
finishType(unionType);
|
|
2595
2608
|
}
|
|
2596
2609
|
linkType(links, unionType, mapper);
|
|
2597
2610
|
if (mapper === undefined) {
|
|
@@ -2631,8 +2644,9 @@ export function createChecker(program) {
|
|
|
2631
2644
|
union: undefined,
|
|
2632
2645
|
});
|
|
2633
2646
|
variantType.decorators = checkDecorators(variantType, variantNode, mapper);
|
|
2647
|
+
linkMapper(variantType, mapper);
|
|
2634
2648
|
if (shouldCreateTypeForTemplate(variantNode.parent, mapper)) {
|
|
2635
|
-
finishType(variantType
|
|
2649
|
+
finishType(variantType);
|
|
2636
2650
|
}
|
|
2637
2651
|
if (links) {
|
|
2638
2652
|
linkType(links, variantType, mapper);
|
|
@@ -2719,10 +2733,11 @@ export function createChecker(program) {
|
|
|
2719
2733
|
*/
|
|
2720
2734
|
function createType(typeDef) {
|
|
2721
2735
|
Object.setPrototypeOf(typeDef, typePrototype);
|
|
2736
|
+
typeDef.isFinished = false;
|
|
2722
2737
|
return typeDef;
|
|
2723
2738
|
}
|
|
2724
|
-
function finishType(typeDef
|
|
2725
|
-
return finishTypeForProgramAndChecker(program, typePrototype, typeDef
|
|
2739
|
+
function finishType(typeDef) {
|
|
2740
|
+
return finishTypeForProgramAndChecker(program, typePrototype, typeDef);
|
|
2726
2741
|
}
|
|
2727
2742
|
function getLiteralType(node) {
|
|
2728
2743
|
return createLiteralType(node.value, node);
|
|
@@ -3889,14 +3904,14 @@ function addDerivedModels(models, possiblyDerivedModels) {
|
|
|
3889
3904
|
}
|
|
3890
3905
|
}
|
|
3891
3906
|
function createTypeMapper(parameters, args, parentMapper) {
|
|
3892
|
-
var _a;
|
|
3907
|
+
var _a, _b;
|
|
3893
3908
|
const map = new Map((_a = parentMapper === null || parentMapper === void 0 ? void 0 : parentMapper.map) !== null && _a !== void 0 ? _a : []);
|
|
3894
3909
|
for (const [index, param] of parameters.entries()) {
|
|
3895
3910
|
map.set(param, args[index]);
|
|
3896
3911
|
}
|
|
3897
3912
|
return {
|
|
3898
3913
|
partial: false,
|
|
3899
|
-
args,
|
|
3914
|
+
args: [...((_b = parentMapper === null || parentMapper === void 0 ? void 0 : parentMapper.args) !== null && _b !== void 0 ? _b : []), ...args],
|
|
3900
3915
|
getMappedType: (type) => {
|
|
3901
3916
|
var _a;
|
|
3902
3917
|
return (_a = map.get(type)) !== null && _a !== void 0 ? _a : type;
|
|
@@ -4069,21 +4084,24 @@ function countPropertiesInherited(model, filter) {
|
|
|
4069
4084
|
}
|
|
4070
4085
|
return count;
|
|
4071
4086
|
}
|
|
4072
|
-
export function finishTypeForProgram(program, typeDef
|
|
4073
|
-
return finishTypeForProgramAndChecker(program, program.checker.typePrototype, typeDef
|
|
4087
|
+
export function finishTypeForProgram(program, typeDef) {
|
|
4088
|
+
return finishTypeForProgramAndChecker(program, program.checker.typePrototype, typeDef);
|
|
4074
4089
|
}
|
|
4075
|
-
function
|
|
4090
|
+
function linkMapper(typeDef, mapper) {
|
|
4076
4091
|
if (mapper) {
|
|
4077
4092
|
compilerAssert(!typeDef.templateArguments, "Mapper provided but template arguments already set.");
|
|
4078
4093
|
typeDef.templateMapper = mapper;
|
|
4079
4094
|
typeDef.templateArguments = mapper.args;
|
|
4080
4095
|
}
|
|
4096
|
+
}
|
|
4097
|
+
function finishTypeForProgramAndChecker(program, typePrototype, typeDef) {
|
|
4081
4098
|
if ("decorators" in typeDef) {
|
|
4082
4099
|
for (const decApp of typeDef.decorators) {
|
|
4083
4100
|
applyDecoratorToType(program, decApp, typeDef);
|
|
4084
4101
|
}
|
|
4085
4102
|
}
|
|
4086
4103
|
Object.setPrototypeOf(typeDef, typePrototype);
|
|
4104
|
+
typeDef.isFinished = true;
|
|
4087
4105
|
return typeDef;
|
|
4088
4106
|
}
|
|
4089
4107
|
function applyDecoratorToType(program, decApp, target) {
|