@typespec/compiler 0.47.0-dev.0 → 0.47.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/manifest.js +2 -2
- package/dist/src/core/checker.d.ts.map +1 -1
- package/dist/src/core/checker.js +103 -18
- package/dist/src/core/checker.js.map +1 -1
- package/dist/src/core/cli/{args.d.ts → actions/compile/args.d.ts} +3 -2
- package/dist/src/core/cli/actions/compile/args.d.ts.map +1 -0
- package/dist/src/core/cli/{args.js → actions/compile/args.js} +11 -6
- package/dist/src/core/cli/actions/compile/args.js.map +1 -0
- package/dist/src/core/cli/actions/compile/compile.d.ts +7 -0
- package/dist/src/core/cli/actions/compile/compile.d.ts.map +1 -0
- package/dist/src/core/cli/actions/compile/compile.js +105 -0
- package/dist/src/core/cli/actions/compile/compile.js.map +1 -0
- package/dist/src/core/cli/actions/format.d.ts +9 -0
- package/dist/src/core/cli/actions/format.d.ts.map +1 -0
- package/dist/src/core/cli/actions/format.js +25 -0
- package/dist/src/core/cli/actions/format.js.map +1 -0
- package/dist/src/core/cli/actions/info.d.ts +6 -0
- package/dist/src/core/cli/actions/info.d.ts.map +1 -0
- package/dist/src/core/cli/actions/info.js +21 -0
- package/dist/src/core/cli/actions/info.js.map +1 -0
- package/dist/src/core/cli/actions/init.d.ts +7 -0
- package/dist/src/core/cli/actions/init.d.ts.map +1 -0
- package/dist/src/core/cli/actions/init.js +14 -0
- package/dist/src/core/cli/actions/init.js.map +1 -0
- package/dist/src/core/cli/actions/vs.d.ts +5 -0
- package/dist/src/core/cli/actions/vs.d.ts.map +1 -0
- package/dist/src/core/cli/actions/vs.js +73 -0
- package/dist/src/core/cli/actions/vs.js.map +1 -0
- package/dist/src/core/cli/actions/vscode.d.ts +11 -0
- package/dist/src/core/cli/actions/vscode.d.ts.map +1 -0
- package/dist/src/core/cli/actions/vscode.js +34 -0
- package/dist/src/core/cli/actions/vscode.js.map +1 -0
- package/dist/src/core/cli/cli.js +26 -363
- package/dist/src/core/cli/cli.js.map +1 -1
- package/dist/src/core/cli/index.d.ts +1 -1
- package/dist/src/core/cli/index.d.ts.map +1 -1
- package/dist/src/core/cli/index.js +1 -1
- package/dist/src/core/cli/index.js.map +1 -1
- package/dist/src/core/cli/install-vsix.d.ts +3 -0
- package/dist/src/core/cli/install-vsix.d.ts.map +1 -0
- package/dist/src/core/cli/install-vsix.js +42 -0
- package/dist/src/core/cli/install-vsix.js.map +1 -0
- package/dist/src/core/cli/types.d.ts +6 -0
- package/dist/src/core/cli/types.d.ts.map +1 -0
- package/dist/src/core/cli/types.js +2 -0
- package/dist/src/core/cli/types.js.map +1 -0
- package/dist/src/core/cli/utils.d.ts +35 -0
- package/dist/src/core/cli/utils.d.ts.map +1 -0
- package/dist/src/core/cli/utils.js +114 -0
- package/dist/src/core/cli/utils.js.map +1 -0
- package/dist/src/core/deprecation.d.ts +31 -0
- package/dist/src/core/deprecation.d.ts.map +1 -0
- package/dist/src/core/deprecation.js +48 -0
- package/dist/src/core/deprecation.js.map +1 -0
- package/dist/src/core/index.d.ts +1 -0
- package/dist/src/core/index.d.ts.map +1 -1
- package/dist/src/core/index.js +1 -0
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/core/install.d.ts +2 -1
- package/dist/src/core/install.d.ts.map +1 -1
- package/dist/src/core/install.js +3 -5
- package/dist/src/core/install.js.map +1 -1
- package/dist/src/core/messages.d.ts +97 -2
- package/dist/src/core/messages.d.ts.map +1 -1
- package/dist/src/core/messages.js +33 -0
- package/dist/src/core/messages.js.map +1 -1
- package/dist/src/core/options.d.ts +4 -0
- package/dist/src/core/options.d.ts.map +1 -1
- package/dist/src/core/parser.js +1 -1
- package/dist/src/core/parser.js.map +1 -1
- package/dist/src/core/program.d.ts.map +1 -1
- package/dist/src/core/program.js +5 -3
- package/dist/src/core/program.js.map +1 -1
- package/dist/src/core/types.d.ts +9 -1
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/types.js.map +1 -1
- package/dist/src/core/util.d.ts +1 -0
- package/dist/src/core/util.d.ts.map +1 -1
- package/dist/src/core/util.js +1 -0
- package/dist/src/core/util.js.map +1 -1
- package/dist/src/emitter-framework/asset-emitter.js +2 -2
- package/dist/src/emitter-framework/asset-emitter.js.map +1 -1
- package/dist/src/emitter-framework/type-emitter.d.ts +1 -1
- package/dist/src/emitter-framework/type-emitter.d.ts.map +1 -1
- package/dist/src/emitter-framework/type-emitter.js +1 -1
- package/dist/src/emitter-framework/type-emitter.js.map +1 -1
- package/dist/src/emitter-framework/types.d.ts +1 -1
- package/dist/src/emitter-framework/types.d.ts.map +1 -1
- package/dist/src/init/init.js +1 -1
- package/dist/src/init/init.js.map +1 -1
- package/dist/src/lib/decorators.d.ts +1 -7
- package/dist/src/lib/decorators.d.ts.map +1 -1
- package/dist/src/lib/decorators.js +4 -11
- package/dist/src/lib/decorators.js.map +1 -1
- package/dist/src/server/completion.d.ts.map +1 -1
- package/dist/src/server/completion.js +9 -5
- package/dist/src/server/completion.js.map +1 -1
- package/lib/decorators.tsp +8 -2
- package/lib/lib.tsp +1 -1
- package/package.json +1 -1
- package/dist/src/core/cli/args.d.ts.map +0 -1
- package/dist/src/core/cli/args.js.map +0 -1
package/dist/manifest.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../../../src/core/checker.ts"],"names":[],"mappings":"
|
|
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,EAO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
import { $docFromComment, getIndexer } from "../lib/decorators.js";
|
|
2
2
|
import { createSymbol, createSymbolTable } from "./binder.js";
|
|
3
|
+
import { getDeprecationDetails, markDeprecated } from "./deprecation.js";
|
|
3
4
|
import { ProjectionError, compilerAssert, reportDeprecated } from "./diagnostics.js";
|
|
4
5
|
import { validateInheritanceDiscriminatedUnions } from "./helpers/discriminator-utils.js";
|
|
5
6
|
import { getNamespaceFullName, getTypeName } from "./helpers/index.js";
|
|
@@ -487,7 +488,6 @@ export function createChecker(program) {
|
|
|
487
488
|
return errorType;
|
|
488
489
|
}
|
|
489
490
|
const type = checkTypeReferenceSymbol(sym, node, mapper, instantiateTemplate);
|
|
490
|
-
checkDeprecated(type, node);
|
|
491
491
|
return type;
|
|
492
492
|
}
|
|
493
493
|
function resolveTypeReference(node) {
|
|
@@ -498,16 +498,23 @@ export function createChecker(program) {
|
|
|
498
498
|
onCheckerDiagnostic = oldDiagnosticHook;
|
|
499
499
|
return [type === errorType ? undefined : type, diagnostics];
|
|
500
500
|
}
|
|
501
|
-
function
|
|
502
|
-
const
|
|
503
|
-
if (
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
501
|
+
function copyDeprecation(sourceType, destType) {
|
|
502
|
+
const deprecationDetails = getDeprecationDetails(program, sourceType);
|
|
503
|
+
if (deprecationDetails) {
|
|
504
|
+
markDeprecated(program, destType, deprecationDetails);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
function checkDeprecated(type, node, target) {
|
|
508
|
+
if (node) {
|
|
509
|
+
const deprecationDetails = getDeprecationDetails(program, node);
|
|
510
|
+
if (deprecationDetails) {
|
|
511
|
+
reportDeprecation(program, target, deprecationDetails.message, reportCheckerDiagnostic);
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
const deprecationDetails = getDeprecationDetails(program, type);
|
|
516
|
+
if (deprecationDetails) {
|
|
517
|
+
reportDeprecation(program, target, deprecationDetails.message, reportCheckerDiagnostic);
|
|
511
518
|
}
|
|
512
519
|
}
|
|
513
520
|
function checkTypeReferenceArgs(node, mapper) {
|
|
@@ -665,6 +672,11 @@ export function createChecker(program) {
|
|
|
665
672
|
}
|
|
666
673
|
}
|
|
667
674
|
}
|
|
675
|
+
// Check for deprecations here, first on symbol, then on type.
|
|
676
|
+
const declarationNode = sym === null || sym === void 0 ? void 0 : sym.declarations[0];
|
|
677
|
+
if (declarationNode) {
|
|
678
|
+
checkDeprecated(baseType, declarationNode, node);
|
|
679
|
+
}
|
|
668
680
|
return baseType;
|
|
669
681
|
}
|
|
670
682
|
/**
|
|
@@ -1701,7 +1713,6 @@ export function createChecker(program) {
|
|
|
1701
1713
|
const isBase = checkModelIs(node, node.is, mapper);
|
|
1702
1714
|
if (isBase) {
|
|
1703
1715
|
type.sourceModel = isBase;
|
|
1704
|
-
checkDeprecated(isBase, node.is);
|
|
1705
1716
|
// copy decorators
|
|
1706
1717
|
decorators.push(...isBase.decorators);
|
|
1707
1718
|
if (isBase.indexer) {
|
|
@@ -1725,7 +1736,7 @@ export function createChecker(program) {
|
|
|
1725
1736
|
else if (node.extends) {
|
|
1726
1737
|
type.baseModel = checkClassHeritage(node, node.extends, mapper);
|
|
1727
1738
|
if (type.baseModel) {
|
|
1728
|
-
|
|
1739
|
+
copyDeprecation(type.baseModel, type);
|
|
1729
1740
|
}
|
|
1730
1741
|
}
|
|
1731
1742
|
if (type.baseModel) {
|
|
@@ -2448,7 +2459,7 @@ export function createChecker(program) {
|
|
|
2448
2459
|
if (node.extends) {
|
|
2449
2460
|
type.baseScalar = checkScalarExtends(node, node.extends, mapper);
|
|
2450
2461
|
if (type.baseScalar) {
|
|
2451
|
-
|
|
2462
|
+
copyDeprecation(type.baseScalar, type);
|
|
2452
2463
|
type.baseScalar.derivedScalars.push(type);
|
|
2453
2464
|
}
|
|
2454
2465
|
}
|
|
@@ -2598,6 +2609,8 @@ export function createChecker(program) {
|
|
|
2598
2609
|
if (!ownMembers.has(member.name)) {
|
|
2599
2610
|
linkIndirectMember(node, newMember, mapper);
|
|
2600
2611
|
}
|
|
2612
|
+
// Clone deprecation information
|
|
2613
|
+
copyDeprecation(member, newMember);
|
|
2601
2614
|
interfaceType.operations.set(newMember.name, newMember);
|
|
2602
2615
|
}
|
|
2603
2616
|
interfaceType.sourceInterfaces.push(extendsType);
|
|
@@ -2773,6 +2786,29 @@ export function createChecker(program) {
|
|
|
2773
2786
|
}
|
|
2774
2787
|
return members;
|
|
2775
2788
|
}
|
|
2789
|
+
function checkDirectives(node, type) {
|
|
2790
|
+
var _a;
|
|
2791
|
+
let hasDeprecation = false;
|
|
2792
|
+
((_a = node.directives) !== null && _a !== void 0 ? _a : []).forEach((directive) => {
|
|
2793
|
+
if (directive.target.sv === "deprecated") {
|
|
2794
|
+
if (directive.arguments[0].kind !== SyntaxKind.StringLiteral) {
|
|
2795
|
+
reportCheckerDiagnostic(createDiagnostic({
|
|
2796
|
+
code: "invalid-deprecation-argument",
|
|
2797
|
+
target: directive.arguments[0],
|
|
2798
|
+
}));
|
|
2799
|
+
}
|
|
2800
|
+
if (hasDeprecation === true) {
|
|
2801
|
+
reportCheckerDiagnostic(createDiagnostic({ code: "duplicate-deprecation", target: node }));
|
|
2802
|
+
}
|
|
2803
|
+
else {
|
|
2804
|
+
hasDeprecation = true;
|
|
2805
|
+
markDeprecated(program, type, {
|
|
2806
|
+
message: directive.arguments[0].value,
|
|
2807
|
+
});
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
});
|
|
2811
|
+
}
|
|
2776
2812
|
// the types here aren't ideal and could probably be refactored.
|
|
2777
2813
|
function createAndFinishType(typeDef) {
|
|
2778
2814
|
createType(typeDef);
|
|
@@ -2786,7 +2822,13 @@ export function createChecker(program) {
|
|
|
2786
2822
|
function createType(typeDef) {
|
|
2787
2823
|
Object.setPrototypeOf(typeDef, typePrototype);
|
|
2788
2824
|
typeDef.isFinished = false;
|
|
2789
|
-
|
|
2825
|
+
// If the type has an associated syntax node, check any directives that
|
|
2826
|
+
// might be attached.
|
|
2827
|
+
const createdType = typeDef;
|
|
2828
|
+
if (createdType.node) {
|
|
2829
|
+
checkDirectives(createdType.node, createdType);
|
|
2830
|
+
}
|
|
2831
|
+
return createdType;
|
|
2790
2832
|
}
|
|
2791
2833
|
function finishType(typeDef) {
|
|
2792
2834
|
return finishTypeForProgramAndChecker(program, typePrototype, typeDef);
|
|
@@ -4250,8 +4292,44 @@ function finishTypeForProgramAndChecker(program, typePrototype, typeDef) {
|
|
|
4250
4292
|
typeDef.isFinished = true;
|
|
4251
4293
|
return typeDef;
|
|
4252
4294
|
}
|
|
4295
|
+
function isTemplateParameterOfParent(identifier, startNode) {
|
|
4296
|
+
for (let current = startNode; current; current = current.parent) {
|
|
4297
|
+
if (isTemplatedNode(current)) {
|
|
4298
|
+
for (const param of current.templateParameters) {
|
|
4299
|
+
// If the identifiers are the same symbol, we're looking at a template
|
|
4300
|
+
// parameter of a templated type
|
|
4301
|
+
if (param.id.symbol === identifier.symbol) {
|
|
4302
|
+
return true;
|
|
4303
|
+
}
|
|
4304
|
+
}
|
|
4305
|
+
}
|
|
4306
|
+
}
|
|
4307
|
+
return false;
|
|
4308
|
+
}
|
|
4309
|
+
function reportDeprecation(program, target, message, reportFunc) {
|
|
4310
|
+
// Check if the deprecation is being reported on a template parameter inside
|
|
4311
|
+
// of a templated type so that deprecated types don't raise un-suppressable
|
|
4312
|
+
// diagnostics in library abstractions
|
|
4313
|
+
const typeReference = target.kind === SyntaxKind.TypeReference ? target : undefined;
|
|
4314
|
+
if (typeReference && typeReference.target.kind === SyntaxKind.Identifier) {
|
|
4315
|
+
if (isTemplateParameterOfParent(typeReference.target, typeReference)) {
|
|
4316
|
+
// Don't report diagnostics when deprecated types are referenced by
|
|
4317
|
+
// template parameters
|
|
4318
|
+
return;
|
|
4319
|
+
}
|
|
4320
|
+
}
|
|
4321
|
+
if (program.compilerOptions.ignoreDeprecated !== true) {
|
|
4322
|
+
reportFunc(createDiagnostic({
|
|
4323
|
+
code: "deprecated",
|
|
4324
|
+
format: {
|
|
4325
|
+
message,
|
|
4326
|
+
},
|
|
4327
|
+
target,
|
|
4328
|
+
}));
|
|
4329
|
+
}
|
|
4330
|
+
}
|
|
4253
4331
|
function applyDecoratorToType(program, decApp, target) {
|
|
4254
|
-
var _a;
|
|
4332
|
+
var _a, _b;
|
|
4255
4333
|
compilerAssert("decorators" in target, "Cannot apply decorator to non-decoratable type", target);
|
|
4256
4334
|
for (const arg of decApp.args) {
|
|
4257
4335
|
if (isErrorType(arg.value)) {
|
|
@@ -4259,6 +4337,13 @@ function applyDecoratorToType(program, decApp, target) {
|
|
|
4259
4337
|
return;
|
|
4260
4338
|
}
|
|
4261
4339
|
}
|
|
4340
|
+
// Is the decorator definition deprecated?
|
|
4341
|
+
if (decApp.definition) {
|
|
4342
|
+
const deprecation = getDeprecationDetails(program, decApp.definition);
|
|
4343
|
+
if (deprecation !== undefined) {
|
|
4344
|
+
reportDeprecation(program, (_a = decApp.node) !== null && _a !== void 0 ? _a : target, deprecation.message, program.reportDiagnostic);
|
|
4345
|
+
}
|
|
4346
|
+
}
|
|
4262
4347
|
// peel `fn` off to avoid setting `this`.
|
|
4263
4348
|
try {
|
|
4264
4349
|
const args = decApp.args.map((x) => x.jsValue);
|
|
@@ -4272,7 +4357,7 @@ function applyDecoratorToType(program, decApp, target) {
|
|
|
4272
4357
|
program.reportDiagnostic(createDiagnostic({
|
|
4273
4358
|
code: "decorator-fail",
|
|
4274
4359
|
format: { decoratorName: decApp.decorator.name, error: error.stack },
|
|
4275
|
-
target: (
|
|
4360
|
+
target: (_b = decApp.node) !== null && _b !== void 0 ? _b : target,
|
|
4276
4361
|
}));
|
|
4277
4362
|
}
|
|
4278
4363
|
else {
|