@typespec/compiler 1.1.0-dev.2 → 1.1.0-dev.21
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 +6 -0
- package/dist/src/core/checker.d.ts.map +1 -1
- package/dist/src/core/checker.js +32 -12
- package/dist/src/core/checker.js.map +1 -1
- package/dist/src/core/cli/actions/compile/args.d.ts +2 -0
- package/dist/src/core/cli/actions/compile/args.d.ts.map +1 -1
- package/dist/src/core/cli/actions/compile/args.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 +54 -0
- package/dist/src/core/cli/actions/compile/compile.js.map +1 -1
- package/dist/src/core/cli/cli.js +5 -0
- package/dist/src/core/cli/cli.js.map +1 -1
- package/dist/src/core/helpers/type-name-utils.d.ts +1 -0
- package/dist/src/core/helpers/type-name-utils.d.ts.map +1 -1
- package/dist/src/core/helpers/type-name-utils.js +13 -5
- package/dist/src/core/helpers/type-name-utils.js.map +1 -1
- package/dist/src/core/inspector/node.js +2 -2
- package/dist/src/core/inspector/node.js.map +1 -1
- package/dist/src/core/linter.d.ts +11 -1
- package/dist/src/core/linter.d.ts.map +1 -1
- package/dist/src/core/linter.js +17 -2
- package/dist/src/core/linter.js.map +1 -1
- package/dist/src/core/logger/console-sink.d.ts.map +1 -1
- package/dist/src/core/logger/console-sink.js +2 -3
- package/dist/src/core/logger/console-sink.js.map +1 -1
- package/dist/src/core/name-resolver.js +1 -1
- package/dist/src/core/name-resolver.js.map +1 -1
- package/dist/src/core/program.d.ts.map +1 -1
- package/dist/src/core/program.js +40 -8
- package/dist/src/core/program.js.map +1 -1
- package/dist/src/core/stats.d.ts +39 -0
- package/dist/src/core/stats.d.ts.map +1 -0
- package/dist/src/core/stats.js +19 -0
- package/dist/src/core/stats.js.map +1 -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.js +3 -0
- package/dist/src/experimental/mutators.js.map +1 -1
- package/dist/src/init/init-template.d.ts +6 -0
- package/dist/src/init/init-template.d.ts.map +1 -1
- package/dist/src/init/init-template.js +1 -0
- package/dist/src/init/init-template.js.map +1 -1
- package/dist/src/init/scaffold.js +11 -10
- package/dist/src/init/scaffold.js.map +1 -1
- package/dist/src/internals/index.d.ts +1 -0
- package/dist/src/internals/index.d.ts.map +1 -1
- package/dist/src/lib/paging.js +10 -4
- package/dist/src/lib/paging.js.map +1 -1
- package/dist/src/lib/visibility.js +17 -27
- package/dist/src/lib/visibility.js.map +1 -1
- package/dist/src/server/compile-service.d.ts +5 -1
- package/dist/src/server/compile-service.d.ts.map +1 -1
- package/dist/src/server/compile-service.js +16 -3
- package/dist/src/server/compile-service.js.map +1 -1
- package/dist/src/server/index.d.ts +1 -1
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/server/server-track-action-task.d.ts +18 -0
- package/dist/src/server/server-track-action-task.d.ts.map +1 -0
- package/dist/src/server/server-track-action-task.js +70 -0
- package/dist/src/server/server-track-action-task.js.map +1 -0
- package/dist/src/server/server.js +2 -0
- package/dist/src/server/server.js.map +1 -1
- package/dist/src/server/serverlib.d.ts.map +1 -1
- package/dist/src/server/serverlib.js +90 -8
- package/dist/src/server/serverlib.js.map +1 -1
- package/dist/src/server/type-details.js +7 -0
- package/dist/src/server/type-details.js.map +1 -1
- package/dist/src/server/type-signature.js +47 -14
- package/dist/src/server/type-signature.js.map +1 -1
- package/dist/src/server/types.d.ts +21 -2
- package/dist/src/server/types.d.ts.map +1 -1
- package/dist/src/server/types.js.map +1 -1
- package/dist/src/typekit/kits/type.js +6 -0
- package/dist/src/typekit/kits/type.js.map +1 -1
- package/package.json +2 -2
- package/templates/__snapshots__/rest/package.json +3 -10
- package/templates/scaffolding.json +2 -0
package/dist/manifest.js
CHANGED
|
@@ -49,6 +49,12 @@ export interface Checker {
|
|
|
49
49
|
*/
|
|
50
50
|
getValueExactType(value: Value): Type | undefined;
|
|
51
51
|
}
|
|
52
|
+
export interface CheckerStats {
|
|
53
|
+
/** Number of types created */
|
|
54
|
+
createdTypes: number;
|
|
55
|
+
/** Number of types finished */
|
|
56
|
+
finishedTypes: number;
|
|
57
|
+
}
|
|
52
58
|
interface TypePrototype {
|
|
53
59
|
}
|
|
54
60
|
export interface TypeSpecCompletionItem {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../../../src/core/checker.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AASlD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAY5C,OAAO,EAML,cAAc,EACd,kBAAkB,EA+BlB,mBAAmB,EAWnB,KAAK,EAGL,aAAa,EAOb,IAAI,EAGJ,cAAc,EACd,kBAAkB,EASlB,MAAM,EAMN,WAAW,EACX,QAAQ,EACR,aAAa,EACb,iBAAiB,EAUjB,GAAG,
|
|
1
|
+
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../../../src/core/checker.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AASlD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAY5C,OAAO,EAML,cAAc,EACd,kBAAkB,EA+BlB,mBAAmB,EAWnB,KAAK,EAGL,aAAa,EAOb,IAAI,EAGJ,cAAc,EACd,kBAAkB,EASlB,MAAM,EAMN,WAAW,EACX,QAAQ,EACR,aAAa,EACb,iBAAiB,EAUjB,GAAG,EAcH,IAAI,EAaJ,KAAK,EAGN,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,GAAG,MAAM,aAAa,CAAC,CAAC;AAE5F,MAAM,WAAW,OAAO;IAGtB;;;OAGG;IACH,cA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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;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
|
@@ -25,6 +25,10 @@ import { IdentifierKind, ResolutionResultFlags, SyntaxKind, } from "./types.js";
|
|
|
25
25
|
const TypeInstantiationMap = class extends MultiKeyMap {
|
|
26
26
|
};
|
|
27
27
|
export function createChecker(program, resolver) {
|
|
28
|
+
const stats = {
|
|
29
|
+
createdTypes: 0,
|
|
30
|
+
finishedTypes: 0,
|
|
31
|
+
};
|
|
28
32
|
const stdTypes = {};
|
|
29
33
|
const indeterminateEntities = new WeakMap();
|
|
30
34
|
const docFromCommentForSym = new Map();
|
|
@@ -83,6 +87,7 @@ export function createChecker(program, resolver) {
|
|
|
83
87
|
getValueExactType,
|
|
84
88
|
getTemplateParameterUsageMap,
|
|
85
89
|
isTypeAssignableTo: undefined,
|
|
90
|
+
stats,
|
|
86
91
|
};
|
|
87
92
|
const relation = createTypeRelationChecker(program, checker);
|
|
88
93
|
checker.isTypeAssignableTo = relation.isTypeAssignableTo;
|
|
@@ -233,7 +238,7 @@ export function createChecker(program, resolver) {
|
|
|
233
238
|
}
|
|
234
239
|
return entity;
|
|
235
240
|
}
|
|
236
|
-
function getValueForNode(node, mapper, constraint
|
|
241
|
+
function getValueForNode(node, mapper, constraint) {
|
|
237
242
|
const initial = checkNode(node, mapper, constraint);
|
|
238
243
|
if (initial === null) {
|
|
239
244
|
return null;
|
|
@@ -245,15 +250,23 @@ export function createChecker(program, resolver) {
|
|
|
245
250
|
else {
|
|
246
251
|
entity = initial;
|
|
247
252
|
}
|
|
248
|
-
// if (options.legacyTupleAndModelCast && entity !== null && isType(entity)) {
|
|
249
|
-
// entity = legacy_tryTypeToValueCast(entity, constraint, node);
|
|
250
|
-
// }
|
|
251
253
|
if (entity === null) {
|
|
252
254
|
return null;
|
|
253
255
|
}
|
|
254
256
|
if (isValue(entity)) {
|
|
255
257
|
return constraint ? inferScalarsFromConstraints(entity, constraint.type) : entity;
|
|
256
258
|
}
|
|
259
|
+
// If a template parameter that can be a value is used in a template declaration then we allow it but we return null because we don't have an actual value.
|
|
260
|
+
if (entity.kind === "TemplateParameter" &&
|
|
261
|
+
entity.constraint?.valueType &&
|
|
262
|
+
entity.constraint.type === undefined &&
|
|
263
|
+
mapper === undefined) {
|
|
264
|
+
return createValue({
|
|
265
|
+
entityKind: "Value",
|
|
266
|
+
valueKind: "TemplateValue",
|
|
267
|
+
type: entity.constraint.valueType,
|
|
268
|
+
}, entity.constraint.valueType);
|
|
269
|
+
}
|
|
257
270
|
reportExpectedValue(node, entity);
|
|
258
271
|
return null;
|
|
259
272
|
}
|
|
@@ -2308,7 +2321,7 @@ export function createChecker(program, resolver) {
|
|
|
2308
2321
|
const spanValue = createTemplateSpanValue(span.expression, type);
|
|
2309
2322
|
spans.push(spanValue);
|
|
2310
2323
|
const spanValueAsString = stringifyTypeForTemplate(type);
|
|
2311
|
-
if (spanValueAsString) {
|
|
2324
|
+
if (spanValueAsString !== undefined) {
|
|
2312
2325
|
stringValue += spanValueAsString;
|
|
2313
2326
|
}
|
|
2314
2327
|
else {
|
|
@@ -3232,7 +3245,8 @@ export function createChecker(program, resolver) {
|
|
|
3232
3245
|
}));
|
|
3233
3246
|
return undefined;
|
|
3234
3247
|
}
|
|
3235
|
-
if (heritageRef.kind !== SyntaxKind.TypeReference
|
|
3248
|
+
if (heritageRef.kind !== SyntaxKind.TypeReference &&
|
|
3249
|
+
heritageRef.kind !== SyntaxKind.ArrayExpression) {
|
|
3236
3250
|
reportCheckerDiagnostic(createDiagnostic({
|
|
3237
3251
|
code: "extend-model",
|
|
3238
3252
|
target: heritageRef,
|
|
@@ -3396,7 +3410,7 @@ export function createChecker(program, resolver) {
|
|
|
3396
3410
|
pendingResolutions.start(sym, ResolutionKind.Type);
|
|
3397
3411
|
type.type = getTypeForNode(prop.value, mapper);
|
|
3398
3412
|
if (prop.default) {
|
|
3399
|
-
const defaultValue = checkDefaultValue(prop.default, type.type);
|
|
3413
|
+
const defaultValue = checkDefaultValue(prop.default, type.type, mapper);
|
|
3400
3414
|
if (defaultValue !== null) {
|
|
3401
3415
|
type.defaultValue = defaultValue;
|
|
3402
3416
|
}
|
|
@@ -3427,15 +3441,15 @@ export function createChecker(program, resolver) {
|
|
|
3427
3441
|
],
|
|
3428
3442
|
};
|
|
3429
3443
|
}
|
|
3430
|
-
function checkDefaultValue(defaultNode, type) {
|
|
3444
|
+
function checkDefaultValue(defaultNode, type, mapper) {
|
|
3431
3445
|
if (isErrorType(type)) {
|
|
3432
3446
|
// if the prop type is an error we don't need to validate again.
|
|
3433
3447
|
return null;
|
|
3434
3448
|
}
|
|
3435
|
-
const defaultValue = getValueForNode(defaultNode,
|
|
3449
|
+
const defaultValue = getValueForNode(defaultNode, mapper, {
|
|
3436
3450
|
kind: "assignment",
|
|
3437
3451
|
type,
|
|
3438
|
-
}
|
|
3452
|
+
});
|
|
3439
3453
|
if (defaultValue === null) {
|
|
3440
3454
|
return null;
|
|
3441
3455
|
}
|
|
@@ -3444,6 +3458,11 @@ export function createChecker(program, resolver) {
|
|
|
3444
3458
|
reportCheckerDiagnostics(diagnostics);
|
|
3445
3459
|
return null;
|
|
3446
3460
|
}
|
|
3461
|
+
else if (defaultValue.valueKind === "TemplateValue") {
|
|
3462
|
+
// Right now we don't want to expose `TemplateValue` in the type graph.
|
|
3463
|
+
// And as interating with the template declaration is not a supported feature we can just drop it.
|
|
3464
|
+
return null;
|
|
3465
|
+
}
|
|
3447
3466
|
else {
|
|
3448
3467
|
return { ...defaultValue, type };
|
|
3449
3468
|
}
|
|
@@ -4253,6 +4272,7 @@ export function createChecker(program, resolver) {
|
|
|
4253
4272
|
* Given the own-properties of a type, returns a fully-initialized type.
|
|
4254
4273
|
*/
|
|
4255
4274
|
function createType(typeDef) {
|
|
4275
|
+
stats.createdTypes++;
|
|
4256
4276
|
Object.setPrototypeOf(typeDef, typePrototype);
|
|
4257
4277
|
typeDef.isFinished = false;
|
|
4258
4278
|
// If the type has an associated syntax node, check any directives that
|
|
@@ -4265,6 +4285,7 @@ export function createChecker(program, resolver) {
|
|
|
4265
4285
|
return createdType;
|
|
4266
4286
|
}
|
|
4267
4287
|
function finishType(typeDef) {
|
|
4288
|
+
stats.finishedTypes++;
|
|
4268
4289
|
return finishTypeForProgramAndChecker(program, typePrototype, typeDef);
|
|
4269
4290
|
}
|
|
4270
4291
|
function getLiteralType(node) {
|
|
@@ -4735,9 +4756,8 @@ export function finishTypeForProgram(program, typeDef) {
|
|
|
4735
4756
|
}
|
|
4736
4757
|
function linkMapper(typeDef, mapper) {
|
|
4737
4758
|
if (mapper) {
|
|
4738
|
-
compilerAssert(!typeDef.
|
|
4759
|
+
compilerAssert(!typeDef.templateMapper, "Mapper provided but template arguments already set.");
|
|
4739
4760
|
typeDef.templateMapper = mapper;
|
|
4740
|
-
typeDef.templateArguments = mapper.args;
|
|
4741
4761
|
}
|
|
4742
4762
|
}
|
|
4743
4763
|
function extractMainDoc(type) {
|