@typespec/compiler 1.14.0-dev.8 → 1.14.0
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/auto-decorator.d.ts +12 -0
- package/dist/src/core/auto-decorator.d.ts.map +1 -1
- package/dist/src/core/auto-decorator.js +16 -2
- package/dist/src/core/auto-decorator.js.map +1 -1
- package/dist/src/core/checker.d.ts.map +1 -1
- package/dist/src/core/checker.js +30 -22
- package/dist/src/core/checker.js.map +1 -1
- package/dist/src/core/cli/actions/vs.d.ts.map +1 -1
- package/dist/src/core/cli/actions/vs.js +21 -10
- package/dist/src/core/cli/actions/vs.js.map +1 -1
- package/dist/src/core/cli/actions/vscode.d.ts.map +1 -1
- package/dist/src/core/cli/actions/vscode.js +9 -4
- package/dist/src/core/cli/actions/vscode.js.map +1 -1
- package/dist/src/core/cli/cli.js +4 -4
- package/dist/src/core/cli/cli.js.map +1 -1
- package/dist/src/core/cli/download-vsix.d.ts +19 -0
- package/dist/src/core/cli/download-vsix.d.ts.map +1 -0
- package/dist/src/core/cli/download-vsix.js +76 -0
- package/dist/src/core/cli/download-vsix.js.map +1 -0
- package/dist/src/core/cli/utils.d.ts +7 -0
- package/dist/src/core/cli/utils.d.ts.map +1 -1
- package/dist/src/core/cli/utils.js +16 -0
- package/dist/src/core/cli/utils.js.map +1 -1
- package/dist/src/core/diagnostics.d.ts +3 -3
- package/dist/src/core/diagnostics.d.ts.map +1 -1
- package/dist/src/core/diagnostics.js +34 -3
- package/dist/src/core/diagnostics.js.map +1 -1
- package/dist/src/core/entrypoint-resolution.d.ts.map +1 -1
- package/dist/src/core/entrypoint-resolution.js +5 -4
- package/dist/src/core/entrypoint-resolution.js.map +1 -1
- package/dist/src/core/features.d.ts.map +1 -1
- package/dist/src/core/features.js +15 -5
- package/dist/src/core/features.js.map +1 -1
- package/dist/src/core/messages.d.ts +56 -2
- package/dist/src/core/messages.d.ts.map +1 -1
- package/dist/src/core/messages.js +18 -0
- package/dist/src/core/messages.js.map +1 -1
- package/dist/src/core/program.d.ts.map +1 -1
- package/dist/src/core/program.js +6 -1
- package/dist/src/core/program.js.map +1 -1
- package/dist/src/core/source-loader.d.ts.map +1 -1
- package/dist/src/core/source-loader.js +23 -0
- package/dist/src/core/source-loader.js.map +1 -1
- package/dist/src/core/suppression-tracking.d.ts +4 -0
- package/dist/src/core/suppression-tracking.d.ts.map +1 -1
- package/dist/src/core/suppression-tracking.js +25 -0
- package/dist/src/core/suppression-tracking.js.map +1 -1
- package/dist/src/core/types.d.ts +6 -0
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/types.js.map +1 -1
- package/dist/src/experimental/mutators.d.ts.map +1 -1
- package/dist/src/experimental/mutators.js +32 -8
- package/dist/src/experimental/mutators.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/testing/code-fix-testing.d.ts.map +1 -1
- package/dist/src/testing/code-fix-testing.js +2 -0
- package/dist/src/testing/code-fix-testing.js.map +1 -1
- package/dist/src/testing/fs.js +1 -0
- package/dist/src/testing/fs.js.map +1 -1
- package/dist/src/testing/index.d.ts +2 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +3 -0
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/testing/rule-tester.d.ts.map +1 -1
- package/dist/src/testing/rule-tester.js +4 -1
- package/dist/src/testing/rule-tester.js.map +1 -1
- package/dist/src/testing/test-compiler-host.d.ts.map +1 -1
- package/dist/src/testing/test-compiler-host.js +5 -0
- package/dist/src/testing/test-compiler-host.js.map +1 -1
- package/dist/src/testing/test-host.d.ts +2 -2
- package/dist/src/testing/test-host.d.ts.map +1 -1
- package/dist/src/testing/test-host.js +4 -2
- package/dist/src/testing/test-host.js.map +1 -1
- package/dist/src/testing/test-utils.d.ts +6 -1
- package/dist/src/testing/test-utils.d.ts.map +1 -1
- package/dist/src/testing/test-utils.js +8 -1
- package/dist/src/testing/test-utils.js.map +1 -1
- package/dist/src/testing/tester.d.ts.map +1 -1
- package/dist/src/testing/tester.js +10 -0
- package/dist/src/testing/tester.js.map +1 -1
- package/dist/src/testing/types.d.ts +7 -0
- package/dist/src/testing/types.d.ts.map +1 -1
- package/dist/src/testing/types.js +2 -0
- package/dist/src/testing/types.js.map +1 -1
- package/package.json +6 -6
- package/templates/scaffolding.json +3 -11
- package/dist/src/core/cli/install-vsix.d.ts +0 -3
- package/dist/src/core/cli/install-vsix.d.ts.map +0 -1
- package/dist/src/core/cli/install-vsix.js +0 -41
- package/dist/src/core/cli/install-vsix.js.map +0 -1
- package/templates/__snapshots__/emitter-ts/src/testing/index.ts +0 -8
- package/templates/__snapshots__/library-ts/src/testing/index.ts +0 -8
- package/templates/emitter-ts/src/testing/index.ts.mu +0 -8
- package/templates/library-ts/src/testing/index.ts.mu +0 -8
package/dist/manifest.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import type { Program } from "./program.js";
|
|
2
2
|
import type { Type } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Programmatically apply an auto decorator to a target, storing its argument values.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors what the synthesized `auto dec` implementation does when the decorator is
|
|
7
|
+
* written in source, so emitters and mutators can mark synthetic types the same way
|
|
8
|
+
* without reaching into the program state map directly.
|
|
9
|
+
* @param program - The current program.
|
|
10
|
+
* @param decoratorFqn - The fully-qualified name of the decorator (e.g., "MyLib.myDec").
|
|
11
|
+
* @param target - The type to mark.
|
|
12
|
+
* @param value - The stored `{ paramName: value }` record (defaults to `{}` for a no-arg decorator).
|
|
13
|
+
*/
|
|
14
|
+
export declare function setAutoDecorator(program: Program, decoratorFqn: string, target: Type, value?: Record<string, unknown>): void;
|
|
3
15
|
/**
|
|
4
16
|
* Check if an auto decorator has been applied to a target.
|
|
5
17
|
* @param program - The current program.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-decorator.d.ts","sourceRoot":"","sources":["../../../src/core/auto-decorator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAA4D,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"auto-decorator.d.ts","sourceRoot":"","sources":["../../../src/core/auto-decorator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAA4D,IAAI,EAAE,MAAM,YAAY,CAAC;AAwDjG;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,IAAI,EACZ,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAClC,IAAI,CAGN;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAG,OAAO,CAG9F;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,IAAI,GACX,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAGrC;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,GACnB,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAGpB"}
|
|
@@ -21,7 +21,6 @@ export function getAutoDecoratorStateKey(decoratorFqn) {
|
|
|
21
21
|
*/
|
|
22
22
|
export function createAutoDecoratorImplementation(symbol, node) {
|
|
23
23
|
const fqn = getFullyQualifiedSymbolName(symbol);
|
|
24
|
-
const stateKey = getAutoDecoratorStateKey(fqn);
|
|
25
24
|
const paramNames = node.parameters.map((p) => p.id.sv);
|
|
26
25
|
const lastParamIsRest = node.parameters.length > 0 && node.parameters[node.parameters.length - 1].rest;
|
|
27
26
|
const impl = (context, target, ...args) => {
|
|
@@ -43,13 +42,28 @@ export function createAutoDecoratorImplementation(symbol, node) {
|
|
|
43
42
|
data[paramNames[i]] = args[i];
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
|
-
context.program
|
|
45
|
+
setAutoDecorator(context.program, fqn, target, data);
|
|
47
46
|
};
|
|
48
47
|
// The function name drives the `@<name>` text in the duplicate-decorator
|
|
49
48
|
// diagnostic; mirror the extern `$name` convention so the helper strips it.
|
|
50
49
|
Object.defineProperty(impl, "name", { value: `$${node.id.sv}` });
|
|
51
50
|
return impl;
|
|
52
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Programmatically apply an auto decorator to a target, storing its argument values.
|
|
54
|
+
*
|
|
55
|
+
* Mirrors what the synthesized `auto dec` implementation does when the decorator is
|
|
56
|
+
* written in source, so emitters and mutators can mark synthetic types the same way
|
|
57
|
+
* without reaching into the program state map directly.
|
|
58
|
+
* @param program - The current program.
|
|
59
|
+
* @param decoratorFqn - The fully-qualified name of the decorator (e.g., "MyLib.myDec").
|
|
60
|
+
* @param target - The type to mark.
|
|
61
|
+
* @param value - The stored `{ paramName: value }` record (defaults to `{}` for a no-arg decorator).
|
|
62
|
+
*/
|
|
63
|
+
export function setAutoDecorator(program, decoratorFqn, target, value = {}) {
|
|
64
|
+
const key = getAutoDecoratorStateKey(decoratorFqn);
|
|
65
|
+
program.stateMap(key).set(target, value);
|
|
66
|
+
}
|
|
53
67
|
/**
|
|
54
68
|
* Check if an auto decorator has been applied to a target.
|
|
55
69
|
* @param program - The current program.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-decorator.js","sourceRoot":"","sources":["../../../src/core/auto-decorator.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,kCAAk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IAC3B,8BAA8B;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,aAAa;CAAG;AAE1B,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,GAAG,CAAC;IAET;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AASD,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAwsP/E;AAgED;;;;;;;;;;;;;;;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,EAChB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,OAAO,GAC3C,KAAK,CAqCP;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS,CAcxF;AAED;;;;;;;GAOG;AACH,wBAAiB,uBAAuB,CAAC,KAAK,EAAE,KAAK,2CAapD"}
|
package/dist/src/core/checker.js
CHANGED
|
@@ -3383,24 +3383,30 @@ export function createChecker(program, resolver) {
|
|
|
3383
3383
|
function checkStringTemplateExpresion(ctx, node) {
|
|
3384
3384
|
let hasType = false;
|
|
3385
3385
|
let hasValue = false;
|
|
3386
|
-
const spanTypeOrValues =
|
|
3386
|
+
const spanTypeOrValues = [];
|
|
3387
|
+
for (const span of node.spans) {
|
|
3388
|
+
const typeOrValue = checkNode(ctx, span.expression);
|
|
3389
|
+
// A null span is the value-world equivalent of `errorType`: the expression couldn't
|
|
3390
|
+
// produce a usable value (e.g. an already-reported error, or a function call that can't
|
|
3391
|
+
// be evaluated yet in a template declaration). Like `checkArrayValue`/`checkObjectValue`,
|
|
3392
|
+
// propagate the null up so the whole template resolves to null instead of fabricating a
|
|
3393
|
+
// partial string. It is re-evaluated against the real value when the template is instantiated.
|
|
3394
|
+
if (typeOrValue === null) {
|
|
3395
|
+
return null;
|
|
3396
|
+
}
|
|
3397
|
+
spanTypeOrValues.push([span, typeOrValue]);
|
|
3398
|
+
}
|
|
3387
3399
|
for (const [_, typeOrValue] of spanTypeOrValues) {
|
|
3388
|
-
if (typeOrValue
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
if (typeOrValue.constraint.valueType) {
|
|
3397
|
-
hasValue = true;
|
|
3398
|
-
}
|
|
3399
|
-
if (typeOrValue.constraint.type) {
|
|
3400
|
-
hasType = true;
|
|
3401
|
-
}
|
|
3400
|
+
if (isValue(typeOrValue)) {
|
|
3401
|
+
hasValue = true;
|
|
3402
|
+
}
|
|
3403
|
+
else if ("kind" in typeOrValue &&
|
|
3404
|
+
(typeOrValue.kind === "TemplateParameter" || typeOrValue.kind === "TemplateParameterAccess")) {
|
|
3405
|
+
if (typeOrValue.constraint) {
|
|
3406
|
+
if (typeOrValue.constraint.valueType) {
|
|
3407
|
+
hasValue = true;
|
|
3402
3408
|
}
|
|
3403
|
-
|
|
3409
|
+
if (typeOrValue.constraint.type) {
|
|
3404
3410
|
hasType = true;
|
|
3405
3411
|
}
|
|
3406
3412
|
}
|
|
@@ -3408,6 +3414,9 @@ export function createChecker(program, resolver) {
|
|
|
3408
3414
|
hasType = true;
|
|
3409
3415
|
}
|
|
3410
3416
|
}
|
|
3417
|
+
else {
|
|
3418
|
+
hasType = true;
|
|
3419
|
+
}
|
|
3411
3420
|
}
|
|
3412
3421
|
if (hasType && hasValue) {
|
|
3413
3422
|
reportCheckerDiagnostic(createDiagnostic({
|
|
@@ -3419,11 +3428,10 @@ export function createChecker(program, resolver) {
|
|
|
3419
3428
|
if (hasValue) {
|
|
3420
3429
|
let str = node.head.value;
|
|
3421
3430
|
for (const [span, typeOrValue] of spanTypeOrValues) {
|
|
3422
|
-
if (
|
|
3423
|
-
(
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
compilerAssert(typeOrValue !== null && isValue(typeOrValue), "Expected value.");
|
|
3431
|
+
if (!("kind" in typeOrValue) ||
|
|
3432
|
+
(typeOrValue.kind !== "TemplateParameter" &&
|
|
3433
|
+
typeOrValue.kind !== "TemplateParameterAccess")) {
|
|
3434
|
+
compilerAssert(isValue(typeOrValue), "Expected value.");
|
|
3427
3435
|
str += stringifyValueForTemplate(typeOrValue);
|
|
3428
3436
|
}
|
|
3429
3437
|
str += span.literal.value;
|
|
@@ -3435,7 +3443,7 @@ export function createChecker(program, resolver) {
|
|
|
3435
3443
|
let stringValue = node.head.value;
|
|
3436
3444
|
const spans = [createTemplateSpanLiteral(node.head)];
|
|
3437
3445
|
for (const [span, typeOrValue] of spanTypeOrValues) {
|
|
3438
|
-
compilerAssert(
|
|
3446
|
+
compilerAssert(!isValue(typeOrValue), "Expected type.");
|
|
3439
3447
|
const type = typeOrValue.entityKind === "Indeterminate" ? typeOrValue.type : typeOrValue;
|
|
3440
3448
|
const spanValue = createTemplateSpanValue(span.expression, type);
|
|
3441
3449
|
spans.push(spanValue);
|