@typespec/compiler 0.57.0-dev.0 → 0.57.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/generated-defs/TypeSpec.d.ts +9 -9
- package/dist/generated-defs/TypeSpec.d.ts.map +1 -1
- package/dist/manifest.js +2 -2
- package/dist/src/config/types.d.ts +2 -2
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/core/binder.d.ts +1 -1
- package/dist/src/core/binder.d.ts.map +1 -1
- package/dist/src/core/binder.js +16 -3
- package/dist/src/core/binder.js.map +1 -1
- package/dist/src/core/checker.d.ts +11 -9
- package/dist/src/core/checker.d.ts.map +1 -1
- package/dist/src/core/checker.js +1577 -241
- package/dist/src/core/checker.js.map +1 -1
- package/dist/src/core/compiler-code-fixes/model-to-object-literal.codefix.d.ts +6 -0
- package/dist/src/core/compiler-code-fixes/model-to-object-literal.codefix.d.ts.map +1 -0
- package/dist/src/core/compiler-code-fixes/model-to-object-literal.codefix.js +15 -0
- package/dist/src/core/compiler-code-fixes/model-to-object-literal.codefix.js.map +1 -0
- package/dist/src/core/compiler-code-fixes/tuple-to-array-value.codefix.d.ts +6 -0
- package/dist/src/core/compiler-code-fixes/tuple-to-array-value.codefix.d.ts.map +1 -0
- package/dist/src/core/compiler-code-fixes/tuple-to-array-value.codefix.js +15 -0
- package/dist/src/core/compiler-code-fixes/tuple-to-array-value.codefix.js.map +1 -0
- package/dist/src/core/decorator-utils.d.ts +5 -1
- package/dist/src/core/decorator-utils.d.ts.map +1 -1
- package/dist/src/core/decorator-utils.js +11 -1
- package/dist/src/core/decorator-utils.js.map +1 -1
- package/dist/src/core/deprecation.d.ts +1 -1
- package/dist/src/core/deprecation.d.ts.map +1 -1
- package/dist/src/core/diagnostic-creator.d.ts.map +1 -1
- package/dist/src/core/diagnostic-creator.js +1 -2
- package/dist/src/core/diagnostic-creator.js.map +1 -1
- package/dist/src/core/diagnostics.js +3 -3
- package/dist/src/core/diagnostics.js.map +1 -1
- package/dist/src/core/emitter-utils.d.ts +1 -1
- package/dist/src/core/emitter-utils.d.ts.map +1 -1
- package/dist/src/core/helpers/discriminator-utils.d.ts +2 -2
- package/dist/src/core/helpers/discriminator-utils.d.ts.map +1 -1
- package/dist/src/core/helpers/discriminator-utils.js +1 -1
- package/dist/src/core/helpers/discriminator-utils.js.map +1 -1
- package/dist/src/core/helpers/index.d.ts +1 -1
- package/dist/src/core/helpers/index.d.ts.map +1 -1
- package/dist/src/core/helpers/index.js +3 -1
- package/dist/src/core/helpers/index.js.map +1 -1
- package/dist/src/core/helpers/location-context.d.ts +2 -2
- package/dist/src/core/helpers/location-context.d.ts.map +1 -1
- package/dist/src/core/helpers/projected-names-utils.d.ts +2 -2
- package/dist/src/core/helpers/projected-names-utils.d.ts.map +1 -1
- package/dist/src/core/helpers/projected-names-utils.js.map +1 -1
- package/dist/src/core/helpers/string-template-utils.d.ts +6 -6
- package/dist/src/core/helpers/string-template-utils.d.ts.map +1 -1
- package/dist/src/core/helpers/string-template-utils.js +20 -33
- package/dist/src/core/helpers/string-template-utils.js.map +1 -1
- package/dist/src/core/helpers/type-name-utils.d.ts +3 -2
- package/dist/src/core/helpers/type-name-utils.d.ts.map +1 -1
- package/dist/src/core/helpers/type-name-utils.js +57 -8
- package/dist/src/core/helpers/type-name-utils.js.map +1 -1
- package/dist/src/core/index.d.ts +4 -1
- package/dist/src/core/index.d.ts.map +1 -1
- package/dist/src/core/index.js +4 -1
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/core/intrinsic-type-state.d.ts +63 -0
- package/dist/src/core/intrinsic-type-state.d.ts.map +1 -0
- package/dist/src/core/intrinsic-type-state.js +160 -0
- package/dist/src/core/intrinsic-type-state.js.map +1 -0
- package/dist/src/core/js-marshaller.d.ts +13 -0
- package/dist/src/core/js-marshaller.d.ts.map +1 -0
- package/dist/src/core/js-marshaller.js +79 -0
- package/dist/src/core/js-marshaller.js.map +1 -0
- package/dist/src/core/library.d.ts +2 -1
- package/dist/src/core/library.d.ts.map +1 -1
- package/dist/src/core/library.js +3 -0
- package/dist/src/core/library.js.map +1 -1
- package/dist/src/core/linter.d.ts +1 -1
- package/dist/src/core/linter.d.ts.map +1 -1
- package/dist/src/core/linter.js +1 -1
- package/dist/src/core/linter.js.map +1 -1
- package/dist/src/core/messages.d.ts +235 -2
- package/dist/src/core/messages.d.ts.map +1 -1
- package/dist/src/core/messages.js +74 -1
- package/dist/src/core/messages.js.map +1 -1
- package/dist/src/core/numeric-ranges.d.ts +51 -0
- package/dist/src/core/numeric-ranges.d.ts.map +1 -0
- package/dist/src/core/numeric-ranges.js +30 -0
- package/dist/src/core/numeric-ranges.js.map +1 -0
- package/dist/src/core/parser.d.ts.map +1 -1
- package/dist/src/core/parser.js +232 -5
- package/dist/src/core/parser.js.map +1 -1
- package/dist/src/core/program.d.ts +2 -45
- package/dist/src/core/program.d.ts.map +1 -1
- package/dist/src/core/program.js +3 -127
- package/dist/src/core/program.js.map +1 -1
- package/dist/src/core/projected-program.d.ts +3 -0
- package/dist/src/core/projected-program.d.ts.map +1 -0
- package/dist/src/core/projected-program.js +4 -0
- package/dist/src/core/projected-program.js.map +1 -0
- package/dist/src/core/projection-members.d.ts +2 -2
- package/dist/src/core/projection-members.d.ts.map +1 -1
- package/dist/src/core/projector.d.ts +2 -2
- package/dist/src/core/projector.d.ts.map +1 -1
- package/dist/src/core/projector.js +12 -3
- package/dist/src/core/projector.js.map +1 -1
- package/dist/src/core/scanner.d.ts +42 -37
- package/dist/src/core/scanner.d.ts.map +1 -1
- package/dist/src/core/scanner.js +67 -46
- package/dist/src/core/scanner.js.map +1 -1
- package/dist/src/core/semantic-walker.d.ts +1 -1
- package/dist/src/core/semantic-walker.d.ts.map +1 -1
- package/dist/src/core/semantic-walker.js +12 -0
- package/dist/src/core/semantic-walker.js.map +1 -1
- package/dist/src/core/state-accessors.d.ts +46 -0
- package/dist/src/core/state-accessors.d.ts.map +1 -0
- package/dist/src/core/state-accessors.js +123 -0
- package/dist/src/core/state-accessors.js.map +1 -0
- package/dist/src/core/type-utils.d.ts +18 -7
- package/dist/src/core/type-utils.d.ts.map +1 -1
- package/dist/src/core/type-utils.js +24 -5
- package/dist/src/core/type-utils.js.map +1 -1
- package/dist/src/core/types.d.ts +224 -45
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/types.js +8 -0
- package/dist/src/core/types.js.map +1 -1
- package/dist/src/emitter-framework/asset-emitter.d.ts +1 -1
- package/dist/src/emitter-framework/asset-emitter.d.ts.map +1 -1
- package/dist/src/emitter-framework/asset-emitter.js +4 -1
- package/dist/src/emitter-framework/asset-emitter.js.map +1 -1
- package/dist/src/emitter-framework/ref-scope.d.ts +1 -1
- package/dist/src/emitter-framework/ref-scope.d.ts.map +1 -1
- package/dist/src/emitter-framework/reference-cycle.d.ts +2 -2
- package/dist/src/emitter-framework/reference-cycle.d.ts.map +1 -1
- package/dist/src/emitter-framework/reference-cycle.js +1 -1
- package/dist/src/emitter-framework/reference-cycle.js.map +1 -1
- package/dist/src/emitter-framework/type-emitter.d.ts +2 -1
- package/dist/src/emitter-framework/type-emitter.d.ts.map +1 -1
- package/dist/src/emitter-framework/type-emitter.js +10 -2
- package/dist/src/emitter-framework/type-emitter.js.map +1 -1
- package/dist/src/emitter-framework/types.d.ts +2 -2
- package/dist/src/emitter-framework/types.d.ts.map +1 -1
- package/dist/src/formatter/print/comment-handler.d.ts.map +1 -1
- package/dist/src/formatter/print/comment-handler.js +22 -0
- package/dist/src/formatter/print/comment-handler.js.map +1 -1
- package/dist/src/formatter/print/printer.d.ts +11 -5
- package/dist/src/formatter/print/printer.d.ts.map +1 -1
- package/dist/src/formatter/print/printer.js +95 -4
- package/dist/src/formatter/print/printer.js.map +1 -1
- package/dist/src/init/file-templating.d.ts +2 -2
- package/dist/src/init/file-templating.d.ts.map +1 -1
- package/dist/src/lib/decorators.d.ts +3 -55
- package/dist/src/lib/decorators.d.ts.map +1 -1
- package/dist/src/lib/decorators.js +30 -124
- package/dist/src/lib/decorators.js.map +1 -1
- package/dist/src/lib/encoded-names.d.ts +2 -2
- package/dist/src/lib/encoded-names.d.ts.map +1 -1
- package/dist/src/lib/intrinsic-decorators.d.ts +2 -2
- package/dist/src/lib/intrinsic-decorators.d.ts.map +1 -1
- package/dist/src/lib/intrinsic-decorators.js +7 -0
- package/dist/src/lib/intrinsic-decorators.js.map +1 -1
- package/dist/src/lib/service.d.ts +1 -1
- package/dist/src/lib/service.d.ts.map +1 -1
- package/dist/src/server/classify.d.ts.map +1 -1
- package/dist/src/server/classify.js +10 -0
- package/dist/src/server/classify.js.map +1 -1
- package/dist/src/server/completion.d.ts.map +1 -1
- package/dist/src/server/completion.js +6 -0
- package/dist/src/server/completion.js.map +1 -1
- package/dist/src/server/serverlib.js +2 -2
- package/dist/src/server/serverlib.js.map +1 -1
- package/dist/src/server/tmlanguage.d.ts +1 -1
- package/dist/src/server/tmlanguage.d.ts.map +1 -1
- package/dist/src/server/tmlanguage.js +147 -20
- package/dist/src/server/tmlanguage.js.map +1 -1
- package/dist/src/server/type-details.js +1 -2
- package/dist/src/server/type-details.js.map +1 -1
- package/dist/src/server/type-signature.js +15 -6
- package/dist/src/server/type-signature.js.map +1 -1
- package/dist/src/server/types.d.ts +1 -1
- package/dist/src/server/types.d.ts.map +1 -1
- package/dist/src/testing/expect.js +1 -1
- package/dist/src/testing/expect.js.map +1 -1
- package/dist/src/testing/rule-tester.d.ts.map +1 -1
- package/dist/src/testing/rule-tester.js +1 -2
- package/dist/src/testing/rule-tester.js.map +1 -1
- package/dist/src/testing/test-host.d.ts +1 -2
- package/dist/src/testing/test-host.d.ts.map +1 -1
- package/dist/src/testing/test-host.js +1 -8
- package/dist/src/testing/test-host.js.map +1 -1
- package/dist/src/testing/test-server-host.d.ts.map +1 -1
- package/dist/src/testing/test-server-host.js +2 -1
- package/dist/src/testing/test-server-host.js.map +1 -1
- package/dist/src/testing/test-utils.d.ts +1 -0
- package/dist/src/testing/test-utils.d.ts.map +1 -1
- package/dist/src/testing/test-utils.js +7 -0
- package/dist/src/testing/test-utils.js.map +1 -1
- package/dist/typespec.tmLanguage +408 -17
- package/lib/intrinsics.tsp +55 -5
- package/package.json +1 -1
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import { Program } from "./program.js";
|
|
2
|
-
import { Enum, ErrorType, Interface, Model, Namespace, NeverType, Node, NullType, Operation, Sym, TemplateDeclarationNode, TemplatedType, Type, TypeMapper, UnknownType, VoidType } from "./types.js";
|
|
3
|
-
export declare function isErrorType(type:
|
|
4
|
-
export declare function isVoidType(type:
|
|
5
|
-
export declare function isNeverType(type:
|
|
6
|
-
export declare function isUnknownType(type:
|
|
7
|
-
export declare function isNullType(type:
|
|
1
|
+
import type { Program } from "./program.js";
|
|
2
|
+
import { ArrayModelType, Entity, Enum, ErrorType, Interface, Model, Namespace, NeverType, Node, NullType, Operation, Sym, TemplateDeclarationNode, TemplatedType, Type, TypeMapper, UnknownType, Value, VoidType } from "./types.js";
|
|
3
|
+
export declare function isErrorType(type: Entity): type is ErrorType;
|
|
4
|
+
export declare function isVoidType(type: Entity): type is VoidType;
|
|
5
|
+
export declare function isNeverType(type: Entity): type is NeverType;
|
|
6
|
+
export declare function isUnknownType(type: Entity): type is UnknownType;
|
|
7
|
+
export declare function isNullType(type: Entity): type is NullType;
|
|
8
|
+
export declare function isType(entity: Entity): entity is Type;
|
|
9
|
+
export declare function isValue(entity: Entity): entity is Value;
|
|
10
|
+
/**
|
|
11
|
+
* @param type Model type
|
|
12
|
+
*/
|
|
13
|
+
export declare function isArrayModelType(program: Program, type: Model): type is ArrayModelType;
|
|
14
|
+
/**
|
|
15
|
+
* Check if a model is an array type.
|
|
16
|
+
* @param type Model type
|
|
17
|
+
*/
|
|
18
|
+
export declare function isRecordModelType(program: Program, type: Model): type is ArrayModelType;
|
|
8
19
|
/**
|
|
9
20
|
* Lookup and find the node
|
|
10
21
|
* @param node Node
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../../../src/core/type-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../../../src/core/type-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,MAAM,EACN,IAAI,EACJ,SAAS,EACT,SAAS,EACT,KAAK,EACL,SAAS,EACT,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,GAAG,EAGH,uBAAuB,EACvB,aAAa,EACb,IAAI,EACJ,UAAU,EACV,WAAW,EACX,KAAK,EACL,QAAQ,EACT,MAAM,YAAY,CAAC;AAEpB,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,SAAS,CAE3D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,QAAQ,CAEzD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,SAAS,CAE3D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,WAAW,CAE/D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,QAAQ,CAEzD;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,IAAI,CAErD;AACD,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,KAAK,CAEvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI,IAAI,cAAc,CAEtF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,G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|
|
3
|
-
return type.kind === "Intrinsic" && type.name === "ErrorType";
|
|
3
|
+
return "kind" in type && type.kind === "Intrinsic" && type.name === "ErrorType";
|
|
4
4
|
}
|
|
5
5
|
export function isVoidType(type) {
|
|
6
|
-
return type.kind === "Intrinsic" && type.name === "void";
|
|
6
|
+
return "kind" in type && type.kind === "Intrinsic" && type.name === "void";
|
|
7
7
|
}
|
|
8
8
|
export function isNeverType(type) {
|
|
9
|
-
return type.kind === "Intrinsic" && type.name === "never";
|
|
9
|
+
return "kind" in type && type.kind === "Intrinsic" && type.name === "never";
|
|
10
10
|
}
|
|
11
11
|
export function isUnknownType(type) {
|
|
12
|
-
return type.kind === "Intrinsic" && type.name === "unknown";
|
|
12
|
+
return "kind" in type && type.kind === "Intrinsic" && type.name === "unknown";
|
|
13
13
|
}
|
|
14
14
|
export function isNullType(type) {
|
|
15
|
-
return type.kind === "Intrinsic" && type.name === "null";
|
|
15
|
+
return "kind" in type && type.kind === "Intrinsic" && type.name === "null";
|
|
16
|
+
}
|
|
17
|
+
export function isType(entity) {
|
|
18
|
+
return entity.entityKind === "Type";
|
|
19
|
+
}
|
|
20
|
+
export function isValue(entity) {
|
|
21
|
+
return entity.entityKind === "Value";
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @param type Model type
|
|
25
|
+
*/
|
|
26
|
+
export function isArrayModelType(program, type) {
|
|
27
|
+
return Boolean(type.indexer && type.indexer.key.name === "integer");
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Check if a model is an array type.
|
|
31
|
+
* @param type Model type
|
|
32
|
+
*/
|
|
33
|
+
export function isRecordModelType(program, type) {
|
|
34
|
+
return Boolean(type.indexer && type.indexer.key.name === "string");
|
|
16
35
|
}
|
|
17
36
|
/**
|
|
18
37
|
* Lookup and find the node
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-utils.js","sourceRoot":"","sources":["../../../src/core/type-utils.ts"],"names":[],"mappings":"AACA,OAAO,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SchemaType as AjvJSONSchemaType } from "ajv";
|
|
2
|
-
import { TypeEmitter } from "../emitter-framework/type-emitter.js";
|
|
3
|
-
import { AssetEmitter } from "../emitter-framework/types.js";
|
|
4
|
-
import { ModuleResolutionResult } from "./module-resolver.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
import type { TypeEmitter } from "../emitter-framework/type-emitter.js";
|
|
3
|
+
import type { AssetEmitter } from "../emitter-framework/types.js";
|
|
4
|
+
import type { ModuleResolutionResult } from "./module-resolver.js";
|
|
5
|
+
import type { Numeric } from "./numeric.js";
|
|
6
|
+
import type { Program } from "./program.js";
|
|
7
|
+
export type MarshalledValue<Value> = Value extends StringValue ? string : Value extends NumericValue ? number | Numeric : Value extends BooleanValue ? boolean : Value extends ObjectValue ? Record<string, unknown> : Value extends ArrayValue ? unknown[] : Value extends EnumValue ? EnumMember : Value extends NullValue ? null : Value extends ScalarValue ? Value : Value;
|
|
7
8
|
/**
|
|
8
9
|
* Type System types
|
|
9
10
|
*/
|
|
10
11
|
export type DecoratorArgumentValue = Type | number | string | boolean;
|
|
11
12
|
export interface DecoratorArgument {
|
|
12
|
-
value: Type;
|
|
13
|
+
value: Type | Value;
|
|
13
14
|
/**
|
|
14
15
|
* Marshalled value for use in Javascript.
|
|
15
16
|
*/
|
|
16
|
-
jsValue: Type | string | number | boolean;
|
|
17
|
+
jsValue: Type | Value | Record<string, unknown> | unknown[] | string | number | boolean | Numeric | null;
|
|
17
18
|
node?: Node;
|
|
18
19
|
}
|
|
19
20
|
export interface DecoratorApplication {
|
|
@@ -27,6 +28,7 @@ export interface DecoratorFunction {
|
|
|
27
28
|
namespace?: string;
|
|
28
29
|
}
|
|
29
30
|
export interface BaseType {
|
|
31
|
+
readonly entityKind: "Type";
|
|
30
32
|
kind: string;
|
|
31
33
|
node?: Node;
|
|
32
34
|
instantiationParameters?: Type[];
|
|
@@ -53,18 +55,25 @@ export interface DecoratedType {
|
|
|
53
55
|
export type TemplatedType = Model | Operation | Interface | Union | Scalar;
|
|
54
56
|
export interface TypeMapper {
|
|
55
57
|
partial: boolean;
|
|
56
|
-
getMappedType(type: TemplateParameter): Type;
|
|
57
|
-
args: readonly Type[];
|
|
58
|
+
getMappedType(type: TemplateParameter): Type | Value | IndeterminateEntity;
|
|
59
|
+
args: readonly (Type | Value | IndeterminateEntity)[];
|
|
58
60
|
}
|
|
59
61
|
export interface TemplatedTypeBase {
|
|
60
62
|
templateMapper?: TypeMapper;
|
|
61
63
|
/**
|
|
62
64
|
* @deprecated use templateMapper instead.
|
|
63
65
|
*/
|
|
64
|
-
templateArguments?: Type[];
|
|
66
|
+
templateArguments?: (Type | Value | IndeterminateEntity)[];
|
|
65
67
|
templateNode?: Node;
|
|
66
68
|
}
|
|
67
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Represent every single entity that are part of the TypeSpec program. Those are composed of different elements:
|
|
71
|
+
* - Types
|
|
72
|
+
* - Values
|
|
73
|
+
* - Value Constraints
|
|
74
|
+
*/
|
|
75
|
+
export type Entity = Type | Value | MixedParameterConstraint | IndeterminateEntity;
|
|
76
|
+
export type Type = BooleanLiteral | Decorator | Enum | EnumMember | FunctionParameter | FunctionType | Interface | IntrinsicType | Model | ModelProperty | Namespace | NumericLiteral | ObjectType | Operation | Projection | Scalar | ScalarConstructor | StringLiteral | StringTemplate | StringTemplateSpan | TemplateParameter | Tuple | Union | UnionVariant;
|
|
68
77
|
export type StdTypes = {
|
|
69
78
|
Array: Model;
|
|
70
79
|
Record: Model;
|
|
@@ -91,13 +100,22 @@ export interface Projector {
|
|
|
91
100
|
parentProjector?: Projector;
|
|
92
101
|
projections: ProjectionApplication[];
|
|
93
102
|
projectedTypes: Map<Type, Type>;
|
|
94
|
-
projectType(type: Type): Type;
|
|
103
|
+
projectType(type: Type | Value): Type | Value;
|
|
95
104
|
projectedStartNode?: Type;
|
|
96
105
|
projectedGlobalNamespace?: Namespace;
|
|
97
106
|
}
|
|
98
|
-
export interface
|
|
99
|
-
|
|
100
|
-
|
|
107
|
+
export interface MixedParameterConstraint {
|
|
108
|
+
readonly entityKind: "MixedParameterConstraint";
|
|
109
|
+
readonly node?: UnionExpressionNode | Expression;
|
|
110
|
+
/** Type constraints */
|
|
111
|
+
readonly type?: Type;
|
|
112
|
+
/** Expecting value */
|
|
113
|
+
readonly valueType?: Type;
|
|
114
|
+
}
|
|
115
|
+
/** When an entity that could be used as a type or value has not figured out if it is a value or type yet. */
|
|
116
|
+
export interface IndeterminateEntity {
|
|
117
|
+
readonly entityKind: "Indeterminate";
|
|
118
|
+
readonly type: StringLiteral | StringTemplate | NumericLiteral | BooleanLiteral | EnumMember | UnionVariant | NullType;
|
|
101
119
|
}
|
|
102
120
|
export interface IntrinsicType extends BaseType {
|
|
103
121
|
kind: "Intrinsic";
|
|
@@ -146,7 +164,7 @@ export interface RecordModelType extends Model {
|
|
|
146
164
|
export interface Model extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
147
165
|
kind: "Model";
|
|
148
166
|
name: string;
|
|
149
|
-
node?: ModelStatementNode | ModelExpressionNode | IntersectionExpressionNode | ProjectionModelExpressionNode;
|
|
167
|
+
node?: ModelStatementNode | ModelExpressionNode | IntersectionExpressionNode | ProjectionModelExpressionNode | ObjectLiteralNode;
|
|
150
168
|
namespace?: Namespace;
|
|
151
169
|
indexer?: ModelIndexer;
|
|
152
170
|
/**
|
|
@@ -192,14 +210,77 @@ export interface SourceModel {
|
|
|
192
210
|
}
|
|
193
211
|
export interface ModelProperty extends BaseType, DecoratedType {
|
|
194
212
|
kind: "ModelProperty";
|
|
195
|
-
node: ModelPropertyNode | ModelSpreadPropertyNode | ProjectionModelPropertyNode | ProjectionModelSpreadPropertyNode;
|
|
213
|
+
node: ModelPropertyNode | ModelSpreadPropertyNode | ProjectionModelPropertyNode | ProjectionModelSpreadPropertyNode | ObjectLiteralPropertyNode;
|
|
196
214
|
name: string;
|
|
197
215
|
type: Type;
|
|
198
216
|
sourceProperty?: ModelProperty;
|
|
199
217
|
optional: boolean;
|
|
218
|
+
/** @deprecated use {@link defaultValue} instead. */
|
|
200
219
|
default?: Type;
|
|
220
|
+
defaultValue?: Value;
|
|
201
221
|
model?: Model;
|
|
202
222
|
}
|
|
223
|
+
export type Value = ScalarValue | NumericValue | StringValue | BooleanValue | ObjectValue | ArrayValue | EnumValue | NullValue;
|
|
224
|
+
interface BaseValue {
|
|
225
|
+
readonly entityKind: "Value";
|
|
226
|
+
readonly valueKind: string;
|
|
227
|
+
/**
|
|
228
|
+
* Represent the storage type of a value.
|
|
229
|
+
* @example
|
|
230
|
+
* ```tsp
|
|
231
|
+
* const a = "hello"; // Type here would be "hello"
|
|
232
|
+
* const b: string = a; // Type here would be string
|
|
233
|
+
* const c: string | int32 = b; // Type here would be string | int32
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
type: Type;
|
|
237
|
+
}
|
|
238
|
+
export interface ObjectValue extends BaseValue {
|
|
239
|
+
valueKind: "ObjectValue";
|
|
240
|
+
node: ObjectLiteralNode;
|
|
241
|
+
properties: Map<string, ObjectValuePropertyDescriptor>;
|
|
242
|
+
}
|
|
243
|
+
export interface ObjectValuePropertyDescriptor {
|
|
244
|
+
node: ObjectLiteralPropertyNode;
|
|
245
|
+
name: string;
|
|
246
|
+
value: Value;
|
|
247
|
+
}
|
|
248
|
+
export interface ArrayValue extends BaseValue {
|
|
249
|
+
valueKind: "ArrayValue";
|
|
250
|
+
node: ArrayLiteralNode;
|
|
251
|
+
values: Value[];
|
|
252
|
+
}
|
|
253
|
+
export interface ScalarValue extends BaseValue {
|
|
254
|
+
valueKind: "ScalarValue";
|
|
255
|
+
scalar: Scalar;
|
|
256
|
+
value: {
|
|
257
|
+
name: string;
|
|
258
|
+
args: Value[];
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
export interface NumericValue extends BaseValue {
|
|
262
|
+
valueKind: "NumericValue";
|
|
263
|
+
scalar: Scalar | undefined;
|
|
264
|
+
value: Numeric;
|
|
265
|
+
}
|
|
266
|
+
export interface StringValue extends BaseValue {
|
|
267
|
+
valueKind: "StringValue";
|
|
268
|
+
scalar: Scalar | undefined;
|
|
269
|
+
value: string;
|
|
270
|
+
}
|
|
271
|
+
export interface BooleanValue extends BaseValue {
|
|
272
|
+
valueKind: "BooleanValue";
|
|
273
|
+
scalar: Scalar | undefined;
|
|
274
|
+
value: boolean;
|
|
275
|
+
}
|
|
276
|
+
export interface EnumValue extends BaseValue {
|
|
277
|
+
valueKind: "EnumValue";
|
|
278
|
+
value: EnumMember;
|
|
279
|
+
}
|
|
280
|
+
export interface NullValue extends BaseValue {
|
|
281
|
+
valueKind: "NullValue";
|
|
282
|
+
value: null;
|
|
283
|
+
}
|
|
203
284
|
export interface Scalar extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
204
285
|
kind: "Scalar";
|
|
205
286
|
name: string;
|
|
@@ -216,6 +297,14 @@ export interface Scalar extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
|
216
297
|
* Direct children. This is the reverse relation of @see baseScalar
|
|
217
298
|
*/
|
|
218
299
|
derivedScalars: Scalar[];
|
|
300
|
+
constructors: Map<string, ScalarConstructor>;
|
|
301
|
+
}
|
|
302
|
+
export interface ScalarConstructor extends BaseType {
|
|
303
|
+
kind: "ScalarConstructor";
|
|
304
|
+
node: ScalarConstructorNode;
|
|
305
|
+
name: string;
|
|
306
|
+
scalar: Scalar;
|
|
307
|
+
parameters: SignatureFunctionParameter[];
|
|
219
308
|
}
|
|
220
309
|
export interface Interface extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
221
310
|
kind: "Interface";
|
|
@@ -348,6 +437,7 @@ export interface NumericLiteral extends BaseType {
|
|
|
348
437
|
kind: "Number";
|
|
349
438
|
node?: NumericLiteralNode;
|
|
350
439
|
value: number;
|
|
440
|
+
numericValue: Numeric;
|
|
351
441
|
valueAsString: string;
|
|
352
442
|
}
|
|
353
443
|
export interface BooleanLiteral extends BaseType {
|
|
@@ -357,6 +447,8 @@ export interface BooleanLiteral extends BaseType {
|
|
|
357
447
|
}
|
|
358
448
|
export interface StringTemplate extends BaseType {
|
|
359
449
|
kind: "StringTemplate";
|
|
450
|
+
/** If the template can be render as as string this is the string value */
|
|
451
|
+
stringValue?: string;
|
|
360
452
|
node: StringTemplateExpressionNode;
|
|
361
453
|
spans: StringTemplateSpan[];
|
|
362
454
|
}
|
|
@@ -375,7 +467,7 @@ export interface StringTemplateSpanValue extends BaseType {
|
|
|
375
467
|
}
|
|
376
468
|
export interface Tuple extends BaseType {
|
|
377
469
|
kind: "Tuple";
|
|
378
|
-
node: TupleExpressionNode;
|
|
470
|
+
node: TupleExpressionNode | ArrayLiteralNode;
|
|
379
471
|
values: Type[];
|
|
380
472
|
}
|
|
381
473
|
export interface Union extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
@@ -405,16 +497,16 @@ export interface UnionVariant extends BaseType, DecoratedType {
|
|
|
405
497
|
export interface TemplateParameter extends BaseType {
|
|
406
498
|
kind: "TemplateParameter";
|
|
407
499
|
node: TemplateParameterDeclarationNode;
|
|
408
|
-
constraint?:
|
|
409
|
-
default?: Type;
|
|
500
|
+
constraint?: MixedParameterConstraint;
|
|
501
|
+
default?: Type | Value | IndeterminateEntity;
|
|
410
502
|
}
|
|
411
503
|
export interface Decorator extends BaseType {
|
|
412
504
|
kind: "Decorator";
|
|
413
505
|
node: DecoratorDeclarationStatementNode;
|
|
414
506
|
name: `@${string}`;
|
|
415
507
|
namespace: Namespace;
|
|
416
|
-
target:
|
|
417
|
-
parameters:
|
|
508
|
+
target: MixedFunctionParameter;
|
|
509
|
+
parameters: MixedFunctionParameter[];
|
|
418
510
|
implementation: (...args: unknown[]) => void;
|
|
419
511
|
}
|
|
420
512
|
export interface FunctionType extends BaseType {
|
|
@@ -422,18 +514,28 @@ export interface FunctionType extends BaseType {
|
|
|
422
514
|
node?: FunctionDeclarationStatementNode;
|
|
423
515
|
namespace?: Namespace;
|
|
424
516
|
name: string;
|
|
425
|
-
parameters:
|
|
517
|
+
parameters: MixedFunctionParameter[];
|
|
426
518
|
returnType: Type;
|
|
427
519
|
implementation: (...args: unknown[]) => unknown;
|
|
428
520
|
}
|
|
429
|
-
export interface
|
|
521
|
+
export interface FunctionParameterBase extends BaseType {
|
|
430
522
|
kind: "FunctionParameter";
|
|
431
523
|
node: FunctionParameterNode;
|
|
432
524
|
name: string;
|
|
433
|
-
type: Type | ValueType;
|
|
434
525
|
optional: boolean;
|
|
435
526
|
rest: boolean;
|
|
436
527
|
}
|
|
528
|
+
/** Represent a function parameter that could accept types or values in the TypeSpec program. */
|
|
529
|
+
export interface MixedFunctionParameter extends FunctionParameterBase {
|
|
530
|
+
mixed: true;
|
|
531
|
+
type: MixedParameterConstraint;
|
|
532
|
+
}
|
|
533
|
+
/** Represent a function parameter that represent the parameter signature(i.e the type would be the type of the value passed) */
|
|
534
|
+
export interface SignatureFunctionParameter extends FunctionParameterBase {
|
|
535
|
+
mixed: false;
|
|
536
|
+
type: Type;
|
|
537
|
+
}
|
|
538
|
+
export type FunctionParameter = MixedFunctionParameter | SignatureFunctionParameter;
|
|
437
539
|
export interface Sym {
|
|
438
540
|
readonly flags: SymbolFlags;
|
|
439
541
|
/**
|
|
@@ -483,8 +585,12 @@ export interface Sym {
|
|
|
483
585
|
}
|
|
484
586
|
export interface SymbolLinks {
|
|
485
587
|
type?: Type;
|
|
588
|
+
/** For types that can be instanitated this is the type of the declaration */
|
|
486
589
|
declaredType?: Type;
|
|
590
|
+
/** For types that can be instanitated those are the types per instantiation */
|
|
487
591
|
instantiations?: TypeInstantiationMap;
|
|
592
|
+
/** For const statements the value of the const */
|
|
593
|
+
value?: Value | null;
|
|
488
594
|
}
|
|
489
595
|
/**
|
|
490
596
|
* @hidden bug in typedoc
|
|
@@ -520,24 +626,26 @@ export declare const enum SymbolFlags {
|
|
|
520
626
|
SourceFile = 2097152,
|
|
521
627
|
Declaration = 4194304,
|
|
522
628
|
Implementation = 8388608,
|
|
629
|
+
Const = 16777216,
|
|
630
|
+
ScalarMember = 33554432,
|
|
523
631
|
/**
|
|
524
632
|
* A symbol which was late-bound, in which case, the type referred to
|
|
525
633
|
* by this symbol is stored directly in the symbol.
|
|
526
634
|
*/
|
|
527
|
-
LateBound =
|
|
635
|
+
LateBound = 67108864,
|
|
528
636
|
ExportContainer = 2101248,
|
|
529
637
|
/**
|
|
530
638
|
* Symbols whose members will be late bound (and stored on the type)
|
|
531
639
|
*/
|
|
532
|
-
MemberContainer =
|
|
533
|
-
Member =
|
|
640
|
+
MemberContainer = 682,
|
|
641
|
+
Member = 33555780
|
|
534
642
|
}
|
|
535
643
|
/**
|
|
536
644
|
* Maps type arguments to instantiated type.
|
|
537
645
|
*/
|
|
538
646
|
export interface TypeInstantiationMap {
|
|
539
|
-
get(args: readonly Type[]): Type | undefined;
|
|
540
|
-
set(args: readonly Type[], type: Type): void;
|
|
647
|
+
get(args: readonly (Type | Value | IndeterminateEntity)[]): Type | undefined;
|
|
648
|
+
set(args: readonly (Type | Value | IndeterminateEntity)[], type: Type): void;
|
|
541
649
|
}
|
|
542
650
|
/**
|
|
543
651
|
* A map where keys can be changed without changing enumeration order.
|
|
@@ -650,7 +758,15 @@ export declare enum SyntaxKind {
|
|
|
650
758
|
ProjectionDecoratorReferenceExpression = 88,
|
|
651
759
|
Return = 89,
|
|
652
760
|
JsNamespaceDeclaration = 90,
|
|
653
|
-
TemplateArgument = 91
|
|
761
|
+
TemplateArgument = 91,
|
|
762
|
+
TypeOfExpression = 92,
|
|
763
|
+
ObjectLiteral = 93,
|
|
764
|
+
ObjectLiteralProperty = 94,
|
|
765
|
+
ObjectLiteralSpreadProperty = 95,
|
|
766
|
+
ArrayLiteral = 96,
|
|
767
|
+
ConstStatement = 97,
|
|
768
|
+
CallExpression = 98,
|
|
769
|
+
ScalarConstructor = 99
|
|
654
770
|
}
|
|
655
771
|
export declare const enum NodeFlags {
|
|
656
772
|
None = 0,
|
|
@@ -696,7 +812,7 @@ export interface TemplateDeclarationNode {
|
|
|
696
812
|
readonly templateParameters: readonly TemplateParameterDeclarationNode[];
|
|
697
813
|
readonly locals?: SymbolTable;
|
|
698
814
|
}
|
|
699
|
-
export type Node = TypeSpecScriptNode | JsSourceFileNode | JsNamespaceDeclarationNode | TemplateArgumentNode | TemplateParameterDeclarationNode | ProjectionParameterDeclarationNode | ProjectionLambdaParameterDeclarationNode | ModelPropertyNode | UnionVariantNode | OperationStatementNode | OperationSignatureDeclarationNode | OperationSignatureReferenceNode | EnumMemberNode | EnumSpreadMemberNode | ModelSpreadPropertyNode | DecoratorExpressionNode | DirectiveExpressionNode | Statement | Expression | FunctionParameterNode | StringTemplateSpanNode | StringTemplateHeadNode | StringTemplateMiddleNode | StringTemplateTailNode | Modifier | DocNode | DocContent | DocTag | ProjectionStatementItem | ProjectionExpression | ProjectionModelSelectorNode | ProjectionModelPropertySelectorNode | ProjectionScalarSelectorNode | ProjectionInterfaceSelectorNode | ProjectionOperationSelectorNode | ProjectionEnumSelectorNode | ProjectionEnumMemberSelectorNode | ProjectionUnionSelectorNode | ProjectionUnionVariantSelectorNode | ProjectionModelPropertyNode | ProjectionModelSpreadPropertyNode | ProjectionStatementNode | ProjectionNode;
|
|
815
|
+
export type Node = TypeSpecScriptNode | JsSourceFileNode | JsNamespaceDeclarationNode | TemplateArgumentNode | TemplateParameterDeclarationNode | ProjectionParameterDeclarationNode | ProjectionLambdaParameterDeclarationNode | ModelPropertyNode | UnionVariantNode | OperationStatementNode | OperationSignatureDeclarationNode | OperationSignatureReferenceNode | EnumMemberNode | EnumSpreadMemberNode | ModelSpreadPropertyNode | DecoratorExpressionNode | DirectiveExpressionNode | Statement | Expression | FunctionParameterNode | StringTemplateSpanNode | StringTemplateHeadNode | StringTemplateMiddleNode | StringTemplateTailNode | Modifier | DocNode | DocContent | DocTag | ProjectionStatementItem | ProjectionExpression | ProjectionModelSelectorNode | ProjectionModelPropertySelectorNode | ProjectionScalarSelectorNode | ProjectionInterfaceSelectorNode | ProjectionOperationSelectorNode | ProjectionEnumSelectorNode | ProjectionEnumMemberSelectorNode | ProjectionUnionSelectorNode | ProjectionUnionVariantSelectorNode | ProjectionModelPropertyNode | ProjectionModelSpreadPropertyNode | ProjectionStatementNode | ProjectionNode | ObjectLiteralNode | ObjectLiteralPropertyNode | ObjectLiteralSpreadPropertyNode | ScalarConstructorNode | ArrayLiteralNode;
|
|
700
816
|
/**
|
|
701
817
|
* Node that can be used as template
|
|
702
818
|
*/
|
|
@@ -705,8 +821,8 @@ export type TemplateableNode = ModelStatementNode | ScalarStatementNode | AliasS
|
|
|
705
821
|
* Node types that can have referencable members
|
|
706
822
|
*/
|
|
707
823
|
export type MemberContainerNode = ModelStatementNode | ModelExpressionNode | InterfaceStatementNode | EnumStatementNode | UnionStatementNode;
|
|
708
|
-
export type MemberNode = ModelPropertyNode | EnumMemberNode | OperationStatementNode | UnionVariantNode;
|
|
709
|
-
export type MemberContainerType = Model | Enum | Interface | Union;
|
|
824
|
+
export type MemberNode = ModelPropertyNode | EnumMemberNode | OperationStatementNode | UnionVariantNode | ScalarConstructorNode;
|
|
825
|
+
export type MemberContainerType = Model | Enum | Interface | Union | Scalar;
|
|
710
826
|
/**
|
|
711
827
|
* Type that can be used as members of a container type.
|
|
712
828
|
*/
|
|
@@ -741,11 +857,11 @@ export interface TypeSpecScriptNode extends DeclarationNode, BaseNode {
|
|
|
741
857
|
readonly locals: SymbolTable;
|
|
742
858
|
readonly parseOptions: ParseOptions;
|
|
743
859
|
}
|
|
744
|
-
export type Statement = ImportStatementNode | ModelStatementNode | ScalarStatementNode | NamespaceStatementNode | InterfaceStatementNode | UnionStatementNode | UsingStatementNode | EnumStatementNode | AliasStatementNode | OperationStatementNode | DecoratorDeclarationStatementNode | FunctionDeclarationStatementNode | AugmentDecoratorStatementNode | EmptyStatementNode | InvalidStatementNode | ProjectionStatementNode;
|
|
860
|
+
export type Statement = ImportStatementNode | ModelStatementNode | ScalarStatementNode | NamespaceStatementNode | InterfaceStatementNode | UnionStatementNode | UsingStatementNode | EnumStatementNode | AliasStatementNode | OperationStatementNode | DecoratorDeclarationStatementNode | FunctionDeclarationStatementNode | AugmentDecoratorStatementNode | ConstStatementNode | CallExpressionNode | EmptyStatementNode | InvalidStatementNode | ProjectionStatementNode;
|
|
745
861
|
export interface DeclarationNode {
|
|
746
862
|
readonly id: IdentifierNode;
|
|
747
863
|
}
|
|
748
|
-
export type Declaration = ModelStatementNode | ScalarStatementNode | InterfaceStatementNode | UnionStatementNode | NamespaceStatementNode | OperationStatementNode | TemplateParameterDeclarationNode | ProjectionStatementNode | ProjectionParameterDeclarationNode | ProjectionLambdaParameterDeclarationNode | EnumStatementNode | AliasStatementNode | DecoratorDeclarationStatementNode | FunctionDeclarationStatementNode;
|
|
864
|
+
export type Declaration = ModelStatementNode | ScalarStatementNode | InterfaceStatementNode | UnionStatementNode | NamespaceStatementNode | OperationStatementNode | TemplateParameterDeclarationNode | ProjectionStatementNode | ProjectionParameterDeclarationNode | ProjectionLambdaParameterDeclarationNode | EnumStatementNode | AliasStatementNode | ConstStatementNode | DecoratorDeclarationStatementNode | FunctionDeclarationStatementNode;
|
|
749
865
|
export type ScopeNode = NamespaceStatementNode | ModelStatementNode | InterfaceStatementNode | AliasStatementNode | TypeSpecScriptNode | JsSourceFileNode | ProjectionLambdaExpressionNode | ProjectionNode;
|
|
750
866
|
export interface ImportStatementNode extends BaseNode {
|
|
751
867
|
readonly kind: SyntaxKind.ImportStatement;
|
|
@@ -774,7 +890,7 @@ export interface DirectiveExpressionNode extends BaseNode {
|
|
|
774
890
|
readonly arguments: readonly DirectiveArgument[];
|
|
775
891
|
}
|
|
776
892
|
export type DirectiveArgument = StringLiteralNode | IdentifierNode;
|
|
777
|
-
export type Expression = ArrayExpressionNode | MemberExpressionNode | ModelExpressionNode | TupleExpressionNode | UnionExpressionNode | IntersectionExpressionNode | TypeReferenceNode | ValueOfExpressionNode | StringLiteralNode | NumericLiteralNode | BooleanLiteralNode | StringTemplateExpressionNode | VoidKeywordNode | NeverKeywordNode | AnyKeywordNode;
|
|
893
|
+
export type Expression = ArrayExpressionNode | MemberExpressionNode | ModelExpressionNode | ObjectLiteralNode | ArrayLiteralNode | TupleExpressionNode | UnionExpressionNode | IntersectionExpressionNode | TypeReferenceNode | ValueOfExpressionNode | TypeOfExpressionNode | CallExpressionNode | StringLiteralNode | NumericLiteralNode | BooleanLiteralNode | StringTemplateExpressionNode | VoidKeywordNode | NeverKeywordNode | AnyKeywordNode;
|
|
778
894
|
export type ProjectionExpression = ProjectionLogicalExpressionNode | ProjectionRelationalExpressionNode | ProjectionEqualityExpressionNode | ProjectionUnaryExpressionNode | ProjectionArithmeticExpressionNode | ProjectionCallExpressionNode | ProjectionMemberExpressionNode | ProjectionDecoratorReferenceExpressionNode | ProjectionTupleExpressionNode | ProjectionModelExpressionNode | ProjectionIfExpressionNode | ProjectionBlockExpressionNode | ProjectionLambdaExpressionNode | StringLiteralNode | NumericLiteralNode | BooleanLiteralNode | IdentifierNode | VoidKeywordNode | NeverKeywordNode | AnyKeywordNode | ReturnExpressionNode;
|
|
779
895
|
export type ReferenceExpression = TypeReferenceNode | MemberExpressionNode | IdentifierNode | VoidKeywordNode | NeverKeywordNode;
|
|
780
896
|
export interface MemberExpressionNode extends BaseNode {
|
|
@@ -823,8 +939,15 @@ export interface ScalarStatementNode extends BaseNode, DeclarationNode, Template
|
|
|
823
939
|
readonly kind: SyntaxKind.ScalarStatement;
|
|
824
940
|
readonly extends?: TypeReferenceNode;
|
|
825
941
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
942
|
+
readonly members: readonly ScalarConstructorNode[];
|
|
826
943
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
827
944
|
}
|
|
945
|
+
export interface ScalarConstructorNode extends BaseNode {
|
|
946
|
+
readonly kind: SyntaxKind.ScalarConstructor;
|
|
947
|
+
readonly id: IdentifierNode;
|
|
948
|
+
readonly parameters: FunctionParameterNode[];
|
|
949
|
+
readonly parent?: ScalarStatementNode;
|
|
950
|
+
}
|
|
828
951
|
export interface InterfaceStatementNode extends BaseNode, DeclarationNode, TemplateDeclarationNode {
|
|
829
952
|
readonly kind: SyntaxKind.InterfaceStatement;
|
|
830
953
|
readonly operations: readonly OperationStatementNode[];
|
|
@@ -867,6 +990,17 @@ export interface AliasStatementNode extends BaseNode, DeclarationNode, TemplateD
|
|
|
867
990
|
readonly value: Expression;
|
|
868
991
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
869
992
|
}
|
|
993
|
+
export interface ConstStatementNode extends BaseNode, DeclarationNode {
|
|
994
|
+
readonly kind: SyntaxKind.ConstStatement;
|
|
995
|
+
readonly value: Expression;
|
|
996
|
+
readonly type?: Expression;
|
|
997
|
+
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
998
|
+
}
|
|
999
|
+
export interface CallExpressionNode extends BaseNode {
|
|
1000
|
+
readonly kind: SyntaxKind.CallExpression;
|
|
1001
|
+
readonly target: MemberExpressionNode | IdentifierNode;
|
|
1002
|
+
readonly arguments: Expression[];
|
|
1003
|
+
}
|
|
870
1004
|
export interface InvalidStatementNode extends BaseNode {
|
|
871
1005
|
readonly kind: SyntaxKind.InvalidStatement;
|
|
872
1006
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
@@ -900,6 +1034,25 @@ export interface ModelSpreadPropertyNode extends BaseNode {
|
|
|
900
1034
|
readonly target: TypeReferenceNode;
|
|
901
1035
|
readonly parent?: ModelStatementNode | ModelExpressionNode;
|
|
902
1036
|
}
|
|
1037
|
+
export interface ObjectLiteralNode extends BaseNode {
|
|
1038
|
+
readonly kind: SyntaxKind.ObjectLiteral;
|
|
1039
|
+
readonly properties: (ObjectLiteralPropertyNode | ObjectLiteralSpreadPropertyNode)[];
|
|
1040
|
+
}
|
|
1041
|
+
export interface ObjectLiteralPropertyNode extends BaseNode {
|
|
1042
|
+
readonly kind: SyntaxKind.ObjectLiteralProperty;
|
|
1043
|
+
readonly id: IdentifierNode;
|
|
1044
|
+
readonly value: Expression;
|
|
1045
|
+
readonly parent?: ObjectLiteralNode;
|
|
1046
|
+
}
|
|
1047
|
+
export interface ObjectLiteralSpreadPropertyNode extends BaseNode {
|
|
1048
|
+
readonly kind: SyntaxKind.ObjectLiteralSpreadProperty;
|
|
1049
|
+
readonly target: TypeReferenceNode;
|
|
1050
|
+
readonly parent?: ObjectLiteralNode;
|
|
1051
|
+
}
|
|
1052
|
+
export interface ArrayLiteralNode extends BaseNode {
|
|
1053
|
+
readonly kind: SyntaxKind.ArrayLiteral;
|
|
1054
|
+
readonly values: readonly Expression[];
|
|
1055
|
+
}
|
|
903
1056
|
export type LiteralNode = StringLiteralNode | NumericLiteralNode | BooleanLiteralNode | StringTemplateHeadNode | StringTemplateMiddleNode | StringTemplateTailNode;
|
|
904
1057
|
export interface StringLiteralNode extends BaseNode {
|
|
905
1058
|
readonly kind: SyntaxKind.StringLiteral;
|
|
@@ -964,6 +1117,10 @@ export interface ValueOfExpressionNode extends BaseNode {
|
|
|
964
1117
|
readonly kind: SyntaxKind.ValueOfExpression;
|
|
965
1118
|
readonly target: Expression;
|
|
966
1119
|
}
|
|
1120
|
+
export interface TypeOfExpressionNode extends BaseNode {
|
|
1121
|
+
readonly kind: SyntaxKind.TypeOfExpression;
|
|
1122
|
+
readonly target: Expression;
|
|
1123
|
+
}
|
|
967
1124
|
export interface TypeReferenceNode extends BaseNode {
|
|
968
1125
|
readonly kind: SyntaxKind.TypeReference;
|
|
969
1126
|
readonly target: MemberExpressionNode | IdentifierNode;
|
|
@@ -1284,20 +1441,24 @@ export interface SourceFile {
|
|
|
1284
1441
|
export type LocationContext = ProjectLocationContext | CompilerLocationContext | SyntheticLocationContext | LibraryLocationContext;
|
|
1285
1442
|
/** Defined in the user project. */
|
|
1286
1443
|
export interface ProjectLocationContext {
|
|
1287
|
-
type: "project";
|
|
1444
|
+
readonly type: "project";
|
|
1445
|
+
readonly flags?: PackageFlags;
|
|
1288
1446
|
}
|
|
1289
1447
|
/** Built-in */
|
|
1290
1448
|
export interface CompilerLocationContext {
|
|
1291
|
-
type: "compiler";
|
|
1449
|
+
readonly type: "compiler";
|
|
1292
1450
|
}
|
|
1293
1451
|
/** Refer to a type that was not declared in a file */
|
|
1294
1452
|
export interface SyntheticLocationContext {
|
|
1295
|
-
type: "synthetic";
|
|
1453
|
+
readonly type: "synthetic";
|
|
1296
1454
|
}
|
|
1297
1455
|
/** Defined in a library. */
|
|
1298
1456
|
export interface LibraryLocationContext {
|
|
1299
|
-
type: "library";
|
|
1300
|
-
metadata
|
|
1457
|
+
readonly type: "library";
|
|
1458
|
+
/** Library metadata */
|
|
1459
|
+
readonly metadata: ModuleLibraryMetadata;
|
|
1460
|
+
/** Module definition */
|
|
1461
|
+
readonly flags?: PackageFlags;
|
|
1301
1462
|
}
|
|
1302
1463
|
export interface LibraryInstance {
|
|
1303
1464
|
module: ModuleResolutionResult;
|
|
@@ -1324,9 +1485,9 @@ export interface FileLibraryMetadata extends LibraryMetadataBase {
|
|
|
1324
1485
|
}
|
|
1325
1486
|
/** Data for a library. Either loaded via a node_modules package or a standalone js file */
|
|
1326
1487
|
export interface ModuleLibraryMetadata extends LibraryMetadataBase {
|
|
1327
|
-
type: "module";
|
|
1488
|
+
readonly type: "module";
|
|
1328
1489
|
/** Library name as specified in the package.json or in exported $lib. */
|
|
1329
|
-
name: string;
|
|
1490
|
+
readonly name: string;
|
|
1330
1491
|
}
|
|
1331
1492
|
export interface TextRange {
|
|
1332
1493
|
/**
|
|
@@ -1347,7 +1508,7 @@ export interface SourceLocation extends TextRange {
|
|
|
1347
1508
|
/** Used to explicitly specify that a diagnostic has no target. */
|
|
1348
1509
|
export declare const NoTarget: unique symbol;
|
|
1349
1510
|
/** Diagnostic target that can be used when working with TypeSpec types. */
|
|
1350
|
-
export type TypeSpecDiagnosticTarget = Node |
|
|
1511
|
+
export type TypeSpecDiagnosticTarget = Node | Entity | Sym;
|
|
1351
1512
|
export type DiagnosticTarget = TypeSpecDiagnosticTarget | SourceLocation;
|
|
1352
1513
|
export type DiagnosticSeverity = "error" | "warning";
|
|
1353
1514
|
export interface Diagnostic {
|
|
@@ -1569,6 +1730,24 @@ export interface TypeSpecLibraryDef<T extends {
|
|
|
1569
1730
|
readonly linter?: LinterDefinition;
|
|
1570
1731
|
readonly state?: Record<State, StateDef>;
|
|
1571
1732
|
}
|
|
1733
|
+
export interface PackageFlags {
|
|
1734
|
+
/**
|
|
1735
|
+
* Decorator arg marshalling algorithm. Specify how TypeSpec values are marshalled to decorator arguments.
|
|
1736
|
+
* - `lossless` - New recommended behavior
|
|
1737
|
+
* - string value -> `string`
|
|
1738
|
+
* - numeric value -> `number` if the constraint can be represented as a JS number, Numeric otherwise(e.g. for types int64, decimal128, numeric, etc.)
|
|
1739
|
+
* - boolean value -> `boolean`
|
|
1740
|
+
* - null value -> `null`
|
|
1741
|
+
*
|
|
1742
|
+
* - `legacy` Behavior before version 0.56.0.
|
|
1743
|
+
* - string value -> `string`
|
|
1744
|
+
* - numeric value -> `number`
|
|
1745
|
+
* - boolean value -> `boolean`
|
|
1746
|
+
* - null value -> `NullType`
|
|
1747
|
+
* @default legacy
|
|
1748
|
+
*/
|
|
1749
|
+
readonly decoratorArgMarshalling?: "legacy" | "new";
|
|
1750
|
+
}
|
|
1572
1751
|
export interface LinterDefinition {
|
|
1573
1752
|
rules: LinterRuleDefinition<string, DiagnosticMessages>[];
|
|
1574
1753
|
ruleSets?: Record<string, LinterRuleSet>;
|