@typespec/compiler 0.42.0 → 0.43.0-dev.10
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.map +1 -1
- package/dist/core/checker.js +58 -47
- package/dist/core/checker.js.map +1 -1
- package/dist/core/cli/cli.js +1 -1
- package/dist/core/cli/cli.js.map +1 -1
- package/dist/core/helpers/projected-names-utils.d.ts.map +1 -1
- package/dist/core/helpers/projected-names-utils.js +5 -3
- package/dist/core/helpers/projected-names-utils.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/messages.d.ts +2 -20
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +0 -6
- package/dist/core/messages.js.map +1 -1
- package/dist/core/projection-members.d.ts.map +1 -1
- package/dist/core/projection-members.js +12 -19
- package/dist/core/projection-members.js.map +1 -1
- package/dist/core/projector.js +12 -12
- package/dist/core/projector.js.map +1 -1
- package/dist/core/types.d.ts +92 -4
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/util.d.ts +2 -1
- package/dist/core/util.d.ts.map +1 -1
- package/dist/core/util.js +87 -9
- package/dist/core/util.js.map +1 -1
- package/dist/emitter-framework/asset-emitter.d.ts.map +1 -1
- package/dist/emitter-framework/asset-emitter.js +3 -0
- package/dist/emitter-framework/asset-emitter.js.map +1 -1
- package/dist/emitter-framework/type-emitter.d.ts.map +1 -1
- package/dist/emitter-framework/type-emitter.js +3 -0
- package/dist/emitter-framework/type-emitter.js.map +1 -1
- package/dist/manifest.js +1 -1
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../../core/checker.ts"],"names":[],"mappings":"AAIA,OAAO,EAAqC,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGxF,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AAsB;IACrC,GAAG,EAAE,GAAG,CAAC;IAET;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AASD,KAAK,WAAW,GAAG,mBAAmB,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACvE,KAAK,QAAQ,GAAG;IAEd,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,KAAK,CAAC;CACf,GAAG,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAKxC,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAggJvD;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,EACjD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,CAAC,EACV,MAAM,CAAC,EAAE,UAAU,GAClB,CAAC,CAEH"}
|
package/dist/core/checker.js
CHANGED
|
@@ -8,7 +8,7 @@ import { getIdentifierContext, hasParseError, visitChildren } from "./parser.js"
|
|
|
8
8
|
import { createProjectionMembers } from "./projection-members.js";
|
|
9
9
|
import { getParentTemplateNode, isNeverType, isTemplateInstance, isUnknownType, isVoidType, } from "./type-utils.js";
|
|
10
10
|
import { IdentifierKind, SyntaxKind, } from "./types.js";
|
|
11
|
-
import { isArray, MultiKeyMap, mutate } from "./util.js";
|
|
11
|
+
import { createRekeyableMap, isArray, MultiKeyMap, mutate } from "./util.js";
|
|
12
12
|
/**
|
|
13
13
|
* Maps type arguments to type instantiation.
|
|
14
14
|
*/
|
|
@@ -367,16 +367,22 @@ export function createChecker(program) {
|
|
|
367
367
|
// bubbles out somewhere its not supposed to be.
|
|
368
368
|
return errorType;
|
|
369
369
|
}
|
|
370
|
-
function getFullyQualifiedSymbolName(sym) {
|
|
370
|
+
function getFullyQualifiedSymbolName(sym, options) {
|
|
371
371
|
if (!sym)
|
|
372
372
|
return "";
|
|
373
373
|
if (sym.symbolSource)
|
|
374
374
|
sym = sym.symbolSource;
|
|
375
|
-
const parent = sym.parent;
|
|
375
|
+
const parent = sym.parent && !(sym.parent.flags & 2097152 /* SymbolFlags.SourceFile */) ? sym.parent : undefined;
|
|
376
376
|
const name = sym.flags & 16384 /* SymbolFlags.Decorator */ ? sym.name.slice(1) : sym.name;
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
377
|
+
if (parent === null || parent === void 0 ? void 0 : parent.name) {
|
|
378
|
+
return `${getFullyQualifiedSymbolName(parent)}.${name}`;
|
|
379
|
+
}
|
|
380
|
+
else if (options === null || options === void 0 ? void 0 : options.useGlobalPrefixAtTopLevel) {
|
|
381
|
+
return `global.${name}`;
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
return name;
|
|
385
|
+
}
|
|
380
386
|
}
|
|
381
387
|
/**
|
|
382
388
|
* Return a fully qualified id of node
|
|
@@ -748,7 +754,7 @@ export function createChecker(program) {
|
|
|
748
754
|
return Array.from(this.variants.values()).map((v) => v.type);
|
|
749
755
|
},
|
|
750
756
|
expression: true,
|
|
751
|
-
variants:
|
|
757
|
+
variants: createRekeyableMap(),
|
|
752
758
|
decorators: [],
|
|
753
759
|
});
|
|
754
760
|
for (const o of node.options) {
|
|
@@ -867,7 +873,7 @@ export function createChecker(program) {
|
|
|
867
873
|
return parameterType;
|
|
868
874
|
}
|
|
869
875
|
function mergeModelTypes(node, options, mapper) {
|
|
870
|
-
const properties =
|
|
876
|
+
const properties = createRekeyableMap();
|
|
871
877
|
const intersection = createType({
|
|
872
878
|
kind: "Model",
|
|
873
879
|
node,
|
|
@@ -1188,10 +1194,10 @@ export function createChecker(program) {
|
|
|
1188
1194
|
return getMergedSymbol(sym);
|
|
1189
1195
|
}
|
|
1190
1196
|
function reportAmbiguousIdentifier(node, symbols) {
|
|
1191
|
-
const duplicateNames = symbols.map(getFullyQualifiedSymbolName
|
|
1197
|
+
const duplicateNames = symbols.map((s) => getFullyQualifiedSymbolName(s, { useGlobalPrefixAtTopLevel: true }));
|
|
1192
1198
|
reportCheckerDiagnostic(createDiagnostic({
|
|
1193
1199
|
code: "ambiguous-symbol",
|
|
1194
|
-
format: { name: node.sv, duplicateNames },
|
|
1200
|
+
format: { name: node.sv, duplicateNames: duplicateNames.join(", ") },
|
|
1195
1201
|
target: node,
|
|
1196
1202
|
}));
|
|
1197
1203
|
}
|
|
@@ -1272,14 +1278,16 @@ export function createChecker(program) {
|
|
|
1272
1278
|
if (base.flags & 2048 /* SymbolFlags.Alias */) {
|
|
1273
1279
|
base = getAliasedSymbol(base, undefined);
|
|
1274
1280
|
}
|
|
1275
|
-
if (
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1281
|
+
if (base) {
|
|
1282
|
+
if (isTemplatedNode(base.declarations[0])) {
|
|
1283
|
+
const type = (_a = base.type) !== null && _a !== void 0 ? _a : getTypeForNode(base.declarations[0], undefined);
|
|
1284
|
+
if (isTemplateInstance(type)) {
|
|
1285
|
+
lateBindMemberContainer(type);
|
|
1286
|
+
lateBindMembers(type, base);
|
|
1287
|
+
}
|
|
1280
1288
|
}
|
|
1289
|
+
addCompletions((_b = base.exports) !== null && _b !== void 0 ? _b : base.members);
|
|
1281
1290
|
}
|
|
1282
|
-
addCompletions((_b = base.exports) !== null && _b !== void 0 ? _b : base.members);
|
|
1283
1291
|
}
|
|
1284
1292
|
}
|
|
1285
1293
|
else {
|
|
@@ -1391,13 +1399,19 @@ export function createChecker(program) {
|
|
|
1391
1399
|
return binding;
|
|
1392
1400
|
}
|
|
1393
1401
|
// check "global scope" declarations
|
|
1394
|
-
|
|
1395
|
-
if (binding)
|
|
1396
|
-
return binding;
|
|
1402
|
+
const globalBinding = resolveIdentifierInTable(node, globalNamespaceNode.symbol.exports, resolveDecorator);
|
|
1397
1403
|
// check using types
|
|
1398
|
-
|
|
1399
|
-
if (
|
|
1400
|
-
|
|
1404
|
+
const usingBinding = resolveIdentifierInTable(node, scope.locals, resolveDecorator);
|
|
1405
|
+
if (globalBinding && usingBinding) {
|
|
1406
|
+
reportAmbiguousIdentifier(node, [globalBinding, usingBinding]);
|
|
1407
|
+
return globalBinding;
|
|
1408
|
+
}
|
|
1409
|
+
else if (globalBinding) {
|
|
1410
|
+
return globalBinding;
|
|
1411
|
+
}
|
|
1412
|
+
else if (usingBinding) {
|
|
1413
|
+
return usingBinding.flags & 1048576 /* SymbolFlags.DuplicateUsing */ ? undefined : usingBinding;
|
|
1414
|
+
}
|
|
1401
1415
|
}
|
|
1402
1416
|
if (mapper === undefined) {
|
|
1403
1417
|
reportCheckerDiagnostic(createDiagnostic({ code: "unknown-identifier", format: { id: node.sv }, target: node }));
|
|
@@ -1429,6 +1443,9 @@ export function createChecker(program) {
|
|
|
1429
1443
|
// when resolving a type reference based on an alias, unwrap the alias.
|
|
1430
1444
|
if (base.flags & 2048 /* SymbolFlags.Alias */) {
|
|
1431
1445
|
base = getAliasedSymbol(base, mapper);
|
|
1446
|
+
if (!base) {
|
|
1447
|
+
return undefined;
|
|
1448
|
+
}
|
|
1432
1449
|
}
|
|
1433
1450
|
if (base.flags & 4096 /* SymbolFlags.Namespace */) {
|
|
1434
1451
|
const symbol = resolveIdentifierInTable(node.id, base.exports, resolveDecorator);
|
|
@@ -1532,6 +1549,9 @@ export function createChecker(program) {
|
|
|
1532
1549
|
function getAliasedSymbol(aliasSymbol, mapper) {
|
|
1533
1550
|
var _a;
|
|
1534
1551
|
const aliasType = checkAlias(aliasSymbol.declarations[0], mapper);
|
|
1552
|
+
if (isErrorType(aliasType)) {
|
|
1553
|
+
return undefined;
|
|
1554
|
+
}
|
|
1535
1555
|
switch (aliasType.kind) {
|
|
1536
1556
|
case "Model":
|
|
1537
1557
|
case "Interface":
|
|
@@ -1625,7 +1645,7 @@ export function createChecker(program) {
|
|
|
1625
1645
|
kind: "Model",
|
|
1626
1646
|
name: node.id.sv,
|
|
1627
1647
|
node: node,
|
|
1628
|
-
properties:
|
|
1648
|
+
properties: createRekeyableMap(),
|
|
1629
1649
|
namespace: getParentNamespaceType(node),
|
|
1630
1650
|
decorators,
|
|
1631
1651
|
derivedModels: [],
|
|
@@ -1705,7 +1725,7 @@ export function createChecker(program) {
|
|
|
1705
1725
|
return mapper.args.every((t) => t.kind !== "TemplateParameter");
|
|
1706
1726
|
}
|
|
1707
1727
|
function checkModelExpression(node, mapper) {
|
|
1708
|
-
const properties =
|
|
1728
|
+
const properties = createRekeyableMap();
|
|
1709
1729
|
const type = createType({
|
|
1710
1730
|
kind: "Model",
|
|
1711
1731
|
name: "",
|
|
@@ -1760,17 +1780,8 @@ export function createChecker(program) {
|
|
|
1760
1780
|
const overriddenProp = getOverriddenProperty(newProp);
|
|
1761
1781
|
if (overriddenProp) {
|
|
1762
1782
|
const [isAssignable, _] = isTypeAssignableTo(newProp.type, overriddenProp.type, newProp);
|
|
1763
|
-
const parentScalar = overriddenProp.type.kind === "Scalar";
|
|
1764
1783
|
const parentType = getTypeName(overriddenProp.type);
|
|
1765
1784
|
const newPropType = getTypeName(newProp.type);
|
|
1766
|
-
if (!parentScalar) {
|
|
1767
|
-
reportCheckerDiagnostic(createDiagnostic({
|
|
1768
|
-
code: "override-property-intrinsic",
|
|
1769
|
-
format: { propName: newProp.name, propType: newPropType, parentType: parentType },
|
|
1770
|
-
target: diagnosticTarget !== null && diagnosticTarget !== void 0 ? diagnosticTarget : newProp,
|
|
1771
|
-
}));
|
|
1772
|
-
return;
|
|
1773
|
-
}
|
|
1774
1785
|
if (!isAssignable) {
|
|
1775
1786
|
reportCheckerDiagnostic(createDiagnostic({
|
|
1776
1787
|
code: "override-property-mismatch",
|
|
@@ -2374,7 +2385,7 @@ export function createChecker(program) {
|
|
|
2374
2385
|
kind: "Enum",
|
|
2375
2386
|
name: node.id.sv,
|
|
2376
2387
|
node,
|
|
2377
|
-
members:
|
|
2388
|
+
members: createRekeyableMap(),
|
|
2378
2389
|
decorators: [],
|
|
2379
2390
|
}));
|
|
2380
2391
|
const memberNames = new Set();
|
|
@@ -2420,7 +2431,7 @@ export function createChecker(program) {
|
|
|
2420
2431
|
decorators: [],
|
|
2421
2432
|
node,
|
|
2422
2433
|
namespace: getParentNamespaceType(node),
|
|
2423
|
-
operations:
|
|
2434
|
+
operations: createRekeyableMap(),
|
|
2424
2435
|
name: node.id.sv,
|
|
2425
2436
|
});
|
|
2426
2437
|
interfaceType.decorators = checkDecorators(interfaceType, node, mapper);
|
|
@@ -2484,7 +2495,7 @@ export function createChecker(program) {
|
|
|
2484
2495
|
// we're not instantiating this union and we've already checked it
|
|
2485
2496
|
return links.declaredType;
|
|
2486
2497
|
}
|
|
2487
|
-
const variants =
|
|
2498
|
+
const variants = createRekeyableMap();
|
|
2488
2499
|
const unionType = createType({
|
|
2489
2500
|
kind: "Union",
|
|
2490
2501
|
decorators: [],
|
|
@@ -2790,7 +2801,7 @@ export function createChecker(program) {
|
|
|
2790
2801
|
...additionalProps,
|
|
2791
2802
|
});
|
|
2792
2803
|
if (!("properties" in additionalProps)) {
|
|
2793
|
-
newModel.properties =
|
|
2804
|
+
newModel.properties = createRekeyableMap(Array.from(type.properties.entries()).map(([key, prop]) => [
|
|
2794
2805
|
key,
|
|
2795
2806
|
cloneType(prop, { model: newModel }),
|
|
2796
2807
|
]));
|
|
@@ -2808,7 +2819,7 @@ export function createChecker(program) {
|
|
|
2808
2819
|
...additionalProps,
|
|
2809
2820
|
});
|
|
2810
2821
|
if (!("variants" in additionalProps)) {
|
|
2811
|
-
newUnion.variants =
|
|
2822
|
+
newUnion.variants = createRekeyableMap(Array.from(type.variants.entries()).map(([key, prop]) => [
|
|
2812
2823
|
key,
|
|
2813
2824
|
cloneType(prop, { union: newUnion }),
|
|
2814
2825
|
]));
|
|
@@ -2823,7 +2834,7 @@ export function createChecker(program) {
|
|
|
2823
2834
|
...additionalProps,
|
|
2824
2835
|
});
|
|
2825
2836
|
if (!("operations" in additionalProps)) {
|
|
2826
|
-
newInterface.operations =
|
|
2837
|
+
newInterface.operations = createRekeyableMap(Array.from(type.operations.entries()).map(([key, prop]) => [
|
|
2827
2838
|
key,
|
|
2828
2839
|
cloneType(prop, { interface: newInterface }),
|
|
2829
2840
|
]));
|
|
@@ -2838,7 +2849,7 @@ export function createChecker(program) {
|
|
|
2838
2849
|
...additionalProps,
|
|
2839
2850
|
});
|
|
2840
2851
|
if (!("members" in additionalProps)) {
|
|
2841
|
-
newEnum.members =
|
|
2852
|
+
newEnum.members = createRekeyableMap(Array.from(type.members.entries()).map(([key, prop]) => [
|
|
2842
2853
|
key,
|
|
2843
2854
|
cloneType(prop, { enum: newEnum }),
|
|
2844
2855
|
]));
|
|
@@ -2979,7 +2990,7 @@ export function createChecker(program) {
|
|
|
2979
2990
|
name: "",
|
|
2980
2991
|
node: node,
|
|
2981
2992
|
decorators: [],
|
|
2982
|
-
properties:
|
|
2993
|
+
properties: createRekeyableMap(),
|
|
2983
2994
|
derivedModels: [],
|
|
2984
2995
|
});
|
|
2985
2996
|
for (const propNode of node.properties) {
|
|
@@ -3450,11 +3461,11 @@ export function createChecker(program) {
|
|
|
3450
3461
|
*/
|
|
3451
3462
|
function isTypeAssignableTo(source, target, diagnosticTarget) {
|
|
3452
3463
|
var _a;
|
|
3453
|
-
if (source === target)
|
|
3454
|
-
return [true, []];
|
|
3455
3464
|
if (source.kind === "TemplateParameter") {
|
|
3456
3465
|
source = (_a = source.constraint) !== null && _a !== void 0 ? _a : unknownType;
|
|
3457
3466
|
}
|
|
3467
|
+
if (source === target)
|
|
3468
|
+
return [true, []];
|
|
3458
3469
|
const isSimpleTypeRelated = isSimpleTypeAssignableTo(source, target);
|
|
3459
3470
|
if (isSimpleTypeRelated === true) {
|
|
3460
3471
|
return [true, []];
|
|
@@ -3606,7 +3617,7 @@ export function createChecker(program) {
|
|
|
3606
3617
|
}
|
|
3607
3618
|
function isIndexerValid(source, target, diagnosticTarget) {
|
|
3608
3619
|
// Model expressions should be able to be assigned.
|
|
3609
|
-
if (source.name === "") {
|
|
3620
|
+
if (source.name === "" && target.indexer.key.name !== "integer") {
|
|
3610
3621
|
return isIndexConstraintValid(target.indexer.value, source, diagnosticTarget);
|
|
3611
3622
|
}
|
|
3612
3623
|
else {
|
|
@@ -3676,8 +3687,8 @@ export function createChecker(program) {
|
|
|
3676
3687
|
return [true, []];
|
|
3677
3688
|
}
|
|
3678
3689
|
function isAssignableToUnion(source, target, diagnosticTarget) {
|
|
3679
|
-
for (const option of target.
|
|
3680
|
-
const [related] = isTypeAssignableTo(source, option, diagnosticTarget);
|
|
3690
|
+
for (const option of target.variants.values()) {
|
|
3691
|
+
const [related] = isTypeAssignableTo(source, option.type, diagnosticTarget);
|
|
3681
3692
|
if (related) {
|
|
3682
3693
|
return [true, []];
|
|
3683
3694
|
}
|
|
@@ -3898,7 +3909,7 @@ export function filterModelProperties(program, model, filter) {
|
|
|
3898
3909
|
if (!filtered) {
|
|
3899
3910
|
return model;
|
|
3900
3911
|
}
|
|
3901
|
-
const properties =
|
|
3912
|
+
const properties = createRekeyableMap();
|
|
3902
3913
|
const newModel = program.checker.createType({
|
|
3903
3914
|
kind: "Model",
|
|
3904
3915
|
node: undefined,
|