@typespec/compiler 1.1.0-dev.2 → 1.1.0-dev.5
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 +21 -8
- package/dist/src/core/checker.js.map +1 -1
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/types.js.map +1 -1
- package/dist/src/lib/visibility.js +17 -27
- package/dist/src/lib/visibility.js.map +1 -1
- package/package.json +1 -1
package/dist/manifest.js
CHANGED
|
@@ -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,EAaH,IAAI,EAaJ,KAAK,
|
|
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,EAaH,IAAI,EAaJ,KAAK,EAGN,MAAM,YAAY,CAAC;AAEpB,MAAM,MA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,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;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
|
@@ -233,7 +233,7 @@ export function createChecker(program, resolver) {
|
|
|
233
233
|
}
|
|
234
234
|
return entity;
|
|
235
235
|
}
|
|
236
|
-
function getValueForNode(node, mapper, constraint
|
|
236
|
+
function getValueForNode(node, mapper, constraint) {
|
|
237
237
|
const initial = checkNode(node, mapper, constraint);
|
|
238
238
|
if (initial === null) {
|
|
239
239
|
return null;
|
|
@@ -245,15 +245,23 @@ export function createChecker(program, resolver) {
|
|
|
245
245
|
else {
|
|
246
246
|
entity = initial;
|
|
247
247
|
}
|
|
248
|
-
// if (options.legacyTupleAndModelCast && entity !== null && isType(entity)) {
|
|
249
|
-
// entity = legacy_tryTypeToValueCast(entity, constraint, node);
|
|
250
|
-
// }
|
|
251
248
|
if (entity === null) {
|
|
252
249
|
return null;
|
|
253
250
|
}
|
|
254
251
|
if (isValue(entity)) {
|
|
255
252
|
return constraint ? inferScalarsFromConstraints(entity, constraint.type) : entity;
|
|
256
253
|
}
|
|
254
|
+
// 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.
|
|
255
|
+
if (entity.kind === "TemplateParameter" &&
|
|
256
|
+
entity.constraint?.valueType &&
|
|
257
|
+
entity.constraint.type === undefined &&
|
|
258
|
+
mapper === undefined) {
|
|
259
|
+
return createValue({
|
|
260
|
+
entityKind: "Value",
|
|
261
|
+
valueKind: "TemplateValue",
|
|
262
|
+
type: entity.constraint.valueType,
|
|
263
|
+
}, entity.constraint.valueType);
|
|
264
|
+
}
|
|
257
265
|
reportExpectedValue(node, entity);
|
|
258
266
|
return null;
|
|
259
267
|
}
|
|
@@ -3396,7 +3404,7 @@ export function createChecker(program, resolver) {
|
|
|
3396
3404
|
pendingResolutions.start(sym, ResolutionKind.Type);
|
|
3397
3405
|
type.type = getTypeForNode(prop.value, mapper);
|
|
3398
3406
|
if (prop.default) {
|
|
3399
|
-
const defaultValue = checkDefaultValue(prop.default, type.type);
|
|
3407
|
+
const defaultValue = checkDefaultValue(prop.default, type.type, mapper);
|
|
3400
3408
|
if (defaultValue !== null) {
|
|
3401
3409
|
type.defaultValue = defaultValue;
|
|
3402
3410
|
}
|
|
@@ -3427,15 +3435,15 @@ export function createChecker(program, resolver) {
|
|
|
3427
3435
|
],
|
|
3428
3436
|
};
|
|
3429
3437
|
}
|
|
3430
|
-
function checkDefaultValue(defaultNode, type) {
|
|
3438
|
+
function checkDefaultValue(defaultNode, type, mapper) {
|
|
3431
3439
|
if (isErrorType(type)) {
|
|
3432
3440
|
// if the prop type is an error we don't need to validate again.
|
|
3433
3441
|
return null;
|
|
3434
3442
|
}
|
|
3435
|
-
const defaultValue = getValueForNode(defaultNode,
|
|
3443
|
+
const defaultValue = getValueForNode(defaultNode, mapper, {
|
|
3436
3444
|
kind: "assignment",
|
|
3437
3445
|
type,
|
|
3438
|
-
}
|
|
3446
|
+
});
|
|
3439
3447
|
if (defaultValue === null) {
|
|
3440
3448
|
return null;
|
|
3441
3449
|
}
|
|
@@ -3444,6 +3452,11 @@ export function createChecker(program, resolver) {
|
|
|
3444
3452
|
reportCheckerDiagnostics(diagnostics);
|
|
3445
3453
|
return null;
|
|
3446
3454
|
}
|
|
3455
|
+
else if (defaultValue.valueKind === "TemplateValue") {
|
|
3456
|
+
// Right now we don't want to expose `TemplateValue` in the type graph.
|
|
3457
|
+
// And as interating with the template declaration is not a supported feature we can just drop it.
|
|
3458
|
+
return null;
|
|
3459
|
+
}
|
|
3447
3460
|
else {
|
|
3448
3461
|
return { ...defaultValue, type };
|
|
3449
3462
|
}
|