@typespec/compiler 0.47.0-dev.13 → 0.47.0-dev.16
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/manifest.js +2 -2
- package/dist/src/core/checker.d.ts.map +1 -1
- package/dist/src/core/checker.js +139 -66
- package/dist/src/core/checker.js.map +1 -1
- package/dist/src/core/cli/actions/compile/compile.d.ts.map +1 -1
- package/dist/src/core/cli/actions/compile/compile.js +59 -51
- package/dist/src/core/cli/actions/compile/compile.js.map +1 -1
- package/dist/src/core/cli/actions/compile/watch.d.ts +15 -0
- package/dist/src/core/cli/actions/compile/watch.d.ts.map +1 -0
- package/dist/src/core/cli/actions/compile/watch.js +59 -0
- package/dist/src/core/cli/actions/compile/watch.js.map +1 -0
- package/package.json +1 -2
package/dist/manifest.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../../../src/core/checker.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAqC,MAAM,oBAAoB,CAAC;AAGxF,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAUzD,OAAO,EAIL,cAAc,EACd,kBAAkB,EAQlB,UAAU,EACV,gBAAgB,EAMhB,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,WAAW,EACX,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,GAAG,EAYH,IAAI,EAIJ,iBAAiB,EACjB,kBAAkB,EAMlB,WAAW,EAEX,SAAS,EACT,QAAQ,EACT,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,eAAe,GAAG,IAAI,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gB,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/src/core/checker.js
CHANGED
|
@@ -1082,7 +1082,8 @@ export function createChecker(program) {
|
|
|
1082
1082
|
function checkOperation(node, mapper, parentInterface) {
|
|
1083
1083
|
var _a;
|
|
1084
1084
|
const inInterface = ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.kind) === SyntaxKind.InterfaceStatement;
|
|
1085
|
-
const
|
|
1085
|
+
const symbol = inInterface ? getSymbolForMember(node) : node.symbol;
|
|
1086
|
+
const links = symbol && getSymbolLinks(symbol);
|
|
1086
1087
|
if (links) {
|
|
1087
1088
|
if (links.declaredType && mapper === undefined) {
|
|
1088
1089
|
// we're not instantiating this operation and we've already checked it
|
|
@@ -1109,8 +1110,19 @@ export function createChecker(program) {
|
|
|
1109
1110
|
return errorType;
|
|
1110
1111
|
}
|
|
1111
1112
|
sourceOperation = baseOperation;
|
|
1113
|
+
const parameterModelSym = getOrCreateAugmentedSymbolTable(symbol.metatypeMembers).get("parameters");
|
|
1112
1114
|
// Reference the same return type and create the parameters type
|
|
1113
|
-
|
|
1115
|
+
const clone = initializeClone(baseOperation.parameters, {
|
|
1116
|
+
properties: createRekeyableMap(),
|
|
1117
|
+
});
|
|
1118
|
+
clone.properties = createRekeyableMap(Array.from(baseOperation.parameters.properties.entries()).map(([key, prop]) => [
|
|
1119
|
+
key,
|
|
1120
|
+
cloneTypeForSymbol(getMemberSymbol(parameterModelSym, prop.name), prop, {
|
|
1121
|
+
model: clone,
|
|
1122
|
+
sourceProperty: prop,
|
|
1123
|
+
}),
|
|
1124
|
+
]));
|
|
1125
|
+
parameters = finishType(clone);
|
|
1114
1126
|
returnType = baseOperation.returnType;
|
|
1115
1127
|
// Copy decorators from the base operation, inserting the base decorators first
|
|
1116
1128
|
decorators = [...baseOperation.decorators];
|
|
@@ -1774,13 +1786,6 @@ export function createChecker(program) {
|
|
|
1774
1786
|
}
|
|
1775
1787
|
// Evaluate the properties after
|
|
1776
1788
|
checkModelProperties(node, type.properties, type, mapper);
|
|
1777
|
-
for (const prop of walkPropertiesInherited(type)) {
|
|
1778
|
-
const table = getOrCreateAugmentedSymbolTable(node.symbol.members);
|
|
1779
|
-
const sym = table.get(prop.name);
|
|
1780
|
-
if (sym) {
|
|
1781
|
-
mutate(sym).type = prop;
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
1789
|
linkMapper(type, mapper);
|
|
1785
1790
|
if (shouldCreateTypeForTemplate(node, mapper)) {
|
|
1786
1791
|
finishType(type);
|
|
@@ -1844,7 +1849,7 @@ export function createChecker(program) {
|
|
|
1844
1849
|
}
|
|
1845
1850
|
else {
|
|
1846
1851
|
// spread property
|
|
1847
|
-
const newProperties = checkSpreadProperty(prop.target, parentModel, mapper);
|
|
1852
|
+
const newProperties = checkSpreadProperty(node.symbol, prop.target, parentModel, mapper);
|
|
1848
1853
|
for (const newProp of newProperties) {
|
|
1849
1854
|
linkIndirectMember(node, newProp, mapper);
|
|
1850
1855
|
checkPropertyCompatibleWithIndexer(parentModel, newProp, prop);
|
|
@@ -1989,40 +1994,68 @@ export function createChecker(program) {
|
|
|
1989
1994
|
}
|
|
1990
1995
|
}
|
|
1991
1996
|
}
|
|
1992
|
-
function
|
|
1997
|
+
function copyMembersToContainer(targetContainerSym, table) {
|
|
1993
1998
|
var _a;
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
1999
|
+
const members = (_a = augmentedSymbolTables.get(table)) !== null && _a !== void 0 ? _a : table;
|
|
2000
|
+
compilerAssert(targetContainerSym.members, "containerSym.members is undefined");
|
|
2001
|
+
const containerMembers = getOrCreateAugmentedSymbolTable(targetContainerSym.members);
|
|
2002
|
+
for (const member of members.values()) {
|
|
2003
|
+
bindMemberToContainer(targetContainerSym, containerMembers, member.name, member.declarations[0], member.flags);
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
function bindMemberToContainer(containerSym, containerMembers, name, node, kind) {
|
|
2007
|
+
const sym = createSymbol(node, name, kind, containerSym);
|
|
2008
|
+
compilerAssert(containerSym.members, "containerSym.members is undefined");
|
|
2009
|
+
containerMembers.set(name, sym);
|
|
2010
|
+
}
|
|
2011
|
+
function bindMetaTypes(node) {
|
|
2012
|
+
const visited = new Set();
|
|
2013
|
+
function visit(node, symbol) {
|
|
2014
|
+
var _a;
|
|
2015
|
+
if (visited.has(node)) {
|
|
2016
|
+
return;
|
|
2004
2017
|
}
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2018
|
+
visited.add(node);
|
|
2019
|
+
switch (node.kind) {
|
|
2020
|
+
case SyntaxKind.ModelProperty: {
|
|
2021
|
+
const sym = getSymbolForMember(node);
|
|
2022
|
+
if (sym) {
|
|
2023
|
+
const table = getOrCreateAugmentedSymbolTable(sym.metatypeMembers);
|
|
2024
|
+
table.set("type", node.value.kind === SyntaxKind.TypeReference
|
|
2025
|
+
? createSymbol(node.value, "", 2048 /* SymbolFlags.Alias */)
|
|
2026
|
+
: node.value.symbol);
|
|
2027
|
+
}
|
|
2028
|
+
break;
|
|
2011
2029
|
}
|
|
2012
|
-
|
|
2013
|
-
const
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
table.set("parameters",
|
|
2017
|
-
table.set("returnType",
|
|
2030
|
+
case SyntaxKind.OperationStatement: {
|
|
2031
|
+
const sym = (_a = symbol !== null && symbol !== void 0 ? symbol : node.symbol) !== null && _a !== void 0 ? _a : getSymbolForMember(node);
|
|
2032
|
+
const table = getOrCreateAugmentedSymbolTable(sym.metatypeMembers);
|
|
2033
|
+
if (node.signature.kind === SyntaxKind.OperationSignatureDeclaration) {
|
|
2034
|
+
table.set("parameters", node.signature.parameters.symbol);
|
|
2035
|
+
table.set("returnType", node.signature.returnType.symbol);
|
|
2018
2036
|
}
|
|
2037
|
+
else {
|
|
2038
|
+
const sig = resolveTypeReferenceSym(node.signature.baseOperation, undefined);
|
|
2039
|
+
if (sig) {
|
|
2040
|
+
visit(sig.declarations[0], sig);
|
|
2041
|
+
const sigTable = getOrCreateAugmentedSymbolTable(sig.metatypeMembers);
|
|
2042
|
+
const sigParameterSym = sigTable.get("parameters");
|
|
2043
|
+
if (sigParameterSym !== undefined) {
|
|
2044
|
+
const parametersSym = createSymbol(sigParameterSym.declarations[0], "parameters", 2 /* SymbolFlags.Model */ & 674 /* SymbolFlags.MemberContainer */);
|
|
2045
|
+
copyMembersToContainer(parametersSym, sigParameterSym.members);
|
|
2046
|
+
table.set("parameters", parametersSym);
|
|
2047
|
+
table.set("returnType", sigTable.get("returnType"));
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
break;
|
|
2019
2052
|
}
|
|
2020
|
-
break;
|
|
2021
2053
|
}
|
|
2054
|
+
visitChildren(node, (child) => {
|
|
2055
|
+
bindMetaTypes(child);
|
|
2056
|
+
});
|
|
2022
2057
|
}
|
|
2023
|
-
|
|
2024
|
-
bindMetaTypes(child);
|
|
2025
|
-
});
|
|
2058
|
+
visit(node);
|
|
2026
2059
|
}
|
|
2027
2060
|
/**
|
|
2028
2061
|
* Initializes a late bound symbol for the type. This is generally necessary when attempting to
|
|
@@ -2184,7 +2217,7 @@ export function createChecker(program) {
|
|
|
2184
2217
|
}
|
|
2185
2218
|
return isType;
|
|
2186
2219
|
}
|
|
2187
|
-
function checkSpreadProperty(targetNode, parentModel, mapper) {
|
|
2220
|
+
function checkSpreadProperty(parentModelSym, targetNode, parentModel, mapper) {
|
|
2188
2221
|
const targetType = getTypeForNode(targetNode, mapper);
|
|
2189
2222
|
if (targetType.kind === "TemplateParameter" || isErrorType(targetType)) {
|
|
2190
2223
|
return [];
|
|
@@ -2196,7 +2229,8 @@ export function createChecker(program) {
|
|
|
2196
2229
|
const props = [];
|
|
2197
2230
|
// copy each property
|
|
2198
2231
|
for (const prop of walkPropertiesInherited(targetType)) {
|
|
2199
|
-
|
|
2232
|
+
const memberSym = getMemberSymbol(parentModelSym, prop.name);
|
|
2233
|
+
props.push(cloneTypeForSymbol(memberSym, prop, {
|
|
2200
2234
|
sourceProperty: prop,
|
|
2201
2235
|
model: parentModel,
|
|
2202
2236
|
}));
|
|
@@ -2429,6 +2463,18 @@ export function createChecker(program) {
|
|
|
2429
2463
|
}
|
|
2430
2464
|
return valid;
|
|
2431
2465
|
}
|
|
2466
|
+
function checkAugmentDecorators(sym, targetType, mapper) {
|
|
2467
|
+
var _a;
|
|
2468
|
+
const augmentDecoratorNodes = (_a = augmentDecoratorsForSym.get(sym)) !== null && _a !== void 0 ? _a : [];
|
|
2469
|
+
const decorators = [];
|
|
2470
|
+
for (const decNode of augmentDecoratorNodes) {
|
|
2471
|
+
const decorator = checkDecorator(targetType, decNode, mapper);
|
|
2472
|
+
if (decorator) {
|
|
2473
|
+
decorators.unshift(decorator);
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
return decorators;
|
|
2477
|
+
}
|
|
2432
2478
|
function checkDecorators(targetType, node, mapper) {
|
|
2433
2479
|
var _a, _b;
|
|
2434
2480
|
const sym = isMemberNode(node) ? (_a = getSymbolForMember(node)) !== null && _a !== void 0 ? _a : node.symbol : node.symbol;
|
|
@@ -2449,7 +2495,7 @@ export function createChecker(program) {
|
|
|
2449
2495
|
if (docComment) {
|
|
2450
2496
|
decorators.unshift({
|
|
2451
2497
|
decorator: $docFromComment,
|
|
2452
|
-
args: [{ value:
|
|
2498
|
+
args: [{ value: createLiteralType(docComment), jsValue: docComment }],
|
|
2453
2499
|
});
|
|
2454
2500
|
}
|
|
2455
2501
|
return decorators;
|
|
@@ -2582,7 +2628,7 @@ export function createChecker(program) {
|
|
|
2582
2628
|
enumType.members.set(memberType.name, memberType);
|
|
2583
2629
|
}
|
|
2584
2630
|
else {
|
|
2585
|
-
const members = checkEnumSpreadMember(enumType, member.target, mapper, memberNames);
|
|
2631
|
+
const members = checkEnumSpreadMember(node.symbol, enumType, member.target, mapper, memberNames);
|
|
2586
2632
|
for (const memberType of members) {
|
|
2587
2633
|
linkIndirectMember(node, memberType, mapper);
|
|
2588
2634
|
enumType.members.set(memberType.name, memberType);
|
|
@@ -2632,7 +2678,9 @@ export function createChecker(program) {
|
|
|
2632
2678
|
target: extendsNode,
|
|
2633
2679
|
}));
|
|
2634
2680
|
}
|
|
2635
|
-
const newMember =
|
|
2681
|
+
const newMember = cloneTypeForSymbol(getMemberSymbol(node.symbol, member.name), member, {
|
|
2682
|
+
interface: interfaceType,
|
|
2683
|
+
});
|
|
2636
2684
|
// Don't link it it is overritten
|
|
2637
2685
|
if (!ownMembers.has(member.name)) {
|
|
2638
2686
|
linkIndirectMember(node, newMember, mapper);
|
|
@@ -2753,6 +2801,9 @@ export function createChecker(program) {
|
|
|
2753
2801
|
node.kind === SyntaxKind.OperationStatement ||
|
|
2754
2802
|
node.kind === SyntaxKind.UnionVariant);
|
|
2755
2803
|
}
|
|
2804
|
+
function getMemberSymbol(parentSym, name) {
|
|
2805
|
+
return parentSym ? getOrCreateAugmentedSymbolTable(parentSym.members).get(name) : undefined;
|
|
2806
|
+
}
|
|
2756
2807
|
function getSymbolForMember(node) {
|
|
2757
2808
|
var _a;
|
|
2758
2809
|
const name = node.id.sv;
|
|
@@ -2785,7 +2836,7 @@ export function createChecker(program) {
|
|
|
2785
2836
|
member.decorators = checkDecorators(member, node, mapper);
|
|
2786
2837
|
return finishType(member);
|
|
2787
2838
|
}
|
|
2788
|
-
function checkEnumSpreadMember(parentEnum, targetNode, mapper, existingMemberNames) {
|
|
2839
|
+
function checkEnumSpreadMember(parentEnumSym, parentEnum, targetNode, mapper, existingMemberNames) {
|
|
2789
2840
|
const members = [];
|
|
2790
2841
|
const targetType = getTypeForNode(targetNode, mapper);
|
|
2791
2842
|
if (!isErrorType(targetType)) {
|
|
@@ -2803,7 +2854,8 @@ export function createChecker(program) {
|
|
|
2803
2854
|
}
|
|
2804
2855
|
else {
|
|
2805
2856
|
existingMemberNames.add(member.name);
|
|
2806
|
-
const
|
|
2857
|
+
const memberSym = getMemberSymbol(parentEnumSym, member.name);
|
|
2858
|
+
const clonedMember = cloneTypeForSymbol(memberSym, member, {
|
|
2807
2859
|
enum: parentEnum,
|
|
2808
2860
|
sourceMember: member,
|
|
2809
2861
|
});
|
|
@@ -2992,23 +3044,7 @@ export function createChecker(program) {
|
|
|
2992
3044
|
getSymbolLinks(globalNamespaceNode.symbol).type = type;
|
|
2993
3045
|
return type;
|
|
2994
3046
|
}
|
|
2995
|
-
|
|
2996
|
-
* Clone a type, resulting in an identical type with all the same decorators
|
|
2997
|
-
* applied. Decorators are re-run on the clone to achieve this.
|
|
2998
|
-
*
|
|
2999
|
-
* Care is taken to clone nested data structures that are part of the type.
|
|
3000
|
-
* Any type with e.g. a map or an array property must recreate the map or array
|
|
3001
|
-
* so that clones don't share the same object.
|
|
3002
|
-
*
|
|
3003
|
-
* For types which have sub-types that are part of it, e.g. enums with members,
|
|
3004
|
-
* unions with variants, or models with properties, the sub-types are cloned
|
|
3005
|
-
* as well.
|
|
3006
|
-
*
|
|
3007
|
-
* If the entire type graph needs to be cloned, then cloneType must be called
|
|
3008
|
-
* recursively by the caller.
|
|
3009
|
-
*/
|
|
3010
|
-
function cloneType(type, additionalProps = {}) {
|
|
3011
|
-
// TODO: this needs to handle other types
|
|
3047
|
+
function initializeClone(type, additionalProps) {
|
|
3012
3048
|
let clone;
|
|
3013
3049
|
switch (type.kind) {
|
|
3014
3050
|
case "Model":
|
|
@@ -3024,7 +3060,7 @@ export function createChecker(program) {
|
|
|
3024
3060
|
cloneType(prop, { model: newModel }),
|
|
3025
3061
|
]));
|
|
3026
3062
|
}
|
|
3027
|
-
clone =
|
|
3063
|
+
clone = newModel;
|
|
3028
3064
|
break;
|
|
3029
3065
|
case "Union":
|
|
3030
3066
|
const newUnion = createType({
|
|
@@ -3042,7 +3078,7 @@ export function createChecker(program) {
|
|
|
3042
3078
|
cloneType(prop, { union: newUnion }),
|
|
3043
3079
|
]));
|
|
3044
3080
|
}
|
|
3045
|
-
clone =
|
|
3081
|
+
clone = newUnion;
|
|
3046
3082
|
break;
|
|
3047
3083
|
case "Interface":
|
|
3048
3084
|
const newInterface = createType({
|
|
@@ -3057,7 +3093,7 @@ export function createChecker(program) {
|
|
|
3057
3093
|
cloneType(prop, { interface: newInterface }),
|
|
3058
3094
|
]));
|
|
3059
3095
|
}
|
|
3060
|
-
clone =
|
|
3096
|
+
clone = newInterface;
|
|
3061
3097
|
break;
|
|
3062
3098
|
case "Enum":
|
|
3063
3099
|
const newEnum = createType({
|
|
@@ -3072,16 +3108,35 @@ export function createChecker(program) {
|
|
|
3072
3108
|
cloneType(prop, { enum: newEnum }),
|
|
3073
3109
|
]));
|
|
3074
3110
|
}
|
|
3075
|
-
clone =
|
|
3111
|
+
clone = newEnum;
|
|
3076
3112
|
break;
|
|
3077
3113
|
default:
|
|
3078
|
-
clone =
|
|
3114
|
+
clone = createType({
|
|
3079
3115
|
...type,
|
|
3080
3116
|
...("decorators" in type ? { decorators: [...type.decorators] } : {}),
|
|
3081
3117
|
...additionalProps,
|
|
3082
3118
|
});
|
|
3083
3119
|
break;
|
|
3084
3120
|
}
|
|
3121
|
+
return clone;
|
|
3122
|
+
}
|
|
3123
|
+
/**
|
|
3124
|
+
* Clone a type, resulting in an identical type with all the same decorators
|
|
3125
|
+
* applied. Decorators are re-run on the clone to achieve this.
|
|
3126
|
+
*
|
|
3127
|
+
* Care is taken to clone nested data structures that are part of the type.
|
|
3128
|
+
* Any type with e.g. a map or an array property must recreate the map or array
|
|
3129
|
+
* so that clones don't share the same object.
|
|
3130
|
+
*
|
|
3131
|
+
* For types which have sub-types that are part of it, e.g. enums with members,
|
|
3132
|
+
* unions with variants, or models with properties, the sub-types are cloned
|
|
3133
|
+
* as well.
|
|
3134
|
+
*
|
|
3135
|
+
* If the entire type graph needs to be cloned, then cloneType must be called
|
|
3136
|
+
* recursively by the caller.
|
|
3137
|
+
*/
|
|
3138
|
+
function cloneType(type, additionalProps = {}) {
|
|
3139
|
+
const clone = finishType(initializeClone(type, additionalProps));
|
|
3085
3140
|
const projection = projectionsByType.get(type);
|
|
3086
3141
|
if (projection) {
|
|
3087
3142
|
projectionsByType.set(clone, projection);
|
|
@@ -3089,6 +3144,24 @@ export function createChecker(program) {
|
|
|
3089
3144
|
compilerAssert(clone.kind === type.kind, "cloneType must not change type kind");
|
|
3090
3145
|
return clone;
|
|
3091
3146
|
}
|
|
3147
|
+
/**
|
|
3148
|
+
* Clone a type linking to the given symbol.
|
|
3149
|
+
* @param sym Symbol which to associate the clone
|
|
3150
|
+
* @param type Type to clone
|
|
3151
|
+
* @param additionalProps Additional properties to set/override on the clone
|
|
3152
|
+
* @returns cloned type
|
|
3153
|
+
*/
|
|
3154
|
+
function cloneTypeForSymbol(sym, type, additionalProps = {}) {
|
|
3155
|
+
let clone = initializeClone(type, additionalProps);
|
|
3156
|
+
if ("decorators" in clone) {
|
|
3157
|
+
for (const dec of checkAugmentDecorators(sym, clone, undefined)) {
|
|
3158
|
+
clone.decorators.push(dec);
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
clone = finishType(clone);
|
|
3162
|
+
compilerAssert(clone.kind === type.kind, "cloneType must not change type kind");
|
|
3163
|
+
return clone;
|
|
3164
|
+
}
|
|
3092
3165
|
function checkProjectionDeclaration(node) {
|
|
3093
3166
|
// todo: check for duplicate projection decls on individual types
|
|
3094
3167
|
// right now you can declare the same projection on a specific type
|