@typespec/compiler 1.18.0-dev.4 → 1.18.0-dev.6
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 +69 -1
- package/dist/generated-defs/TypeSpec.d.ts.map +1 -1
- package/dist/manifest.js +2 -2
- package/dist/src/config/config-to-options.d.ts +2 -0
- package/dist/src/config/config-to-options.d.ts.map +1 -1
- package/dist/src/config/config-to-options.js.map +1 -1
- package/dist/src/config/types.d.ts +26 -1
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/core/checker.d.ts +23 -0
- package/dist/src/core/checker.d.ts.map +1 -1
- package/dist/src/core/checker.js +7 -0
- package/dist/src/core/checker.js.map +1 -1
- package/dist/src/core/code-fixes.d.ts +6 -0
- package/dist/src/core/code-fixes.d.ts.map +1 -1
- package/dist/src/core/code-fixes.js +6 -0
- package/dist/src/core/code-fixes.js.map +1 -1
- package/dist/src/core/compiler-code-fixes/suppress.codefix.d.ts +7 -0
- package/dist/src/core/compiler-code-fixes/suppress.codefix.d.ts.map +1 -1
- package/dist/src/core/compiler-code-fixes/suppress.codefix.js +7 -0
- package/dist/src/core/compiler-code-fixes/suppress.codefix.js.map +1 -1
- package/dist/src/core/decorator-utils.d.ts +17 -0
- package/dist/src/core/decorator-utils.d.ts.map +1 -1
- package/dist/src/core/decorator-utils.js +5 -0
- package/dist/src/core/decorator-utils.js.map +1 -1
- package/dist/src/core/diagnostics.d.ts +9 -0
- package/dist/src/core/diagnostics.d.ts.map +1 -1
- package/dist/src/core/diagnostics.js +2 -0
- package/dist/src/core/diagnostics.js.map +1 -1
- package/dist/src/core/emitter-utils.d.ts +5 -0
- package/dist/src/core/emitter-utils.d.ts.map +1 -1
- package/dist/src/core/emitter-utils.js.map +1 -1
- package/dist/src/core/file-ref.d.ts +2 -0
- package/dist/src/core/file-ref.d.ts.map +1 -1
- package/dist/src/core/file-ref.js +1 -0
- package/dist/src/core/file-ref.js.map +1 -1
- package/dist/src/core/helpers/discriminator-utils.d.ts +14 -0
- package/dist/src/core/helpers/discriminator-utils.d.ts.map +1 -1
- package/dist/src/core/helpers/discriminator-utils.js +5 -0
- package/dist/src/core/helpers/discriminator-utils.js.map +1 -1
- package/dist/src/core/helpers/location-context.d.ts +1 -0
- package/dist/src/core/helpers/location-context.d.ts.map +1 -1
- package/dist/src/core/helpers/location-context.js +1 -0
- package/dist/src/core/helpers/location-context.js.map +1 -1
- package/dist/src/core/helpers/operation-utils.d.ts +1 -0
- package/dist/src/core/helpers/operation-utils.d.ts.map +1 -1
- package/dist/src/core/helpers/operation-utils.js.map +1 -1
- package/dist/src/core/helpers/type-name-utils.d.ts +7 -0
- package/dist/src/core/helpers/type-name-utils.d.ts.map +1 -1
- package/dist/src/core/helpers/type-name-utils.js +3 -0
- package/dist/src/core/helpers/type-name-utils.js.map +1 -1
- package/dist/src/core/helpers/usage-resolver.d.ts +9 -0
- package/dist/src/core/helpers/usage-resolver.d.ts.map +1 -1
- package/dist/src/core/helpers/usage-resolver.js +4 -0
- package/dist/src/core/helpers/usage-resolver.js.map +1 -1
- package/dist/src/core/intrinsic-type-state.d.ts +44 -17
- package/dist/src/core/intrinsic-type-state.d.ts.map +1 -1
- package/dist/src/core/intrinsic-type-state.js +41 -17
- package/dist/src/core/intrinsic-type-state.js.map +1 -1
- package/dist/src/core/library.d.ts +2 -0
- package/dist/src/core/library.d.ts.map +1 -1
- package/dist/src/core/library.js +2 -0
- package/dist/src/core/library.js.map +1 -1
- package/dist/src/core/logger/console-sink.d.ts +4 -0
- package/dist/src/core/logger/console-sink.d.ts.map +1 -1
- package/dist/src/core/logger/console-sink.js +1 -0
- package/dist/src/core/logger/console-sink.js.map +1 -1
- package/dist/src/core/numeric.d.ts +11 -1
- package/dist/src/core/numeric.d.ts.map +1 -1
- package/dist/src/core/numeric.js.map +1 -1
- package/dist/src/core/options.d.ts +8 -2
- package/dist/src/core/options.d.ts.map +1 -1
- package/dist/src/core/param-message.d.ts +9 -0
- package/dist/src/core/param-message.d.ts.map +1 -1
- package/dist/src/core/param-message.js +9 -0
- package/dist/src/core/param-message.js.map +1 -1
- package/dist/src/core/parser.d.ts +19 -0
- package/dist/src/core/parser.d.ts.map +1 -1
- package/dist/src/core/parser.js +18 -0
- package/dist/src/core/parser.js.map +1 -1
- package/dist/src/core/path-utils.d.ts +24 -0
- package/dist/src/core/path-utils.d.ts.map +1 -1
- package/dist/src/core/path-utils.js +9 -1
- package/dist/src/core/path-utils.js.map +1 -1
- package/dist/src/core/perf.d.ts +8 -1
- package/dist/src/core/perf.d.ts.map +1 -1
- package/dist/src/core/perf.js +8 -1
- package/dist/src/core/perf.js.map +1 -1
- package/dist/src/core/program.d.ts +31 -1
- package/dist/src/core/program.d.ts.map +1 -1
- package/dist/src/core/program.js +5 -0
- package/dist/src/core/program.js.map +1 -1
- package/dist/src/core/semantic-walker.d.ts +20 -5
- package/dist/src/core/semantic-walker.d.ts.map +1 -1
- package/dist/src/core/semantic-walker.js +13 -3
- package/dist/src/core/semantic-walker.js.map +1 -1
- package/dist/src/core/source-file.d.ts +2 -0
- package/dist/src/core/source-file.d.ts.map +1 -1
- package/dist/src/core/source-file.js +2 -0
- package/dist/src/core/source-file.js.map +1 -1
- package/dist/src/core/type-utils.d.ts +8 -0
- package/dist/src/core/type-utils.d.ts.map +1 -1
- package/dist/src/core/type-utils.js +8 -0
- package/dist/src/core/type-utils.js.map +1 -1
- package/dist/src/core/types.d.ts +1004 -46
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/types.js +130 -5
- package/dist/src/core/types.js.map +1 -1
- package/dist/src/experimental/mutators.d.ts +32 -3
- package/dist/src/experimental/mutators.d.ts.map +1 -1
- package/dist/src/experimental/mutators.js +11 -3
- package/dist/src/experimental/mutators.js.map +1 -1
- package/dist/src/experimental/realm.d.ts +34 -1
- package/dist/src/experimental/realm.d.ts.map +1 -1
- package/dist/src/experimental/realm.js +34 -1
- package/dist/src/experimental/realm.js.map +1 -1
- package/dist/src/init/core-templates.d.ts +3 -0
- package/dist/src/init/core-templates.d.ts.map +1 -1
- package/dist/src/init/core-templates.js.map +1 -1
- package/dist/src/init/init-template.d.ts +9 -0
- package/dist/src/init/init-template.d.ts.map +1 -1
- package/dist/src/init/init-template.js.map +1 -1
- package/dist/src/init/scaffold.d.ts +1 -0
- package/dist/src/init/scaffold.d.ts.map +1 -1
- package/dist/src/init/scaffold.js.map +1 -1
- package/dist/src/init/template-source/types.d.ts +2 -0
- package/dist/src/init/template-source/types.d.ts.map +1 -1
- package/dist/src/init/template-source/types.js.map +1 -1
- package/dist/src/lib/decorators.d.ts +84 -2
- package/dist/src/lib/decorators.d.ts.map +1 -1
- package/dist/src/lib/decorators.js +71 -7
- package/dist/src/lib/decorators.js.map +1 -1
- package/dist/src/lib/encoded-names.d.ts +4 -0
- package/dist/src/lib/encoded-names.d.ts.map +1 -1
- package/dist/src/lib/encoded-names.js +4 -0
- package/dist/src/lib/encoded-names.js.map +1 -1
- package/dist/src/lib/examples.d.ts +29 -2
- package/dist/src/lib/examples.d.ts.map +1 -1
- package/dist/src/lib/examples.js +25 -2
- package/dist/src/lib/examples.js.map +1 -1
- package/dist/src/lib/key.d.ts +2 -0
- package/dist/src/lib/key.d.ts.map +1 -1
- package/dist/src/lib/key.js +2 -0
- package/dist/src/lib/key.js.map +1 -1
- package/dist/src/lib/paging.d.ts +27 -0
- package/dist/src/lib/paging.d.ts.map +1 -1
- package/dist/src/lib/paging.js +7 -0
- package/dist/src/lib/paging.js.map +1 -1
- package/dist/src/lib/service.d.ts +9 -2
- package/dist/src/lib/service.d.ts.map +1 -1
- package/dist/src/lib/service.js +5 -2
- package/dist/src/lib/service.js.map +1 -1
- package/dist/src/lib/visibility.d.ts +44 -10
- package/dist/src/lib/visibility.d.ts.map +1 -1
- package/dist/src/lib/visibility.js +42 -10
- package/dist/src/lib/visibility.js.map +1 -1
- package/dist/src/manifest.d.ts +2 -0
- package/dist/src/manifest.d.ts.map +1 -1
- package/dist/src/manifest.js +1 -0
- package/dist/src/manifest.js.map +1 -1
- package/dist/src/module-resolver/module-resolver.d.ts +12 -1
- package/dist/src/module-resolver/module-resolver.d.ts.map +1 -1
- package/dist/src/module-resolver/module-resolver.js +7 -1
- package/dist/src/module-resolver/module-resolver.js.map +1 -1
- package/dist/src/module-resolver/types.d.ts +14 -1
- package/dist/src/module-resolver/types.d.ts.map +1 -1
- package/dist/src/server/client-config-provider.d.ts +14 -0
- package/dist/src/server/client-config-provider.d.ts.map +1 -1
- package/dist/src/server/client-config-provider.js.map +1 -1
- package/dist/src/server/server-compile-manager.d.ts +30 -4
- package/dist/src/server/server-compile-manager.d.ts.map +1 -1
- package/dist/src/server/server-compile-manager.js +21 -0
- package/dist/src/server/server-compile-manager.js.map +1 -1
- package/dist/src/server/serverlib.d.ts +9 -0
- package/dist/src/server/serverlib.d.ts.map +1 -1
- package/dist/src/server/serverlib.js +9 -0
- package/dist/src/server/serverlib.js.map +1 -1
- package/dist/src/server/types.d.ts +133 -0
- package/dist/src/server/types.d.ts.map +1 -1
- package/dist/src/server/types.js +26 -0
- package/dist/src/server/types.js.map +1 -1
- package/dist/src/server/update-manager.d.ts +24 -7
- package/dist/src/server/update-manager.d.ts.map +1 -1
- package/dist/src/server/update-manager.js +16 -7
- package/dist/src/server/update-manager.js.map +1 -1
- package/dist/src/testing/code-fix-testing.d.ts +2 -0
- package/dist/src/testing/code-fix-testing.d.ts.map +1 -1
- package/dist/src/testing/code-fix-testing.js.map +1 -1
- package/dist/src/testing/expect.d.ts +16 -10
- package/dist/src/testing/expect.d.ts.map +1 -1
- package/dist/src/testing/expect.js +9 -3
- package/dist/src/testing/expect.js.map +1 -1
- package/dist/src/testing/fourslash.d.ts +3 -3
- package/dist/src/testing/fourslash.d.ts.map +1 -1
- package/dist/src/testing/fs.d.ts +4 -0
- package/dist/src/testing/fs.d.ts.map +1 -1
- package/dist/src/testing/fs.js +4 -0
- package/dist/src/testing/fs.js.map +1 -1
- package/dist/src/testing/marked-template.d.ts +25 -2
- package/dist/src/testing/marked-template.d.ts.map +1 -1
- package/dist/src/testing/marked-template.js +7 -2
- package/dist/src/testing/marked-template.js.map +1 -1
- package/dist/src/testing/rule-tester.d.ts +22 -0
- package/dist/src/testing/rule-tester.d.ts.map +1 -1
- package/dist/src/testing/rule-tester.js +9 -0
- package/dist/src/testing/rule-tester.js.map +1 -1
- package/dist/src/testing/source-utils.d.ts +7 -2
- package/dist/src/testing/source-utils.d.ts.map +1 -1
- package/dist/src/testing/source-utils.js +2 -2
- package/dist/src/testing/source-utils.js.map +1 -1
- package/dist/src/testing/test-compiler-host.d.ts +8 -0
- package/dist/src/testing/test-compiler-host.d.ts.map +1 -1
- package/dist/src/testing/test-compiler-host.js +4 -0
- package/dist/src/testing/test-compiler-host.js.map +1 -1
- package/dist/src/testing/test-host.d.ts +4 -0
- package/dist/src/testing/test-host.d.ts.map +1 -1
- package/dist/src/testing/test-host.js +4 -0
- package/dist/src/testing/test-host.js.map +1 -1
- package/dist/src/testing/test-utils.d.ts +14 -2
- package/dist/src/testing/test-utils.d.ts.map +1 -1
- package/dist/src/testing/test-utils.js +9 -0
- package/dist/src/testing/test-utils.js.map +1 -1
- package/dist/src/testing/tester.d.ts +12 -0
- package/dist/src/testing/tester.d.ts.map +1 -1
- package/dist/src/testing/tester.js +7 -0
- package/dist/src/testing/tester.js.map +1 -1
- package/dist/src/testing/types.d.ts +101 -36
- package/dist/src/testing/types.d.ts.map +1 -1
- package/dist/src/testing/types.js +4 -1
- package/dist/src/testing/types.js.map +1 -1
- package/dist/src/typekit/define-kit.d.ts +6 -0
- package/dist/src/typekit/define-kit.d.ts.map +1 -1
- package/dist/src/typekit/define-kit.js.map +1 -1
- package/dist/src/typekit/kits/array.d.ts +3 -0
- package/dist/src/typekit/kits/array.d.ts.map +1 -1
- package/dist/src/typekit/kits/array.js.map +1 -1
- package/dist/src/typekit/kits/builtin.d.ts +3 -0
- package/dist/src/typekit/kits/builtin.d.ts.map +1 -1
- package/dist/src/typekit/kits/builtin.js.map +1 -1
- package/dist/src/typekit/kits/entity.d.ts +3 -0
- package/dist/src/typekit/kits/entity.d.ts.map +1 -1
- package/dist/src/typekit/kits/entity.js.map +1 -1
- package/dist/src/typekit/kits/enum-member.d.ts +3 -0
- package/dist/src/typekit/kits/enum-member.d.ts.map +1 -1
- package/dist/src/typekit/kits/enum-member.js.map +1 -1
- package/dist/src/typekit/kits/enum.d.ts +3 -0
- package/dist/src/typekit/kits/enum.d.ts.map +1 -1
- package/dist/src/typekit/kits/enum.js.map +1 -1
- package/dist/src/typekit/kits/intrinsic.d.ts +5 -0
- package/dist/src/typekit/kits/intrinsic.d.ts.map +1 -1
- package/dist/src/typekit/kits/intrinsic.js.map +1 -1
- package/dist/src/typekit/kits/model.d.ts +4 -0
- package/dist/src/typekit/kits/model.d.ts.map +1 -1
- package/dist/src/typekit/kits/model.js.map +1 -1
- package/dist/src/typekit/kits/record.d.ts +3 -0
- package/dist/src/typekit/kits/record.d.ts.map +1 -1
- package/dist/src/typekit/kits/record.js.map +1 -1
- package/dist/src/typekit/kits/scalar.d.ts +1 -1
- package/dist/src/typekit/kits/tuple.d.ts +5 -0
- package/dist/src/typekit/kits/tuple.d.ts.map +1 -1
- package/dist/src/typekit/kits/tuple.js.map +1 -1
- package/dist/src/typekit/kits/type.d.ts +5 -0
- package/dist/src/typekit/kits/type.d.ts.map +1 -1
- package/dist/src/typekit/kits/type.js.map +1 -1
- package/dist/src/typekit/kits/value.d.ts +8 -0
- package/dist/src/typekit/kits/value.d.ts.map +1 -1
- package/dist/src/typekit/kits/value.js.map +1 -1
- package/dist/src/types/package-json.d.ts +30 -0
- package/dist/src/types/package-json.d.ts.map +1 -1
- package/dist/src/utils/misc.d.ts +6 -0
- package/dist/src/utils/misc.d.ts.map +1 -1
- package/dist/src/utils/misc.js +6 -0
- package/dist/src/utils/misc.js.map +1 -1
- package/dist/src/utils/state-accessor.d.ts +10 -0
- package/dist/src/utils/state-accessor.d.ts.map +1 -1
- package/dist/src/utils/state-accessor.js +5 -0
- package/dist/src/utils/state-accessor.js.map +1 -1
- package/dist/src/yaml/types.d.ts +3 -0
- package/dist/src/yaml/types.d.ts.map +1 -1
- package/lib/std/decorators.tsp +16 -3
- package/lib/std/visibility.tsp +14 -0
- package/package.json +1 -1
package/dist/src/core/types.d.ts
CHANGED
|
@@ -3,23 +3,34 @@ import type { ModuleResolutionResult } from "../module-resolver/index.js";
|
|
|
3
3
|
import type { FileRef } from "./file-ref.js";
|
|
4
4
|
import type { Numeric } from "./numeric.js";
|
|
5
5
|
import type { Program } from "./program.js";
|
|
6
|
-
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
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* JavaScript-facing type mapping for compiler values.
|
|
8
|
+
* Numeric values may use {@link Numeric} to preserve precision, while scalar constructor values
|
|
9
|
+
* retain their compiler representation.
|
|
9
10
|
*/
|
|
11
|
+
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;
|
|
12
|
+
/** Type or primitive argument accepted by legacy decorator implementations. */
|
|
10
13
|
export type DecoratorArgumentValue = Type | number | string | boolean;
|
|
14
|
+
/** A checked decorator argument, retaining both its compiler entity and JavaScript representation. */
|
|
11
15
|
export interface DecoratorArgument {
|
|
16
|
+
/** Type or value before marshalling for the decorator implementation. */
|
|
12
17
|
value: Type | Value;
|
|
13
18
|
/**
|
|
14
19
|
* Marshalled value for use in Javascript.
|
|
15
20
|
*/
|
|
16
21
|
jsValue: Type | Value | Record<string, unknown> | unknown[] | string | number | boolean | Numeric | null;
|
|
22
|
+
/** Argument expression, when the application originates in TypeSpec source. */
|
|
17
23
|
node?: Node;
|
|
18
24
|
}
|
|
25
|
+
/** A decorator application attached to a type, including its checked arguments. */
|
|
19
26
|
export interface DecoratorApplication {
|
|
27
|
+
/** TypeSpec declaration, if the decorator has a corresponding declaration. */
|
|
20
28
|
definition?: Decorator;
|
|
29
|
+
/** JavaScript implementation invoked when the decorated type is finished. */
|
|
21
30
|
decorator: DecoratorFunction;
|
|
31
|
+
/** Custom arguments in call order, excluding the decorator context and target. */
|
|
22
32
|
args: DecoratorArgument[];
|
|
33
|
+
/** Source application, or absent for a programmatically constructed application. */
|
|
23
34
|
node?: DecoratorExpressionNode | AugmentDecoratorStatementNode;
|
|
24
35
|
}
|
|
25
36
|
/**
|
|
@@ -27,10 +38,14 @@ export interface DecoratorApplication {
|
|
|
27
38
|
* Use `@typespec/tspd` to generate an accurate signature from the `extern dec`
|
|
28
39
|
*/
|
|
29
40
|
export interface DecoratorFunction {
|
|
41
|
+
/** Apply the decorator to its target and optionally register deferred validation. */
|
|
30
42
|
(context: DecoratorContext, target: any, ...customArgs: any[]): DecoratorValidatorCallbacks | void;
|
|
43
|
+
/** Namespace associated with a JavaScript decorator export. */
|
|
31
44
|
namespace?: string;
|
|
32
45
|
}
|
|
46
|
+
/** Deferred decorator validation that returns diagnostics without mutating the type graph. */
|
|
33
47
|
export type ValidatorFn = () => readonly Diagnostic[];
|
|
48
|
+
/** Validation hooks returned by a decorator to run after target or graph construction. */
|
|
34
49
|
export interface DecoratorValidatorCallbacks {
|
|
35
50
|
/**
|
|
36
51
|
* Run validation after all decorators are run on the same type. Useful if trying to validate this decorator is compatible with other decorators without relying on the order they are applied.
|
|
@@ -43,11 +58,18 @@ export interface DecoratorValidatorCallbacks {
|
|
|
43
58
|
*/
|
|
44
59
|
readonly onGraphFinish?: ValidatorFn;
|
|
45
60
|
}
|
|
61
|
+
/** Common identity and construction state shared by semantic types in the compiler graph. */
|
|
46
62
|
export interface BaseType {
|
|
63
|
+
/** Distinguishes semantic types from values and parameter constraints. */
|
|
47
64
|
readonly entityKind: "Type";
|
|
65
|
+
/** Discriminant identifying the concrete semantic type. */
|
|
48
66
|
kind: string;
|
|
49
67
|
/** Node used to construct this type. If the node is undefined it means the type was dynamically built. With typekit for example. */
|
|
50
68
|
node?: Node;
|
|
69
|
+
/**
|
|
70
|
+
* Legacy instantiation metadata. The compiler's type checker does not populate this field,
|
|
71
|
+
* so its absence does not indicate whether this type is a template instance.
|
|
72
|
+
*/
|
|
51
73
|
instantiationParameters?: Type[];
|
|
52
74
|
/**
|
|
53
75
|
* If the type is currently being created.
|
|
@@ -62,20 +84,29 @@ export interface BaseType {
|
|
|
62
84
|
*/
|
|
63
85
|
isFinished: boolean;
|
|
64
86
|
}
|
|
87
|
+
/** A semantic type that can carry decorator applications. */
|
|
65
88
|
export interface DecoratedType {
|
|
89
|
+
/** Applications used when finishing this type, including copied or synthesized applications. */
|
|
66
90
|
decorators: DecoratorApplication[];
|
|
67
91
|
}
|
|
68
92
|
/**
|
|
69
93
|
* Union of all the types that implement TemplatedTypeBase
|
|
70
94
|
*/
|
|
71
95
|
export type TemplatedType = Model | Operation | Interface | Union | Scalar;
|
|
96
|
+
/** Substitutes template parameters with arguments while constructing a template instance. */
|
|
72
97
|
export interface TypeMapper {
|
|
98
|
+
/** Whether enclosing arguments have been applied but this template is not fully instantiated. */
|
|
73
99
|
partial: boolean;
|
|
100
|
+
/** Return the mapped argument, or the original parameter when no substitution is available. */
|
|
74
101
|
getMappedType(type: TemplateParameter): Type | Value | IndeterminateEntity;
|
|
102
|
+
/** Arguments for this instantiation, with enclosing template arguments first. */
|
|
75
103
|
args: readonly (Type | Value | IndeterminateEntity)[];
|
|
76
104
|
}
|
|
105
|
+
/** Instantiation metadata carried by types that support template parameters. */
|
|
77
106
|
export interface TemplatedTypeBase {
|
|
107
|
+
/** Argument substitutions for an instantiation; absent on an uninstantiated declaration. */
|
|
78
108
|
templateMapper?: TypeMapper;
|
|
109
|
+
/** Originating template node, when retained separately from the type's source node. */
|
|
79
110
|
templateNode?: Node;
|
|
80
111
|
}
|
|
81
112
|
/**
|
|
@@ -85,18 +116,29 @@ export interface TemplatedTypeBase {
|
|
|
85
116
|
* - Value Constraints
|
|
86
117
|
*/
|
|
87
118
|
export type Entity = Type | Value | MixedParameterConstraint | IndeterminateEntity;
|
|
119
|
+
/** Semantic type graph nodes, including declarations, members, literals, and template placeholders. */
|
|
88
120
|
export type Type = BooleanLiteral | Decorator | FunctionType | Enum | EnumMember | FunctionParameter | Interface | IntrinsicType | Model | ModelProperty | Namespace | NumericLiteral | Operation | Scalar | ScalarConstructor | StringLiteral | StringTemplate | StringTemplateSpan | TemplateParameter | TemplateParameterAccess | Tuple | Union | UnionVariant;
|
|
121
|
+
/** Standard-library types available by name through {@link Checker.getStdType}. */
|
|
89
122
|
export type StdTypes = {
|
|
123
|
+
/** Generic standard model for integer-indexed collections. */
|
|
90
124
|
Array: Model;
|
|
125
|
+
/** Generic standard model for string-indexed collections. */
|
|
91
126
|
Record: Model;
|
|
92
127
|
} & Record<IntrinsicScalarName, Scalar>;
|
|
128
|
+
/** Names accepted when looking up a standard-library type. */
|
|
93
129
|
export type StdTypeName = keyof StdTypes;
|
|
94
130
|
export interface ObjectType extends BaseType {
|
|
95
131
|
kind: "Object";
|
|
96
132
|
properties: Record<string, Type>;
|
|
97
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* A parameter constraint with independent type and value alternatives.
|
|
136
|
+
* A `valueof` alternative constrains a value's type rather than accepting the type itself.
|
|
137
|
+
*/
|
|
98
138
|
export interface MixedParameterConstraint {
|
|
139
|
+
/** Distinguishes this constraint from a type, value, or unresolved literal entity. */
|
|
99
140
|
readonly entityKind: "MixedParameterConstraint";
|
|
141
|
+
/** Source expression defining the constraint, when available. */
|
|
100
142
|
readonly node?: UnionExpressionNode | Expression;
|
|
101
143
|
/** Type constraints */
|
|
102
144
|
readonly type?: Type;
|
|
@@ -105,54 +147,84 @@ export interface MixedParameterConstraint {
|
|
|
105
147
|
}
|
|
106
148
|
/** When an entity that could be used as a type or value has not figured out if it is a value or type yet. */
|
|
107
149
|
export interface IndeterminateEntity {
|
|
150
|
+
/** Identifies an entity whose type-versus-value interpretation is not yet selected. */
|
|
108
151
|
readonly entityKind: "Indeterminate";
|
|
152
|
+
/** Literal-like type from which a type or value can be selected by the surrounding context. */
|
|
109
153
|
readonly type: StringLiteral | StringTemplate | NumericLiteral | BooleanLiteral | EnumMember | UnionVariant | NullType;
|
|
110
154
|
}
|
|
155
|
+
/** Compiler-defined special type, rather than a declaration in the standard library. */
|
|
111
156
|
export interface IntrinsicType extends BaseType {
|
|
157
|
+
/** Discriminant shared by the compiler's special types. */
|
|
112
158
|
kind: "Intrinsic";
|
|
159
|
+
/** Identifies the special type and its assignability semantics. */
|
|
113
160
|
name: "ErrorType" | "void" | "never" | "unknown" | "null";
|
|
114
161
|
}
|
|
162
|
+
/** Error-recovery type used when checking cannot produce a valid type. */
|
|
115
163
|
export interface ErrorType extends IntrinsicType {
|
|
116
164
|
name: "ErrorType";
|
|
117
165
|
}
|
|
166
|
+
/** An operation result with no return value. */
|
|
118
167
|
export interface VoidType extends IntrinsicType {
|
|
119
168
|
name: "void";
|
|
120
169
|
}
|
|
170
|
+
/** Bottom type with no possible values, assignable to every type. */
|
|
121
171
|
export interface NeverType extends IntrinsicType {
|
|
122
172
|
name: "never";
|
|
123
173
|
}
|
|
174
|
+
/** Top type accepting any type without imposing a more specific constraint. */
|
|
124
175
|
export interface UnknownType extends IntrinsicType {
|
|
125
176
|
name: "unknown";
|
|
126
177
|
}
|
|
178
|
+
/** Singleton type of the `null` value, distinct from an operation returning `void`. */
|
|
127
179
|
export interface NullType extends IntrinsicType {
|
|
128
180
|
name: "null";
|
|
129
181
|
}
|
|
182
|
+
/** Names of the built-in scalars exposed through the compiler's standard-type lookup. */
|
|
130
183
|
export type IntrinsicScalarName = "bytes" | "numeric" | "integer" | "float" | "int64" | "int32" | "int16" | "int8" | "uint64" | "uint32" | "uint16" | "uint8" | "safeint" | "float32" | "float64" | "decimal" | "decimal128" | "string" | "plainDate" | "plainTime" | "utcDateTime" | "offsetDateTime" | "duration" | "boolean" | "url";
|
|
184
|
+
/** An indexer shape that admits no keys and consequently has no value type. */
|
|
131
185
|
export type NeverIndexer = {
|
|
186
|
+
/** Bottom type, allowing no indexed keys. */
|
|
132
187
|
readonly key: NeverType;
|
|
188
|
+
/** No value type exists for an indexer without keys. */
|
|
133
189
|
readonly value: undefined;
|
|
134
190
|
};
|
|
191
|
+
/** Key and element constraints for an indexed model such as an array or record. */
|
|
135
192
|
export type ModelIndexer = {
|
|
193
|
+
/** Scalar constraining keys; standard arrays use `integer` and records use `string`. */
|
|
136
194
|
readonly key: Scalar;
|
|
195
|
+
/** Type required for indexed values. */
|
|
137
196
|
readonly value: Type;
|
|
138
197
|
};
|
|
198
|
+
/** Model narrowed by {@link isArrayModelType} to have an integer-keyed indexer. */
|
|
139
199
|
export interface ArrayModelType extends Model {
|
|
200
|
+
/** Indexer describing the array's element type. */
|
|
140
201
|
indexer: {
|
|
202
|
+
/** Integer key scalar used for array positions. */
|
|
141
203
|
key: Scalar;
|
|
204
|
+
/** Type of each array element. */
|
|
142
205
|
value: Type;
|
|
143
206
|
};
|
|
144
207
|
}
|
|
208
|
+
/** Model narrowed by {@link isRecordModelType} to have a string-keyed indexer. */
|
|
145
209
|
export interface RecordModelType extends Model {
|
|
210
|
+
/** Indexer describing values associated with record keys. */
|
|
146
211
|
indexer: {
|
|
212
|
+
/** String key scalar used for record entries. */
|
|
147
213
|
key: Scalar;
|
|
214
|
+
/** Type of each record entry. */
|
|
148
215
|
value: Type;
|
|
149
216
|
};
|
|
150
217
|
}
|
|
218
|
+
/** Structured type with ordered own properties, optional indexing, and model inheritance. */
|
|
151
219
|
export interface Model extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
220
|
+
/** Discriminant for structured model types. */
|
|
152
221
|
kind: "Model";
|
|
222
|
+
/** Declared name, or an empty string for an anonymous model. */
|
|
153
223
|
name: string;
|
|
154
224
|
node?: ModelStatementNode | ModelDeclarationExpressionNode | ModelExpressionNode | IntersectionExpressionNode | ObjectLiteralNode;
|
|
225
|
+
/** Namespace containing a named declaration, when associated with one. */
|
|
155
226
|
namespace?: Namespace;
|
|
227
|
+
/** Constraint on indexed entries, if this model supports indexing. */
|
|
156
228
|
indexer?: ModelIndexer;
|
|
157
229
|
/**
|
|
158
230
|
* Whether this model was declared in expression position (e.g. an anonymous
|
|
@@ -189,6 +261,7 @@ export interface Model extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
|
189
261
|
*/
|
|
190
262
|
sourceModels: SourceModel[];
|
|
191
263
|
}
|
|
264
|
+
/** Records a model-composition input separately from the model's inheritance relationship. */
|
|
192
265
|
export interface SourceModel {
|
|
193
266
|
/**
|
|
194
267
|
* How was this model used.
|
|
@@ -202,19 +275,34 @@ export interface SourceModel {
|
|
|
202
275
|
/** Node where this source model was referenced. */
|
|
203
276
|
readonly node?: Node;
|
|
204
277
|
}
|
|
278
|
+
/** A named model field, including copied fields introduced by composition. */
|
|
205
279
|
export interface ModelProperty extends BaseType, DecoratedType {
|
|
280
|
+
/** Discriminant for model fields and operation parameters. */
|
|
206
281
|
kind: "ModelProperty";
|
|
207
282
|
node?: ModelPropertyNode | ModelSpreadPropertyNode | ObjectLiteralPropertyNode;
|
|
283
|
+
/** Key under which this property appears in its containing model. */
|
|
208
284
|
name: string;
|
|
285
|
+
/** Type of values accepted by the property, independent of optionality. */
|
|
209
286
|
type: Type;
|
|
287
|
+
/** Property copied to create this one through composition, when applicable. */
|
|
210
288
|
sourceProperty?: ModelProperty;
|
|
289
|
+
/** Whether the property may be omitted; this does not add `null` to its type. */
|
|
211
290
|
optional: boolean;
|
|
291
|
+
/** Checked default value, when a default was supplied. */
|
|
212
292
|
defaultValue?: Value;
|
|
293
|
+
/** Containing model, when attached; copied properties belong to the receiving model. */
|
|
213
294
|
model?: Model;
|
|
214
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* A checked TypeSpec value, distinct from the {@link Type} describing what values are allowed.
|
|
298
|
+
* Narrow with `valueKind` to inspect primitive payloads, collection contents, or constructor calls.
|
|
299
|
+
*/
|
|
215
300
|
export type Value = ScalarValue | NumericValue | StringValue | BooleanValue | ObjectValue | ArrayValue | EnumValue | NullValue | FunctionValue;
|
|
301
|
+
/** Common identity and storage-type metadata inherited by checked values. */
|
|
216
302
|
interface BaseValue {
|
|
303
|
+
/** Distinguishes a concrete value from a type or parameter constraint. */
|
|
217
304
|
readonly entityKind: "Value";
|
|
305
|
+
/** Discriminant identifying how the value's contents are represented. */
|
|
218
306
|
readonly valueKind: string;
|
|
219
307
|
/**
|
|
220
308
|
* Represent the storage type of a value.
|
|
@@ -227,54 +315,93 @@ interface BaseValue {
|
|
|
227
315
|
*/
|
|
228
316
|
type: Type;
|
|
229
317
|
}
|
|
318
|
+
/** An object value with checked named entries, rather than a model type's property declarations. */
|
|
230
319
|
export interface ObjectValue extends BaseValue {
|
|
320
|
+
/** Discriminant for object contents stored in a property map. */
|
|
231
321
|
valueKind: "ObjectValue";
|
|
322
|
+
/** Object literal that produced the value, when available. */
|
|
232
323
|
node?: ObjectLiteralNode;
|
|
324
|
+
/** Actual entries keyed by property name; each descriptor contains a value, not a property type. */
|
|
233
325
|
properties: Map<string, ObjectValuePropertyDescriptor>;
|
|
234
326
|
}
|
|
327
|
+
/** One named entry in an {@link ObjectValue}, with its checked value and optional source. */
|
|
235
328
|
export interface ObjectValuePropertyDescriptor {
|
|
329
|
+
/** Property syntax that supplied this entry, when available. */
|
|
236
330
|
node?: ObjectLiteralPropertyNode;
|
|
331
|
+
/** Entry name matching its key in the containing object's property map. */
|
|
237
332
|
name: string;
|
|
333
|
+
/** Checked contents of the entry. */
|
|
238
334
|
value: Value;
|
|
239
335
|
}
|
|
336
|
+
/** An array value containing checked elements, distinct from an array model or tuple type. */
|
|
240
337
|
export interface ArrayValue extends BaseValue {
|
|
338
|
+
/** Discriminant for array contents stored as an element list. */
|
|
241
339
|
valueKind: "ArrayValue";
|
|
340
|
+
/** Array literal that produced the value, when available. */
|
|
242
341
|
node?: ArrayLiteralNode;
|
|
342
|
+
/** Element values in array order. */
|
|
243
343
|
values: Value[];
|
|
244
344
|
}
|
|
345
|
+
/** A scalar constructor call retained as a scalar, constructor name, and checked arguments. */
|
|
245
346
|
export interface ScalarValue extends BaseValue {
|
|
347
|
+
/** Discriminant for a retained constructor call rather than a primitive payload. */
|
|
246
348
|
valueKind: "ScalarValue";
|
|
349
|
+
/** Scalar instantiated by the constructor call. */
|
|
247
350
|
scalar: Scalar;
|
|
351
|
+
/** Constructor invocation used to create the value. */
|
|
248
352
|
value: {
|
|
353
|
+
/** Constructor name on the scalar. */
|
|
249
354
|
name: string;
|
|
355
|
+
/** Checked arguments in call order. */
|
|
250
356
|
args: Value[];
|
|
251
357
|
};
|
|
252
358
|
}
|
|
359
|
+
/** A numeric value whose exact contents are preserved independently of JavaScript number precision. */
|
|
253
360
|
export interface NumericValue extends BaseValue {
|
|
361
|
+
/** Discriminant for an exact numeric payload. */
|
|
254
362
|
valueKind: "NumericValue";
|
|
363
|
+
/** Selected numeric scalar, or undefined for a literal without an inferred or explicit scalar. */
|
|
255
364
|
scalar: Scalar | undefined;
|
|
365
|
+
/** Exact numeric contents; use Numeric conversion methods when a JavaScript number is needed. */
|
|
256
366
|
value: Numeric;
|
|
257
367
|
}
|
|
368
|
+
/** A string value, optionally associated with a scalar selected by its context or construction. */
|
|
258
369
|
export interface StringValue extends BaseValue {
|
|
370
|
+
/** Discriminant for a JavaScript string payload. */
|
|
259
371
|
valueKind: "StringValue";
|
|
372
|
+
/** Selected string scalar, or undefined when the value has no scalar association. */
|
|
260
373
|
scalar: Scalar | undefined;
|
|
374
|
+
/** String contents, independent of the value's storage type. */
|
|
261
375
|
value: string;
|
|
262
376
|
}
|
|
377
|
+
/** A boolean value, optionally associated with a scalar selected by its context or construction. */
|
|
263
378
|
export interface BooleanValue extends BaseValue {
|
|
379
|
+
/** Discriminant for a JavaScript boolean payload. */
|
|
264
380
|
valueKind: "BooleanValue";
|
|
381
|
+
/** Selected boolean scalar, or undefined when the value has no scalar association. */
|
|
265
382
|
scalar: Scalar | undefined;
|
|
383
|
+
/** Boolean contents, independent of the value's storage type. */
|
|
266
384
|
value: boolean;
|
|
267
385
|
}
|
|
386
|
+
/** A value referring to an enum member, retaining member identity rather than only its assigned value. */
|
|
268
387
|
export interface EnumValue extends BaseValue {
|
|
388
|
+
/** Discriminant for a value backed by an enum member. */
|
|
269
389
|
valueKind: "EnumValue";
|
|
390
|
+
/** Referenced member, including its owning enum and any explicit string or numeric value. */
|
|
270
391
|
value: EnumMember;
|
|
271
392
|
}
|
|
393
|
+
/** The concrete null value, distinct from the intrinsic type used to describe it. */
|
|
272
394
|
export interface NullValue extends BaseValue {
|
|
395
|
+
/** Discriminant for the null payload. */
|
|
273
396
|
valueKind: "NullValue";
|
|
397
|
+
/** Null contents; absence of a value is not represented by this field being undefined. */
|
|
274
398
|
value: null;
|
|
275
399
|
}
|
|
400
|
+
/** A scalar declaration or expression, with optional scalar inheritance and named constructors. */
|
|
276
401
|
export interface Scalar extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
402
|
+
/** Discriminant for scalar types rather than scalar values. */
|
|
277
403
|
kind: "Scalar";
|
|
404
|
+
/** Declared name, or an empty string for an anonymous scalar expression. */
|
|
278
405
|
name: string;
|
|
279
406
|
node?: ScalarStatementNode | ScalarDeclarationExpressionNode;
|
|
280
407
|
/**
|
|
@@ -294,19 +421,29 @@ export interface Scalar extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
|
294
421
|
* Direct children. This is the reverse relation of @see baseScalar
|
|
295
422
|
*/
|
|
296
423
|
derivedScalars: Scalar[];
|
|
424
|
+
/** Constructors keyed by name, including inherited constructors rebound to this scalar. */
|
|
297
425
|
constructors: Map<string, ScalarConstructor>;
|
|
298
426
|
}
|
|
427
|
+
/** A named scalar initializer whose checked call produces a value of its associated scalar. */
|
|
299
428
|
export interface ScalarConstructor extends BaseType {
|
|
429
|
+
/** Discriminant for scalar initializer signatures. */
|
|
300
430
|
kind: "ScalarConstructor";
|
|
301
431
|
node?: ScalarConstructorNode;
|
|
432
|
+
/** Initializer name used after the scalar name in a constructor call. */
|
|
302
433
|
name: string;
|
|
434
|
+
/** Scalar constructed by this signature, including when the signature was inherited. */
|
|
303
435
|
scalar: Scalar;
|
|
436
|
+
/** Parameter constraints in declaration order, including optional and rest parameters. */
|
|
304
437
|
parameters: SignatureFunctionParameter[];
|
|
305
438
|
}
|
|
439
|
+
/** A named collection of operations, including operations copied from extended interfaces. */
|
|
306
440
|
export interface Interface extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
441
|
+
/** Discriminant for operation containers. */
|
|
307
442
|
kind: "Interface";
|
|
443
|
+
/** Local declaration name, excluding its namespace path. */
|
|
308
444
|
name: string;
|
|
309
445
|
node?: InterfaceStatementNode;
|
|
446
|
+
/** Containing namespace, when associated with a namespace. */
|
|
310
447
|
namespace?: Namespace;
|
|
311
448
|
/**
|
|
312
449
|
* The interfaces that provide additional operations via `interface extends`.
|
|
@@ -326,10 +463,14 @@ export interface Interface extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
|
326
463
|
*/
|
|
327
464
|
operations: RekeyableMap<string, Operation>;
|
|
328
465
|
}
|
|
466
|
+
/** An ordered set of named members with optional explicit string or numeric values. */
|
|
329
467
|
export interface Enum extends BaseType, DecoratedType {
|
|
468
|
+
/** Discriminant for enum types rather than individual members. */
|
|
330
469
|
kind: "Enum";
|
|
470
|
+
/** Declared name, or an empty string for an anonymous enum expression. */
|
|
331
471
|
name: string;
|
|
332
472
|
node?: EnumStatementNode | EnumDeclarationExpressionNode;
|
|
473
|
+
/** Containing namespace, when associated with a namespace. */
|
|
333
474
|
namespace?: Namespace;
|
|
334
475
|
/**
|
|
335
476
|
* Whether this enum was declared in expression position (anonymous `enum { ... }`)
|
|
@@ -344,11 +485,16 @@ export interface Enum extends BaseType, DecoratedType {
|
|
|
344
485
|
*/
|
|
345
486
|
members: RekeyableMap<string, EnumMember>;
|
|
346
487
|
}
|
|
488
|
+
/** A named enum entry retaining both its owning enum and any spread source. */
|
|
347
489
|
export interface EnumMember extends BaseType, DecoratedType {
|
|
490
|
+
/** Discriminant for a member declaration rather than an enum value wrapper. */
|
|
348
491
|
kind: "EnumMember";
|
|
492
|
+
/** Member name, distinct from any explicitly assigned value. */
|
|
349
493
|
name: string;
|
|
494
|
+
/** Owning enum; spread copies belong to the receiving enum. */
|
|
350
495
|
enum: Enum;
|
|
351
496
|
node?: EnumMemberNode;
|
|
497
|
+
/** Explicitly assigned value, or undefined for a member declared with only a name. */
|
|
352
498
|
value?: string | number;
|
|
353
499
|
/**
|
|
354
500
|
* when spread operators make new enum members,
|
|
@@ -356,22 +502,33 @@ export interface EnumMember extends BaseType, DecoratedType {
|
|
|
356
502
|
*/
|
|
357
503
|
sourceMember?: EnumMember;
|
|
358
504
|
}
|
|
505
|
+
/** A callable API signature, declared in a namespace or owned by an interface. */
|
|
359
506
|
export interface Operation extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
507
|
+
/** Discriminant for API operation signatures rather than TypeSpec function values. */
|
|
360
508
|
kind: "Operation";
|
|
361
509
|
node?: OperationStatementNode;
|
|
510
|
+
/** Local operation name, excluding namespace and interface qualifiers. */
|
|
362
511
|
name: string;
|
|
512
|
+
/** Containing namespace, including for operations declared inside an interface. */
|
|
363
513
|
namespace?: Namespace;
|
|
514
|
+
/** Owning interface, or absent for a namespace-level operation. */
|
|
364
515
|
interface?: Interface;
|
|
516
|
+
/** Model whose properties describe the operation's ordered parameters. */
|
|
365
517
|
parameters: Model;
|
|
518
|
+
/** Result type, including the `void` intrinsic for an operation without a return value. */
|
|
366
519
|
returnType: Type;
|
|
367
520
|
/**
|
|
368
521
|
* The operation that is referenced via `op is`.
|
|
369
522
|
*/
|
|
370
523
|
sourceOperation?: Operation;
|
|
371
524
|
}
|
|
525
|
+
/** A declaration container; nested namespaces link to their parent and the global namespace is unnamed. */
|
|
372
526
|
export interface Namespace extends BaseType, DecoratedType {
|
|
527
|
+
/** Discriminant for namespace containers rather than their declarations. */
|
|
373
528
|
kind: "Namespace";
|
|
529
|
+
/** Local namespace segment, or an empty string for the global namespace. */
|
|
374
530
|
name: string;
|
|
531
|
+
/** Parent namespace; absent on the global namespace. */
|
|
375
532
|
namespace?: Namespace;
|
|
376
533
|
node?: NamespaceStatementNode | JsNamespaceDeclarationNode;
|
|
377
534
|
/**
|
|
@@ -429,53 +586,84 @@ export interface Namespace extends BaseType, DecoratedType {
|
|
|
429
586
|
*/
|
|
430
587
|
functionDeclarations: Map<string, FunctionValue>;
|
|
431
588
|
}
|
|
589
|
+
/** Singleton primitive types, distinct from the corresponding checked value objects. */
|
|
432
590
|
export type LiteralType = StringLiteral | NumericLiteral | BooleanLiteral;
|
|
591
|
+
/** Singleton type accepting exactly one string. */
|
|
433
592
|
export interface StringLiteral extends BaseType {
|
|
593
|
+
/** Discriminant for string literal types, not the `string` scalar. */
|
|
434
594
|
kind: "String";
|
|
435
595
|
node?: StringLiteralNode;
|
|
596
|
+
/** String accepted by this singleton type. */
|
|
436
597
|
value: string;
|
|
437
598
|
}
|
|
599
|
+
/** Singleton numeric type retaining exact numeric contents alongside a JavaScript projection. */
|
|
438
600
|
export interface NumericLiteral extends BaseType {
|
|
601
|
+
/** Discriminant for numeric literal types, not numeric scalar declarations. */
|
|
439
602
|
kind: "Number";
|
|
440
603
|
node?: NumericLiteralNode;
|
|
604
|
+
/** JavaScript numeric projection; use numericValue when precision or range matters. */
|
|
441
605
|
value: number;
|
|
606
|
+
/** Exact numeric contents, without JavaScript number rounding. */
|
|
442
607
|
numericValue: Numeric;
|
|
608
|
+
/** Source spelling, or synthesized numeric text for a programmatically created literal. */
|
|
443
609
|
valueAsString: string;
|
|
444
610
|
}
|
|
611
|
+
/** Singleton type accepting exactly one boolean. */
|
|
445
612
|
export interface BooleanLiteral extends BaseType {
|
|
613
|
+
/** Discriminant for boolean literal types, not the `boolean` scalar. */
|
|
446
614
|
kind: "Boolean";
|
|
447
615
|
node?: BooleanLiteralNode;
|
|
616
|
+
/** Boolean accepted by this singleton type. */
|
|
448
617
|
value: boolean;
|
|
449
618
|
}
|
|
619
|
+
/** A string template type retaining its literal text and interpolated types as separate spans. */
|
|
450
620
|
export interface StringTemplate extends BaseType {
|
|
621
|
+
/** Discriminant for a template type rather than a concrete string value. */
|
|
451
622
|
kind: "StringTemplate";
|
|
452
623
|
/** If the template can be render as as string this is the string value */
|
|
453
624
|
stringValue?: string;
|
|
454
625
|
node?: StringTemplateExpressionNode;
|
|
626
|
+
/** Text and interpolated types in source order, including any empty text spans. */
|
|
455
627
|
spans: StringTemplateSpan[];
|
|
456
628
|
}
|
|
629
|
+
/** One part of a string template, narrowed by isInterpolated rather than by kind. */
|
|
457
630
|
export type StringTemplateSpan = StringTemplateSpanLiteral | StringTemplateSpanValue;
|
|
631
|
+
/** Literal text between interpolations in a string template. */
|
|
458
632
|
export interface StringTemplateSpanLiteral extends BaseType {
|
|
633
|
+
/** Shared span discriminant; use isInterpolated to distinguish text from interpolation. */
|
|
459
634
|
kind: "StringTemplateSpan";
|
|
460
635
|
node?: StringTemplateHeadNode | StringTemplateMiddleNode | StringTemplateTailNode;
|
|
636
|
+
/** Marks source text rather than an interpolated expression, even when the text is empty. */
|
|
461
637
|
isInterpolated: false;
|
|
638
|
+
/** Singleton string type holding this span's text. */
|
|
462
639
|
type: StringLiteral;
|
|
463
640
|
}
|
|
641
|
+
/** An interpolated type in a string template, including interpolated string literal types. */
|
|
464
642
|
export interface StringTemplateSpanValue extends BaseType {
|
|
643
|
+
/** Shared span discriminant; use isInterpolated to distinguish interpolation from text. */
|
|
465
644
|
kind: "StringTemplateSpan";
|
|
466
645
|
node?: Expression;
|
|
646
|
+
/** Marks an interpolation even when its type is a string literal. */
|
|
467
647
|
isInterpolated: true;
|
|
648
|
+
/** Interpolated type, which may not be renderable as a concrete string. */
|
|
468
649
|
type: Type;
|
|
469
650
|
}
|
|
651
|
+
/** A fixed sequence of element types, distinct from an array value or indexed model. */
|
|
470
652
|
export interface Tuple extends BaseType {
|
|
653
|
+
/** Discriminant for tuple types rather than array values. */
|
|
471
654
|
kind: "Tuple";
|
|
472
655
|
node?: TupleExpressionNode | ArrayLiteralNode;
|
|
656
|
+
/** Element types in tuple position order. */
|
|
473
657
|
values: Type[];
|
|
474
658
|
}
|
|
659
|
+
/** Alternatives described by ordered variants, from either a union declaration or an expression. */
|
|
475
660
|
export interface Union extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
661
|
+
/** Discriminant for a union of types rather than a single variant. */
|
|
476
662
|
kind: "Union";
|
|
663
|
+
/** Declared name, when present; expression unions can also retain a declaration-expression name. */
|
|
477
664
|
name?: string;
|
|
478
665
|
node?: UnionExpressionNode | UnionStatementNode | UnionDeclarationExpressionNode;
|
|
666
|
+
/** Containing namespace, when associated with a namespace. */
|
|
479
667
|
namespace?: Namespace;
|
|
480
668
|
/**
|
|
481
669
|
* The variants of the union.
|
|
@@ -483,6 +671,7 @@ export interface Union extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
|
483
671
|
* Variants are ordered in order that they appear in source.
|
|
484
672
|
*/
|
|
485
673
|
variants: RekeyableMap<string | symbol, UnionVariant>;
|
|
674
|
+
/** Whether the union is used in expression position, including both `A | B` and `union { ... }`. */
|
|
486
675
|
expression: boolean;
|
|
487
676
|
/**
|
|
488
677
|
* Type declared with the `extends` clause of a union statement. Union variants are
|
|
@@ -503,11 +692,16 @@ export interface Union extends BaseType, DecoratedType, TemplatedTypeBase {
|
|
|
503
692
|
*/
|
|
504
693
|
baseType?: Model | Scalar | Enum | Union;
|
|
505
694
|
}
|
|
695
|
+
/** One alternative of a union, with either a declared name or an anonymous symbol key. */
|
|
506
696
|
export interface UnionVariant extends BaseType, DecoratedType {
|
|
697
|
+
/** Discriminant for a union alternative rather than the alternative's value type. */
|
|
507
698
|
kind: "UnionVariant";
|
|
699
|
+
/** Declared variant name, or a unique symbol for an unnamed alternative. */
|
|
508
700
|
name: string | symbol;
|
|
509
701
|
node?: UnionVariantNode | undefined;
|
|
702
|
+
/** Type accepted by this alternative. */
|
|
510
703
|
type: Type;
|
|
704
|
+
/** Owning union; flattened union expressions can reuse variants owned by another union. */
|
|
511
705
|
union: Union;
|
|
512
706
|
}
|
|
513
707
|
/**
|
|
@@ -518,6 +712,7 @@ export interface UnionVariant extends BaseType, DecoratedType {
|
|
|
518
712
|
* @experimental
|
|
519
713
|
*/
|
|
520
714
|
export interface TemplateParameter extends BaseType {
|
|
715
|
+
/** Discriminant for an unresolved template parameter rather than a substituted argument. */
|
|
521
716
|
kind: "TemplateParameter";
|
|
522
717
|
}
|
|
523
718
|
/**
|
|
@@ -531,15 +726,23 @@ export interface TemplateParameter extends BaseType {
|
|
|
531
726
|
* @experimental
|
|
532
727
|
*/
|
|
533
728
|
export interface TemplateParameterAccess extends BaseType {
|
|
729
|
+
/** Discriminant for unresolved member access rooted in a template parameter. */
|
|
534
730
|
kind: "TemplateParameterAccess";
|
|
535
731
|
}
|
|
732
|
+
/** A checked TypeSpec decorator declaration, distinct from an application of that decorator. */
|
|
536
733
|
export interface Decorator extends BaseType {
|
|
734
|
+
/** Discriminant for decorator declarations rather than decorator applications. */
|
|
537
735
|
kind: "Decorator";
|
|
538
736
|
node?: DecoratorDeclarationStatementNode;
|
|
737
|
+
/** Local decorator name including its leading `@`, without namespace qualifiers. */
|
|
539
738
|
name: `@${string}`;
|
|
739
|
+
/** Declaring namespace, including the global namespace for unqualified declarations. */
|
|
540
740
|
namespace: Namespace;
|
|
741
|
+
/** Constraint on the decorated target, separate from custom arguments. */
|
|
541
742
|
target: MixedFunctionParameter;
|
|
743
|
+
/** Custom parameter constraints in declaration order, excluding the target. */
|
|
542
744
|
parameters: MixedFunctionParameter[];
|
|
745
|
+
/** JavaScript implementation receiving the context, target, and marshalled custom arguments. */
|
|
543
746
|
implementation: (ctx: DecoratorContext, target: Type, ...args: unknown[]) => void;
|
|
544
747
|
/** How this decorator was declared. */
|
|
545
748
|
declarationKind: "extern" | "auto";
|
|
@@ -548,6 +751,7 @@ export interface Decorator extends BaseType {
|
|
|
548
751
|
* The type of a Function in TypeSpec.
|
|
549
752
|
*/
|
|
550
753
|
export interface FunctionType extends BaseType {
|
|
754
|
+
/** Discriminant for a function signature constraint rather than a callable function value. */
|
|
551
755
|
kind: "FunctionType";
|
|
552
756
|
/**
|
|
553
757
|
* The parameter constraints of the function.
|
|
@@ -582,7 +786,9 @@ export interface FunctionType extends BaseType {
|
|
|
582
786
|
* ```
|
|
583
787
|
*/
|
|
584
788
|
export interface FunctionValue<Parameters extends unknown[] = never[], ReturnType = unknown> extends BaseValue {
|
|
789
|
+
/** Discriminant for callable function values rather than data values. */
|
|
585
790
|
valueKind: "Function";
|
|
791
|
+
/** Source `fn` declaration, when the function originates in a declaration. */
|
|
586
792
|
node?: FunctionDeclarationStatementNode;
|
|
587
793
|
/**
|
|
588
794
|
* The function's name as declared in the TypeSpec source, if any.
|
|
@@ -613,7 +819,9 @@ export interface FunctionValue<Parameters extends unknown[] = never[], ReturnTyp
|
|
|
613
819
|
*/
|
|
614
820
|
implementation: (ctx: FunctionContext, ...args: Parameters) => ReturnType;
|
|
615
821
|
}
|
|
822
|
+
/** Signature entry shared by function, decorator, and scalar-constructor parameters. */
|
|
616
823
|
export interface FunctionParameterBase extends BaseType {
|
|
824
|
+
/** Shared parameter discriminant; mixed selects the constraint representation. */
|
|
617
825
|
kind: "FunctionParameter";
|
|
618
826
|
node?: FunctionParameterNode;
|
|
619
827
|
/**
|
|
@@ -633,21 +841,31 @@ export interface FunctionParameterBase extends BaseType {
|
|
|
633
841
|
* A function parameter with a mixed parameter constraint that could accept a value.
|
|
634
842
|
*/
|
|
635
843
|
export interface MixedFunctionParameter extends FunctionParameterBase {
|
|
844
|
+
/** Selects independent type and value alternatives instead of a simple type constraint. */
|
|
636
845
|
mixed: true;
|
|
846
|
+
/** Constraint describing the types or values that may be supplied. */
|
|
637
847
|
type: MixedParameterConstraint;
|
|
638
848
|
}
|
|
639
849
|
/**
|
|
640
850
|
* A function parameter with a simple type constraint.
|
|
641
851
|
*/
|
|
642
852
|
export interface SignatureFunctionParameter extends FunctionParameterBase {
|
|
853
|
+
/** Selects a single type constraint instead of mixed type and value alternatives. */
|
|
643
854
|
mixed: false;
|
|
855
|
+
/** Type required for values supplied to this signature parameter. */
|
|
644
856
|
type: Type;
|
|
645
857
|
}
|
|
646
858
|
/**
|
|
647
859
|
* A function parameter.
|
|
648
860
|
*/
|
|
649
861
|
export type FunctionParameter = MixedFunctionParameter | SignatureFunctionParameter;
|
|
862
|
+
/**
|
|
863
|
+
* Binding identity used for name lookup before and during type checking.
|
|
864
|
+
* Declaration symbols collect contributing nodes in `declarations`; expression and
|
|
865
|
+
* late-bound symbols instead use `node` or `type`.
|
|
866
|
+
*/
|
|
650
867
|
export interface Sym {
|
|
868
|
+
/** Combined category, visibility, and binding-state bits for this symbol. */
|
|
651
869
|
readonly flags: SymbolFlags;
|
|
652
870
|
/**
|
|
653
871
|
* Nodes which contribute to this declaration, present if SymbolFlags.Declaration is set.
|
|
@@ -683,7 +901,7 @@ export interface Sym {
|
|
|
683
901
|
*/
|
|
684
902
|
readonly members?: SymbolTable;
|
|
685
903
|
/**
|
|
686
|
-
*
|
|
904
|
+
* Metatype members selected with `::`, such as an operation's `parameters`.
|
|
687
905
|
*/
|
|
688
906
|
readonly metatypeMembers?: SymbolTable;
|
|
689
907
|
/**
|
|
@@ -803,32 +1021,54 @@ export interface MutableSymbolTable extends SymbolTable {
|
|
|
803
1021
|
*/
|
|
804
1022
|
include(source: SymbolTable, parentSym?: Sym): void;
|
|
805
1023
|
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Bit flags describing a symbol's category and how it is bound.
|
|
1026
|
+
* Category bits may be combined with flags such as `Declaration`, `Member`, or `Internal`.
|
|
1027
|
+
*/
|
|
806
1028
|
export declare const enum SymbolFlags {
|
|
1029
|
+
/** No category or binding-state bits are set. */
|
|
807
1030
|
None = 0,
|
|
1031
|
+
/** A model declaration or structural model expression. */
|
|
808
1032
|
Model = 2,
|
|
1033
|
+
/** A scalar declaration, including a scalar declaration expression. */
|
|
809
1034
|
Scalar = 4,
|
|
1035
|
+
/** An operation, either namespace-level or an interface member. */
|
|
810
1036
|
Operation = 8,
|
|
1037
|
+
/** An enum whose members can be looked up by name. */
|
|
811
1038
|
Enum = 16,
|
|
1039
|
+
/** An interface containing operation members. */
|
|
812
1040
|
Interface = 32,
|
|
1041
|
+
/** A keyword-form union containing variant members. */
|
|
813
1042
|
Union = 64,
|
|
1043
|
+
/** An alias whose target must be resolved before accessing the underlying type. */
|
|
814
1044
|
Alias = 128,
|
|
1045
|
+
/** A namespace that can merge declarations and export contained symbols. */
|
|
815
1046
|
Namespace = 256,
|
|
1047
|
+
/** A decorator signature or JavaScript decorator implementation. */
|
|
816
1048
|
Decorator = 512,
|
|
1049
|
+
/** A parameter declared in a template's `<...>` list. */
|
|
817
1050
|
TemplateParameter = 1024,
|
|
1051
|
+
/** A function signature or JavaScript function implementation. */
|
|
818
1052
|
Function = 2048,
|
|
1053
|
+
/** A named parameter in a function, decorator, or scalar constructor signature. */
|
|
819
1054
|
FunctionParameter = 4096,
|
|
1055
|
+
/** A lookup binding introduced by `using`, forwarding to `symbolSource`. */
|
|
820
1056
|
Using = 8192,
|
|
1057
|
+
/** A using binding made ambiguous by another using binding with the same name. */
|
|
821
1058
|
DuplicateUsing = 16384,
|
|
1059
|
+
/** A file-level container for exported declarations. */
|
|
822
1060
|
SourceFile = 32768,
|
|
1061
|
+
/** A symbol accessed as a member of its containing model, scalar, enum, union, or interface. */
|
|
823
1062
|
Member = 65536,
|
|
1063
|
+
/** A constant declaration whose initializer produces a value. */
|
|
824
1064
|
Const = 131072,
|
|
825
1065
|
/**
|
|
826
1066
|
* A symbol which represents a declaration. Such symbols will have at least
|
|
827
|
-
* one entry in the `declarations
|
|
828
|
-
*
|
|
829
|
-
* Symbols which do not represent declarations
|
|
1067
|
+
* one entry in the `declarations` array. Non-declaration symbols instead store
|
|
1068
|
+
* their originating node in `node`, when one exists.
|
|
830
1069
|
*/
|
|
831
1070
|
Declaration = 1048576,
|
|
1071
|
+
/** A JavaScript implementation to be merged with its TypeSpec decorator or function signature. */
|
|
832
1072
|
Implementation = 2097152,
|
|
833
1073
|
/**
|
|
834
1074
|
* A symbol which was late-bound, in which case, the type referred to
|
|
@@ -839,6 +1079,7 @@ export declare const enum SymbolFlags {
|
|
|
839
1079
|
* An internal symbol that can only be referenced from a source file in the same package.
|
|
840
1080
|
*/
|
|
841
1081
|
Internal = 8388608,
|
|
1082
|
+
/** Categories that store contained declarations in their `exports` table. */
|
|
842
1083
|
ExportContainer = 33024,
|
|
843
1084
|
/**
|
|
844
1085
|
* Symbols whose members will be late bound (and stored on the type)
|
|
@@ -849,7 +1090,9 @@ export declare const enum SymbolFlags {
|
|
|
849
1090
|
* Maps type arguments to instantiated type.
|
|
850
1091
|
*/
|
|
851
1092
|
export interface TypeInstantiationMap {
|
|
1093
|
+
/** Retrieve the cached instantiation for an ordered argument list, or `undefined` if absent. */
|
|
852
1094
|
get(args: readonly (Type | Value | IndeterminateEntity)[]): Type | undefined;
|
|
1095
|
+
/** Cache an instantiated type under its ordered list of type or value arguments. */
|
|
853
1096
|
set(args: readonly (Type | Value | IndeterminateEntity)[], type: Type): void;
|
|
854
1097
|
}
|
|
855
1098
|
/**
|
|
@@ -867,88 +1110,168 @@ export interface RekeyableMap<K, V> extends Map<K, V> {
|
|
|
867
1110
|
rekey(existingKey: K, newKey: K): boolean;
|
|
868
1111
|
}
|
|
869
1112
|
/**
|
|
870
|
-
*
|
|
1113
|
+
* Discriminants for syntax nodes, comment ranges, and documentation nodes.
|
|
1114
|
+
* Use a node's `kind` to narrow to its corresponding AST interface.
|
|
871
1115
|
*/
|
|
872
1116
|
export declare enum SyntaxKind {
|
|
1117
|
+
/** Root of a parsed TypeSpec file, including statements and parse diagnostics. */
|
|
873
1118
|
TypeSpecScript = 0,
|
|
1119
|
+
/** Loaded JavaScript module supplying decorator or function implementations. */
|
|
874
1120
|
JsSourceFile = 1,
|
|
1121
|
+
/** File or package import such as `import "./models.tsp";`. */
|
|
875
1122
|
ImportStatement = 2,
|
|
1123
|
+
/** Name token, with its decoded spelling available as `sv`. */
|
|
876
1124
|
Identifier = 3,
|
|
1125
|
+
/** Out-of-line decorator application using `@@decorator(Target, ...)`. */
|
|
877
1126
|
AugmentDecoratorStatement = 4,
|
|
1127
|
+
/** Decorator application attached to a declaration using `@decorator(...)`. */
|
|
878
1128
|
DecoratorExpression = 5,
|
|
1129
|
+
/** Compiler directive introduced by `#`, such as `#suppress`. */
|
|
879
1130
|
DirectiveExpression = 6,
|
|
1131
|
+
/** Qualified name segment selected with `.` or metatype selector `::`. */
|
|
880
1132
|
MemberExpression = 7,
|
|
1133
|
+
/** Namespace declaration, including blockless and dotted forms. */
|
|
881
1134
|
NamespaceStatement = 8,
|
|
1135
|
+
/** Namespace import into the current lookup scope using `using`. */
|
|
882
1136
|
UsingStatement = 9,
|
|
1137
|
+
/** Named operation declaration, either with a signature or an `is` reference. */
|
|
883
1138
|
OperationStatement = 10,
|
|
1139
|
+
/** Explicit operation parameter list and return type. */
|
|
884
1140
|
OperationSignatureDeclaration = 11,
|
|
1141
|
+
/** Operation signature reused through an `is` reference. */
|
|
885
1142
|
OperationSignatureReference = 12,
|
|
1143
|
+
/** Named model declaration registered in its enclosing namespace. */
|
|
886
1144
|
ModelStatement = 13,
|
|
1145
|
+
/** Structural model type in braces, also used for operation parameter lists. */
|
|
887
1146
|
ModelExpression = 14,
|
|
1147
|
+
/** Model property or operation parameter, including its type and optional default. */
|
|
888
1148
|
ModelProperty = 15,
|
|
1149
|
+
/** Model properties copied into a body or parameter list using `...`. */
|
|
889
1150
|
ModelSpreadProperty = 16,
|
|
1151
|
+
/** Named scalar declaration with optional base scalar and constructors. */
|
|
890
1152
|
ScalarStatement = 17,
|
|
1153
|
+
/** Named interface declaration containing operations. */
|
|
891
1154
|
InterfaceStatement = 18,
|
|
1155
|
+
/** Named union declaration containing variant nodes. */
|
|
892
1156
|
UnionStatement = 19,
|
|
1157
|
+
/** Named or unnamed alternative in a keyword-form union. */
|
|
893
1158
|
UnionVariant = 20,
|
|
1159
|
+
/** Named enum declaration containing members and member spreads. */
|
|
894
1160
|
EnumStatement = 21,
|
|
1161
|
+
/** Enum member with an optional explicit string or numeric value. */
|
|
895
1162
|
EnumMember = 22,
|
|
1163
|
+
/** Members copied from another enum using `...`. */
|
|
896
1164
|
EnumSpreadMember = 23,
|
|
1165
|
+
/** Type alias declaration, optionally parameterized by template parameters. */
|
|
897
1166
|
AliasStatement = 24,
|
|
1167
|
+
/** Decorator signature declaration with a separate target parameter. */
|
|
898
1168
|
DecoratorDeclarationStatement = 25,
|
|
1169
|
+
/** Named function signature declaration, distinct from a function type expression. */
|
|
899
1170
|
FunctionDeclarationStatement = 26,
|
|
1171
|
+
/** Parameter in a function, decorator, or scalar constructor signature. */
|
|
900
1172
|
FunctionParameter = 27,
|
|
1173
|
+
/** Infix union type assembled with `|`, not a keyword-form union declaration. */
|
|
901
1174
|
UnionExpression = 28,
|
|
1175
|
+
/** Intersection type assembled with `&`. */
|
|
902
1176
|
IntersectionExpression = 29,
|
|
1177
|
+
/** Tuple type written `[A, B]`, not an array value literal. */
|
|
903
1178
|
TupleExpression = 30,
|
|
1179
|
+
/** Array type formed by an element type followed by `[]`. */
|
|
904
1180
|
ArrayExpression = 31,
|
|
1181
|
+
/** Quoted string without interpolation. */
|
|
905
1182
|
StringLiteral = 32,
|
|
1183
|
+
/** Numeric token retaining both its spelling and JavaScript numeric value. */
|
|
906
1184
|
NumericLiteral = 33,
|
|
1185
|
+
/** The `true` or `false` literal. */
|
|
907
1186
|
BooleanLiteral = 34,
|
|
1187
|
+
/** Interpolated string with a head and ordered substitution spans. */
|
|
908
1188
|
StringTemplateExpression = 35,
|
|
1189
|
+
/** Text before the first `${...}` substitution in an interpolated string. */
|
|
909
1190
|
StringTemplateHead = 36,
|
|
1191
|
+
/** Text between consecutive substitutions in an interpolated string. */
|
|
910
1192
|
StringTemplateMiddle = 37,
|
|
1193
|
+
/** Text after the final substitution in an interpolated string. */
|
|
911
1194
|
StringTemplateTail = 38,
|
|
1195
|
+
/** A string substitution expression paired with the text that follows it. */
|
|
912
1196
|
StringTemplateSpan = 39,
|
|
1197
|
+
/** The `extern` declaration modifier. */
|
|
913
1198
|
ExternKeyword = 40,
|
|
1199
|
+
/** The `void` type keyword, typically used for an operation with no return value. */
|
|
914
1200
|
VoidKeyword = 41,
|
|
1201
|
+
/** The `never` type keyword, denoting a type with no possible values. */
|
|
915
1202
|
NeverKeyword = 42,
|
|
1203
|
+
/** The `unknown` type keyword, represented by {@link AnyKeywordNode}. */
|
|
916
1204
|
UnknownKeyword = 43,
|
|
1205
|
+
/** Value constraint introduced by `valueof`. */
|
|
917
1206
|
ValueOfExpression = 44,
|
|
1207
|
+
/** Reference to a name with an optional template argument list. */
|
|
918
1208
|
TypeReference = 45,
|
|
1209
|
+
/** Template parameter declaration with optional constraint and default. */
|
|
919
1210
|
TemplateParameterDeclaration = 46,
|
|
1211
|
+
/** Standalone semicolon without a declaration. */
|
|
920
1212
|
EmptyStatement = 47,
|
|
1213
|
+
/** Recovery node for source that could not be parsed as a valid statement. */
|
|
921
1214
|
InvalidStatement = 48,
|
|
1215
|
+
/** Single-line comment range collected when comment tracking is enabled. */
|
|
922
1216
|
LineComment = 49,
|
|
1217
|
+
/** Block comment range, possibly also parsed as documentation. */
|
|
923
1218
|
BlockComment = 50,
|
|
1219
|
+
/** Parsed documentation comment with body content and tags. */
|
|
924
1220
|
Doc = 51,
|
|
1221
|
+
/** Text content within a documentation comment or tag. */
|
|
925
1222
|
DocText = 52,
|
|
1223
|
+
/** Documentation tag describing a function or operation parameter. */
|
|
926
1224
|
DocParamTag = 53,
|
|
1225
|
+
/** Documentation tag describing a model property. */
|
|
927
1226
|
DocPropTag = 54,
|
|
1227
|
+
/** Documentation tag describing a return value. */
|
|
928
1228
|
DocReturnsTag = 55,
|
|
1229
|
+
/** Documentation tag describing error responses. */
|
|
929
1230
|
DocErrorsTag = 56,
|
|
1231
|
+
/** Documentation tag describing a template parameter. */
|
|
930
1232
|
DocTemplateTag = 57,
|
|
1233
|
+
/** Documentation tag whose name has no dedicated syntax kind. */
|
|
931
1234
|
DocUnknownTag = 58,
|
|
1235
|
+
/** Reserved kind; the parser does not currently produce return-statement nodes. */
|
|
932
1236
|
Return = 59,
|
|
1237
|
+
/** Namespace node synthesized while binding JavaScript implementations. */
|
|
933
1238
|
JsNamespaceDeclaration = 60,
|
|
1239
|
+
/** Positional or named argument inside a type reference's `<...>` list. */
|
|
934
1240
|
TemplateArgument = 61,
|
|
1241
|
+
/** Expression introduced by `typeof` to obtain the type of a value. */
|
|
935
1242
|
TypeOfExpression = 62,
|
|
1243
|
+
/** Object value written `#{ ... }`, distinct from a structural model type. */
|
|
936
1244
|
ObjectLiteral = 63,
|
|
1245
|
+
/** Named value entry in an object literal. */
|
|
937
1246
|
ObjectLiteralProperty = 64,
|
|
1247
|
+
/** Properties copied from an object value using `...`. */
|
|
938
1248
|
ObjectLiteralSpreadProperty = 65,
|
|
1249
|
+
/** Array value written `#[ ... ]`, distinct from a tuple type. */
|
|
939
1250
|
ArrayLiteral = 66,
|
|
1251
|
+
/** Named constant value with an optional type annotation. */
|
|
940
1252
|
ConstStatement = 67,
|
|
1253
|
+
/** Function or scalar-constructor invocation with positional arguments. */
|
|
941
1254
|
CallExpression = 68,
|
|
1255
|
+
/** Named `init` signature declared within a scalar. */
|
|
942
1256
|
ScalarConstructor = 69,
|
|
1257
|
+
/** The `internal` declaration modifier restricting package visibility. */
|
|
943
1258
|
InternalKeyword = 70,
|
|
1259
|
+
/** The `auto` modifier requesting a compiler-provided decorator implementation. */
|
|
944
1260
|
AutoKeyword = 71,
|
|
1261
|
+
/** Anonymous function signature written `fn(...) => ...`. */
|
|
945
1262
|
FunctionTypeExpression = 72,
|
|
1263
|
+
/** Keyword-form `model` used as an expression without namespace registration. */
|
|
946
1264
|
ModelDeclarationExpression = 73,
|
|
1265
|
+
/** Keyword-form `scalar` used as an expression without namespace registration. */
|
|
947
1266
|
ScalarDeclarationExpression = 74,
|
|
1267
|
+
/** Keyword-form `union` used as an expression without namespace registration. */
|
|
948
1268
|
UnionDeclarationExpression = 75,
|
|
1269
|
+
/** Keyword-form `enum` used as an expression without namespace registration. */
|
|
949
1270
|
EnumDeclarationExpression = 76
|
|
950
1271
|
}
|
|
1272
|
+
/** Parser error-state and origin bits attached to syntax nodes. */
|
|
951
1273
|
export declare const enum NodeFlags {
|
|
1274
|
+
/** No error-state or synthetic-origin bits have been set. */
|
|
952
1275
|
None = 0,
|
|
953
1276
|
/**
|
|
954
1277
|
* If this is set, the DescendantHasError bit can be trusted. If this not set,
|
|
@@ -976,29 +1299,48 @@ export declare const enum NodeFlags {
|
|
|
976
1299
|
*/
|
|
977
1300
|
Synthetic = 8
|
|
978
1301
|
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Shared source range and metadata for syntax nodes.
|
|
1304
|
+
* Parent and binding information need not be available on a freshly parsed or synthetic tree.
|
|
1305
|
+
*/
|
|
979
1306
|
export interface BaseNode extends TextRange {
|
|
1307
|
+
/** Discriminant used to narrow the node to a specific syntax interface. */
|
|
980
1308
|
readonly kind: SyntaxKind;
|
|
1309
|
+
/** Enclosing syntax node once parent links have been established; absent at roots. */
|
|
981
1310
|
readonly parent?: Node;
|
|
1311
|
+
/** Compiler directives attached to this node, in source order when present. */
|
|
982
1312
|
readonly directives?: readonly DirectiveExpressionNode[];
|
|
1313
|
+
/** Attached documentation comments when documentation parsing is enabled. */
|
|
983
1314
|
readonly docs?: readonly DocNode[];
|
|
1315
|
+
/** Parse-error cache state and synthetic-origin markers; use `hasParseError` for errors. */
|
|
984
1316
|
readonly flags: NodeFlags;
|
|
985
1317
|
/** Unique id across the process used to look up NodeLinks */
|
|
986
1318
|
_id?: number;
|
|
987
1319
|
}
|
|
1320
|
+
/** Syntax shared by declarations that accept template parameter lists. */
|
|
988
1321
|
export interface TemplateDeclarationNode {
|
|
1322
|
+
/** Parameters in declaration order; empty when no template list was written. */
|
|
989
1323
|
readonly templateParameters: readonly TemplateParameterDeclarationNode[];
|
|
1324
|
+
/** Range including `<` and `>`; positions are `-1` when the list is absent. */
|
|
990
1325
|
readonly templateParametersRange: TextRange;
|
|
1326
|
+
/** Local bindings, including template parameters, populated during binding when applicable. */
|
|
991
1327
|
readonly locals?: SymbolTable;
|
|
992
1328
|
}
|
|
993
1329
|
/**
|
|
994
1330
|
* owner node and other related information according to the position
|
|
995
1331
|
*/
|
|
996
1332
|
export interface PositionDetail {
|
|
1333
|
+
/** Most specific node accepted by the position query, or `undefined` when none matches. */
|
|
997
1334
|
readonly node: Node | undefined;
|
|
1335
|
+
/** Queried zero-based UTF-16 offset in the source file. */
|
|
998
1336
|
readonly position: number;
|
|
1337
|
+
/** UTF-16 code unit at `position`, or `NaN` outside the source text. */
|
|
999
1338
|
readonly char: number;
|
|
1339
|
+
/** UTF-16 code unit immediately before `position`, or `NaN` outside the source text. */
|
|
1000
1340
|
readonly preChar: number;
|
|
1341
|
+
/** UTF-16 code unit immediately after `position`, or `NaN` outside the source text. */
|
|
1001
1342
|
readonly nextChar: number;
|
|
1343
|
+
/** Whether the position query identifies whitespace or comment trivia at this offset. */
|
|
1002
1344
|
readonly inTrivia: boolean;
|
|
1003
1345
|
/**
|
|
1004
1346
|
* if the position is in a trivia, return the start position of the trivia containing the position
|
|
@@ -1023,6 +1365,10 @@ export interface PositionDetail {
|
|
|
1023
1365
|
/** get the PositionDetail of positionAfterTrivia */
|
|
1024
1366
|
readonly getPositionDetailAfterTrivia: () => PositionDetail;
|
|
1025
1367
|
}
|
|
1368
|
+
/**
|
|
1369
|
+
* Discriminated union of syntax nodes visited by the parser's AST utilities.
|
|
1370
|
+
* Comment ranges are tracked separately as {@link Comment}, not as child nodes.
|
|
1371
|
+
*/
|
|
1026
1372
|
export type Node = TypeSpecScriptNode | JsSourceFileNode | JsNamespaceDeclarationNode | TemplateArgumentNode | TemplateParameterDeclarationNode | ModelPropertyNode | UnionVariantNode | OperationStatementNode | OperationSignatureDeclarationNode | OperationSignatureReferenceNode | EnumMemberNode | EnumSpreadMemberNode | ModelSpreadPropertyNode | DecoratorExpressionNode | DirectiveExpressionNode | Statement | Expression | FunctionParameterNode | StringTemplateSpanNode | StringTemplateHeadNode | StringTemplateMiddleNode | StringTemplateTailNode | Modifier | DocNode | DocContent | DocTag | ReferenceExpression | ObjectLiteralNode | ObjectLiteralPropertyNode | ObjectLiteralSpreadPropertyNode | ScalarConstructorNode | ArrayLiteralNode;
|
|
1027
1373
|
/**
|
|
1028
1374
|
* Node that can be used as template
|
|
@@ -1032,42 +1378,75 @@ export type TemplateableNode = ModelStatementNode | ModelDeclarationExpressionNo
|
|
|
1032
1378
|
* Node types that can have referencable members
|
|
1033
1379
|
*/
|
|
1034
1380
|
export type MemberContainerNode = ModelStatementNode | ModelExpressionNode | ModelDeclarationExpressionNode | InterfaceStatementNode | EnumStatementNode | EnumDeclarationExpressionNode | UnionStatementNode | UnionDeclarationExpressionNode | IntersectionExpressionNode | ScalarStatementNode | ScalarDeclarationExpressionNode;
|
|
1381
|
+
/** Syntax declarations that introduce members of a model, enum, interface, union, or scalar. */
|
|
1035
1382
|
export type MemberNode = ModelPropertyNode | EnumMemberNode | OperationStatementNode | UnionVariantNode | ScalarConstructorNode;
|
|
1383
|
+
/** Semantic types whose named members can be resolved through member access. */
|
|
1036
1384
|
export type MemberContainerType = Model | Enum | Interface | Union | Scalar;
|
|
1037
1385
|
/**
|
|
1038
1386
|
* Type that can be used as members of a container type.
|
|
1039
1387
|
*/
|
|
1040
1388
|
export type MemberType = ModelProperty | EnumMember | Operation | UnionVariant | ScalarConstructor;
|
|
1389
|
+
/** Source comment ranges collected separately from the syntax tree when requested by {@link ParseOptions}. */
|
|
1041
1390
|
export type Comment = LineComment | BlockComment;
|
|
1391
|
+
/** Range of a `//` comment, excluding the terminating line break. */
|
|
1042
1392
|
export interface LineComment extends TextRange {
|
|
1393
|
+
/** Identifies a line-comment range rather than a block-comment range. */
|
|
1043
1394
|
readonly kind: SyntaxKind.LineComment;
|
|
1044
1395
|
}
|
|
1396
|
+
/** Range of a `/* ... *\/` comment, including its delimiters. */
|
|
1045
1397
|
export interface BlockComment extends TextRange {
|
|
1398
|
+
/** Identifies a block-comment range, including documentation comments. */
|
|
1046
1399
|
readonly kind: SyntaxKind.BlockComment;
|
|
1047
1400
|
/** If that comment was parsed as a doc comment. If parserOptions.docs=false this will always be false. */
|
|
1048
1401
|
readonly parsedAsDocs?: boolean;
|
|
1049
1402
|
}
|
|
1403
|
+
/** Controls optional comment collection and documentation parsing without changing the source text. */
|
|
1050
1404
|
export interface ParseOptions {
|
|
1051
1405
|
/** When true, collect comment ranges in {@link TypeSpecScriptNode.comments}. */
|
|
1052
1406
|
readonly comments?: boolean;
|
|
1053
1407
|
/** When true, parse doc comments into {@link Node.docs}. */
|
|
1054
1408
|
readonly docs?: boolean;
|
|
1055
1409
|
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Root syntax node for a TypeSpec source file.
|
|
1412
|
+
* Parsing creates statements and diagnostics; binding later populates namespace,
|
|
1413
|
+
* using, and local-symbol indexes without replacing the source-order statement tree.
|
|
1414
|
+
*/
|
|
1056
1415
|
export interface TypeSpecScriptNode extends BaseNode {
|
|
1416
|
+
/** Identifies a TypeSpec file root, rather than a loaded JavaScript module. */
|
|
1057
1417
|
readonly kind: SyntaxKind.TypeSpecScript;
|
|
1418
|
+
/** Synthetic identifier whose spelling is the source file path. */
|
|
1058
1419
|
readonly id: IdentifierNode;
|
|
1420
|
+
/** Top-level statements in source order, including recovery and empty statements. */
|
|
1059
1421
|
readonly statements: readonly Statement[];
|
|
1422
|
+
/** Source text and path from which this tree was parsed. */
|
|
1060
1423
|
readonly file: SourceFile;
|
|
1424
|
+
/** Blockless file namespace and its enclosing namespace segments, populated during binding. */
|
|
1061
1425
|
readonly inScopeNamespaces: readonly NamespaceStatementNode[];
|
|
1426
|
+
/** All namespace declaration nodes encountered during binding, including nested segments. */
|
|
1062
1427
|
readonly namespaces: NamespaceStatementNode[];
|
|
1428
|
+
/** Using statements from all scopes in this file, collected during binding. */
|
|
1063
1429
|
readonly usings: readonly UsingStatementNode[];
|
|
1430
|
+
/** Source-order comment ranges; empty unless comment collection was requested. */
|
|
1064
1431
|
readonly comments: readonly Comment[];
|
|
1432
|
+
/** Diagnostics produced while parsing, independent of later binding and checking diagnostics. */
|
|
1065
1433
|
readonly parseDiagnostics: readonly Diagnostic[];
|
|
1434
|
+
/** Whether parser recovery left a tree that the formatter can safely print. */
|
|
1066
1435
|
readonly printable: boolean;
|
|
1436
|
+
/** File-local lookup bindings; initialized by the binder, not by parsing alone. */
|
|
1067
1437
|
readonly locals: SymbolTable;
|
|
1438
|
+
/** Options supplied to the parser for this tree. */
|
|
1068
1439
|
readonly parseOptions: ParseOptions;
|
|
1069
1440
|
}
|
|
1441
|
+
/**
|
|
1442
|
+
* AST node variants representable in a statement list, including declarations and recovery nodes.
|
|
1443
|
+
* The union also includes call expressions, but the parser does not accept standalone call statements.
|
|
1444
|
+
*/
|
|
1070
1445
|
export type Statement = ImportStatementNode | ModelStatementNode | ScalarStatementNode | NamespaceStatementNode | InterfaceStatementNode | UnionStatementNode | UsingStatementNode | EnumStatementNode | AliasStatementNode | OperationStatementNode | DecoratorDeclarationStatementNode | FunctionDeclarationStatementNode | AugmentDecoratorStatementNode | ConstStatementNode | CallExpressionNode | EmptyStatementNode | InvalidStatementNode;
|
|
1446
|
+
/**
|
|
1447
|
+
* Shared shape for named statement declarations.
|
|
1448
|
+
* Parsed modifiers preserve source order and may include combinations later rejected by the checker.
|
|
1449
|
+
*/
|
|
1071
1450
|
export interface DeclarationNode {
|
|
1072
1451
|
/**
|
|
1073
1452
|
* Identifier that this node declares.
|
|
@@ -1094,64 +1473,117 @@ export interface OptionallyNamedDeclarationNode {
|
|
|
1094
1473
|
*/
|
|
1095
1474
|
readonly id?: IdentifierNode;
|
|
1096
1475
|
/**
|
|
1097
|
-
* Modifier nodes applied to this declaration.
|
|
1476
|
+
* Modifier nodes applied to this declaration. Empty for parsed declaration expressions.
|
|
1098
1477
|
*/
|
|
1099
1478
|
readonly modifiers: Modifier[];
|
|
1100
1479
|
/**
|
|
1101
|
-
* Combined modifier flags for this declaration.
|
|
1480
|
+
* Combined modifier flags for this declaration. `None` for parsed declaration expressions.
|
|
1102
1481
|
*/
|
|
1103
1482
|
readonly modifierFlags: ModifierFlags;
|
|
1104
1483
|
}
|
|
1484
|
+
/** Statement variants that introduce a named declaration and carry declaration modifiers. */
|
|
1105
1485
|
export type Declaration = Extract<Statement, DeclarationNode>;
|
|
1486
|
+
/** Syntax nodes used as lexical scopes for declaration and reference lookup. */
|
|
1106
1487
|
export type ScopeNode = NamespaceStatementNode | ModelStatementNode | InterfaceStatementNode | AliasStatementNode | TypeSpecScriptNode | JsSourceFileNode;
|
|
1488
|
+
/** File or package import written `import "path";` at the source-file level. */
|
|
1107
1489
|
export interface ImportStatementNode extends BaseNode {
|
|
1490
|
+
/** Distinguishes module loading from namespace lookup through a `using` statement. */
|
|
1108
1491
|
readonly kind: SyntaxKind.ImportStatement;
|
|
1492
|
+
/** Quoted module specifier; its decoded value may be a relative path or package name. */
|
|
1109
1493
|
readonly path: StringLiteralNode;
|
|
1494
|
+
/** Source file containing the import once parent links have been established. */
|
|
1110
1495
|
readonly parent?: TypeSpecScriptNode;
|
|
1111
1496
|
}
|
|
1497
|
+
/** Name token used for declarations, references, member selectors, and other named syntax. */
|
|
1112
1498
|
export interface IdentifierNode extends BaseNode {
|
|
1499
|
+
/** Identifies the name token itself, not a reference or declaration containing it. */
|
|
1113
1500
|
readonly kind: SyntaxKind.Identifier;
|
|
1501
|
+
/**
|
|
1502
|
+
* Decoded name without quoting or escapes; identifier tokens are NFC-normalized.
|
|
1503
|
+
* Read the source range instead when the original spelling is needed.
|
|
1504
|
+
*/
|
|
1114
1505
|
readonly sv: string;
|
|
1115
1506
|
}
|
|
1507
|
+
/** An `@decorator(...)` annotation attached to a declaration or member. */
|
|
1116
1508
|
export interface DecoratorExpressionNode extends BaseNode {
|
|
1509
|
+
/** Distinguishes an attached annotation from an out-of-line `@@` application. */
|
|
1117
1510
|
readonly kind: SyntaxKind.DecoratorExpression;
|
|
1511
|
+
/** Decorator name, without the leading `@`, optionally qualified by a namespace. */
|
|
1118
1512
|
readonly target: IdentifierNode | MemberExpressionNode;
|
|
1513
|
+
/** Explicit arguments in source order; the decorated entity is supplied separately by the checker. */
|
|
1119
1514
|
readonly arguments: readonly Expression[];
|
|
1120
1515
|
}
|
|
1516
|
+
/** An out-of-line decorator application, such as `@@doc(MyModel, "description");`. */
|
|
1121
1517
|
export interface AugmentDecoratorStatementNode extends BaseNode {
|
|
1518
|
+
/** Identifies the `@@` statement form rather than a declaration annotation. */
|
|
1122
1519
|
readonly kind: SyntaxKind.AugmentDecoratorStatement;
|
|
1520
|
+
/** Decorator name without the leading `@@`. */
|
|
1123
1521
|
readonly target: IdentifierNode | MemberExpressionNode;
|
|
1522
|
+
/** First source argument: the reference to the entity being decorated. */
|
|
1124
1523
|
readonly targetType: TypeReferenceNode;
|
|
1524
|
+
/** Remaining source arguments, excluding the decorated entity reference. */
|
|
1125
1525
|
readonly arguments: readonly Expression[];
|
|
1526
|
+
/** Containing file or namespace after binding. */
|
|
1126
1527
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
1127
1528
|
}
|
|
1529
|
+
/** A line-oriented compiler directive, such as `#suppress "code" "reason"`. */
|
|
1128
1530
|
export interface DirectiveExpressionNode extends BaseNode {
|
|
1531
|
+
/** Identifies a `#` directive rather than an `@` decorator annotation. */
|
|
1129
1532
|
readonly kind: SyntaxKind.DirectiveExpression;
|
|
1533
|
+
/** Directive name without the leading `#`. */
|
|
1130
1534
|
readonly target: IdentifierNode;
|
|
1535
|
+
/** Identifier or quoted-string arguments before the terminating newline. */
|
|
1131
1536
|
readonly arguments: readonly DirectiveArgument[];
|
|
1132
1537
|
}
|
|
1538
|
+
/** Directive arguments are names or quoted strings, not arbitrary TypeSpec expressions. */
|
|
1133
1539
|
export type DirectiveArgument = StringLiteralNode | IdentifierNode;
|
|
1540
|
+
/**
|
|
1541
|
+
* Syntax accepted in expression positions, including type expressions and value-producing syntax.
|
|
1542
|
+
* Whether an expression denotes a type, value, or constraint is determined during checking.
|
|
1543
|
+
*/
|
|
1134
1544
|
export type Expression = ArrayExpressionNode | MemberExpressionNode | ModelExpressionNode | ModelDeclarationExpressionNode | EnumDeclarationExpressionNode | UnionDeclarationExpressionNode | ScalarDeclarationExpressionNode | ObjectLiteralNode | ArrayLiteralNode | TupleExpressionNode | UnionExpressionNode | IntersectionExpressionNode | TypeReferenceNode | ValueOfExpressionNode | TypeOfExpressionNode | CallExpressionNode | StringLiteralNode | NumericLiteralNode | BooleanLiteralNode | StringTemplateExpressionNode | VoidKeywordNode | NeverKeywordNode | AnyKeywordNode | FunctionTypeExpressionNode;
|
|
1135
1545
|
export type ParenthesizedExpression = Expression & {
|
|
1136
1546
|
readonly parenthesized: true;
|
|
1137
1547
|
};
|
|
1548
|
+
/** Name-reference syntax accepted by resolution utilities, including the intrinsic `void` and `never` keywords. */
|
|
1138
1549
|
export type ReferenceExpression = TypeReferenceNode | MemberExpressionNode | IdentifierNode | VoidKeywordNode | NeverKeywordNode;
|
|
1550
|
+
/** One step of a qualified reference, such as `Namespace.Type` or `Operation::parameters`. */
|
|
1139
1551
|
export interface MemberExpressionNode extends BaseNode {
|
|
1552
|
+
/** Identifies a selected name segment rather than a complete reference with template arguments. */
|
|
1140
1553
|
readonly kind: SyntaxKind.MemberExpression;
|
|
1554
|
+
/** Name immediately following this node's selector. */
|
|
1141
1555
|
readonly id: IdentifierNode;
|
|
1556
|
+
/** Reference prefix to the left of the selector; longer chains nest through this property. */
|
|
1142
1557
|
readonly base: MemberExpressionNode | IdentifierNode;
|
|
1558
|
+
/** `.` selects namespace or type members; `::` selects compiler-provided metatype members. */
|
|
1143
1559
|
readonly selector: "." | "::";
|
|
1144
1560
|
}
|
|
1561
|
+
/**
|
|
1562
|
+
* One segment of a namespace declaration.
|
|
1563
|
+
* Dotted namespaces are nested nodes, while a blockless namespace scopes subsequent file statements.
|
|
1564
|
+
*/
|
|
1145
1565
|
export interface NamespaceStatementNode extends BaseNode, DeclarationNode {
|
|
1566
|
+
/** Identifies a source namespace declaration, not a namespace synthesized for JavaScript. */
|
|
1146
1567
|
readonly kind: SyntaxKind.NamespaceStatement;
|
|
1568
|
+
/**
|
|
1569
|
+
* Block statements, a nested segment of a dotted name, or `undefined` for the
|
|
1570
|
+
* innermost segment of a blockless namespace.
|
|
1571
|
+
*/
|
|
1147
1572
|
readonly statements?: readonly Statement[] | NamespaceStatementNode;
|
|
1573
|
+
/** Annotations on this segment; outer segments synthesized for a dotted name have none. */
|
|
1148
1574
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1575
|
+
/** Local lookup bindings initialized during binding, separate for each declaration of a merged namespace. */
|
|
1149
1576
|
readonly locals?: SymbolTable;
|
|
1577
|
+
/** Enclosing file or namespace segment after binding. */
|
|
1150
1578
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
1151
1579
|
}
|
|
1580
|
+
/** Brings a namespace's exported names into the containing lookup scope without loading a module. */
|
|
1152
1581
|
export interface UsingStatementNode extends BaseNode {
|
|
1582
|
+
/** Identifies namespace lookup syntax rather than a file import. */
|
|
1153
1583
|
readonly kind: SyntaxKind.UsingStatement;
|
|
1584
|
+
/** Namespace reference to make available for unqualified name lookup. */
|
|
1154
1585
|
readonly name: IdentifierNode | MemberExpressionNode;
|
|
1586
|
+
/** Syntactic container after binding; effective blockless namespace scope is in `scopeNamespace`. */
|
|
1155
1587
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
1156
1588
|
/**
|
|
1157
1589
|
* Namespace this using statement is scoped to.
|
|
@@ -1163,82 +1595,141 @@ export interface UsingStatementNode extends BaseNode {
|
|
|
1163
1595
|
*/
|
|
1164
1596
|
readonly scopeNamespace?: NamespaceStatementNode;
|
|
1165
1597
|
}
|
|
1598
|
+
/** Explicit `(parameters): ReturnType` portion of an operation declaration. */
|
|
1166
1599
|
export interface OperationSignatureDeclarationNode extends BaseNode {
|
|
1600
|
+
/** Selects the explicit-signature branch of {@link OperationSignature}. */
|
|
1167
1601
|
readonly kind: SyntaxKind.OperationSignatureDeclaration;
|
|
1602
|
+
/** Parameter list represented as model properties and spreads, with parentheses as its body range. */
|
|
1168
1603
|
readonly parameters: ModelExpressionNode;
|
|
1604
|
+
/** Type expression following the signature's colon. */
|
|
1169
1605
|
readonly returnType: Expression;
|
|
1170
1606
|
}
|
|
1607
|
+
/** `is BaseOperation` portion of an operation that reuses another operation's signature. */
|
|
1171
1608
|
export interface OperationSignatureReferenceNode extends BaseNode {
|
|
1609
|
+
/** Selects signature reuse rather than an explicit parameter list and return type. */
|
|
1172
1610
|
readonly kind: SyntaxKind.OperationSignatureReference;
|
|
1611
|
+
/** Referenced operation, including any explicit template arguments. */
|
|
1173
1612
|
readonly baseOperation: TypeReferenceNode;
|
|
1174
1613
|
}
|
|
1614
|
+
/** An operation either declares its own signature or reuses one through `is`. */
|
|
1175
1615
|
export type OperationSignature = OperationSignatureDeclarationNode | OperationSignatureReferenceNode;
|
|
1616
|
+
/**
|
|
1617
|
+
* Named operation declared in a namespace or interface.
|
|
1618
|
+
* The `op` keyword is optional for interface members, but both forms use this node shape.
|
|
1619
|
+
*/
|
|
1176
1620
|
export interface OperationStatementNode extends BaseNode, DeclarationNode, TemplateDeclarationNode {
|
|
1621
|
+
/** Identifies the named operation node rather than its signature child. */
|
|
1177
1622
|
readonly kind: SyntaxKind.OperationStatement;
|
|
1623
|
+
/** Explicit signature or reference to an operation whose signature is reused. */
|
|
1178
1624
|
readonly signature: OperationSignature;
|
|
1625
|
+
/** Decorator annotations in source order, not their execution order. */
|
|
1179
1626
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1627
|
+
/** File, namespace, or interface syntactically containing this operation after binding. */
|
|
1180
1628
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode | InterfaceStatementNode;
|
|
1181
1629
|
}
|
|
1630
|
+
/** Named model declaration whose checked type is registered in the enclosing namespace. */
|
|
1182
1631
|
export interface ModelStatementNode extends BaseNode, DeclarationNode, TemplateDeclarationNode {
|
|
1632
|
+
/** Distinguishes a namespace declaration from a keyword-form model in expression position. */
|
|
1183
1633
|
readonly kind: SyntaxKind.ModelStatement;
|
|
1634
|
+
/** Own property declarations and spreads in source order; inherited properties are not inserted here. */
|
|
1184
1635
|
readonly properties: readonly (ModelPropertyNode | ModelSpreadPropertyNode)[];
|
|
1636
|
+
/** Range including body braces, or `{-1, -1}` when an `is` declaration has no body. */
|
|
1185
1637
|
readonly bodyRange: TextRange;
|
|
1638
|
+
/** Base model expression following `extends`; mutually exclusive with `is` in parsed syntax. */
|
|
1186
1639
|
readonly extends?: Expression;
|
|
1640
|
+
/** Model expression following `is`, whose properties and decorators are copied by the checker. */
|
|
1187
1641
|
readonly is?: Expression;
|
|
1642
|
+
/** Decorator annotations as written, before semantic evaluation. */
|
|
1188
1643
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1644
|
+
/** Syntactic containing file or namespace after binding, including for blockless namespaces. */
|
|
1189
1645
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
1190
1646
|
}
|
|
1191
1647
|
/**
|
|
1192
1648
|
* A `model` declaration used in expression position (e.g. `alias M = model { x: string }`
|
|
1193
1649
|
* or a property type). May carry a name (kept on the resulting type but never registered)
|
|
1194
|
-
* and
|
|
1195
|
-
*
|
|
1650
|
+
* and produces a model type with `expression: true`. Checking requires the
|
|
1651
|
+
* `declaration-expressions` feature. Template parameters are syntactically accepted
|
|
1652
|
+
* for error recovery but rejected by the checker.
|
|
1196
1653
|
*/
|
|
1197
1654
|
export interface ModelDeclarationExpressionNode extends BaseNode, OptionallyNamedDeclarationNode, TemplateDeclarationNode {
|
|
1655
|
+
/** Identifies keyword-form model syntax in expression position, not a bare `{ ... }` model type. */
|
|
1198
1656
|
readonly kind: SyntaxKind.ModelDeclarationExpression;
|
|
1657
|
+
/** Own property declarations and spreads in source order, before inheritance or copying is resolved. */
|
|
1199
1658
|
readonly properties: readonly (ModelPropertyNode | ModelSpreadPropertyNode)[];
|
|
1659
|
+
/** Range including body braces, or `{-1, -1}` when an `is` expression omits a body. */
|
|
1200
1660
|
readonly bodyRange: TextRange;
|
|
1661
|
+
/** Base model expression following `extends`, absent when `is` is used. */
|
|
1201
1662
|
readonly extends?: Expression;
|
|
1663
|
+
/** Source model expression following `is`, absent when `extends` is used. */
|
|
1202
1664
|
readonly is?: Expression;
|
|
1665
|
+
/** Annotations applied to the resulting model type, not to the enclosing expression's owner. */
|
|
1203
1666
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1204
1667
|
}
|
|
1668
|
+
/** Named scalar declaration with an optional base scalar and named constructor signatures. */
|
|
1205
1669
|
export interface ScalarStatementNode extends BaseNode, DeclarationNode, TemplateDeclarationNode {
|
|
1670
|
+
/** Distinguishes a namespace scalar declaration from a scalar declaration expression. */
|
|
1206
1671
|
readonly kind: SyntaxKind.ScalarStatement;
|
|
1672
|
+
/** Base scalar reference following `extends`, including any template arguments. */
|
|
1207
1673
|
readonly extends?: TypeReferenceNode;
|
|
1674
|
+
/** Decorator annotations on this scalar in source order. */
|
|
1208
1675
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1676
|
+
/** Constructor signatures written in this body, excluding inherited constructors. */
|
|
1209
1677
|
readonly members: readonly ScalarConstructorNode[];
|
|
1678
|
+
/** Range including constructor-body braces, or `{-1, -1}` for a bodyless declaration. */
|
|
1210
1679
|
readonly bodyRange: TextRange;
|
|
1680
|
+
/** Syntactic containing file or namespace after binding. */
|
|
1211
1681
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
1212
1682
|
}
|
|
1213
1683
|
/**
|
|
1214
1684
|
* A `scalar` declaration used in expression position (e.g. `alias S = scalar extends int32`).
|
|
1215
|
-
* May carry a name (kept on the resulting type but never registered) and
|
|
1216
|
-
* `expression: true`.
|
|
1217
|
-
*
|
|
1685
|
+
* May carry a name (kept on the resulting type but never registered) and
|
|
1686
|
+
* produces a scalar type with `expression: true`. Checking requires the
|
|
1687
|
+
* `declaration-expressions` feature. Template parameters are syntactically accepted
|
|
1688
|
+
* for error recovery but rejected by the checker.
|
|
1218
1689
|
*/
|
|
1219
1690
|
export interface ScalarDeclarationExpressionNode extends BaseNode, OptionallyNamedDeclarationNode, TemplateDeclarationNode {
|
|
1691
|
+
/** Identifies a scalar used as an expression without introducing a namespace binding. */
|
|
1220
1692
|
readonly kind: SyntaxKind.ScalarDeclarationExpression;
|
|
1693
|
+
/** Base scalar reference following `extends`, or `undefined` when omitted. */
|
|
1221
1694
|
readonly extends?: TypeReferenceNode;
|
|
1695
|
+
/** Annotations applied to the scalar type produced by this expression. */
|
|
1222
1696
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1697
|
+
/** Constructor signatures written in the optional scalar body. */
|
|
1223
1698
|
readonly members: readonly ScalarConstructorNode[];
|
|
1699
|
+
/** Range including constructor-body braces, or `{-1, -1}` when no body was written. */
|
|
1224
1700
|
readonly bodyRange: TextRange;
|
|
1225
1701
|
}
|
|
1702
|
+
/** Named scalar constructor signature written `init name(parameters);`. */
|
|
1226
1703
|
export interface ScalarConstructorNode extends BaseNode {
|
|
1704
|
+
/** Distinguishes a constructor declaration from a call to that constructor. */
|
|
1227
1705
|
readonly kind: SyntaxKind.ScalarConstructor;
|
|
1706
|
+
/** Constructor name following `init`. */
|
|
1228
1707
|
readonly id: IdentifierNode;
|
|
1708
|
+
/** Constructor parameters in source order, using function-parameter syntax rather than model properties. */
|
|
1229
1709
|
readonly parameters: FunctionParameterNode[];
|
|
1710
|
+
/** Scalar declaration or scalar declaration expression containing this signature after binding. */
|
|
1230
1711
|
readonly parent?: ScalarStatementNode | ScalarDeclarationExpressionNode;
|
|
1231
1712
|
}
|
|
1713
|
+
/** Named interface declaration grouping operations and optionally extending other interfaces. */
|
|
1232
1714
|
export interface InterfaceStatementNode extends BaseNode, DeclarationNode, TemplateDeclarationNode {
|
|
1715
|
+
/** Identifies an interface declaration, not one of its operation members. */
|
|
1233
1716
|
readonly kind: SyntaxKind.InterfaceStatement;
|
|
1717
|
+
/** Operations explicitly written in this body; inherited operations exist only in the checked type. */
|
|
1234
1718
|
readonly operations: readonly OperationStatementNode[];
|
|
1719
|
+
/** Range including the braces surrounding the operation list. */
|
|
1235
1720
|
readonly bodyRange: TextRange;
|
|
1721
|
+
/** Base interface references in source order; empty when no `extends` clause was written. */
|
|
1236
1722
|
readonly extends: readonly TypeReferenceNode[];
|
|
1723
|
+
/** Annotations on the interface itself, separate from annotations on individual operations. */
|
|
1237
1724
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1725
|
+
/** Syntactic containing file or namespace after binding. */
|
|
1238
1726
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
1239
1727
|
}
|
|
1728
|
+
/** Named keyword-form union whose alternatives may have individually addressable names. */
|
|
1240
1729
|
export interface UnionStatementNode extends BaseNode, DeclarationNode, TemplateDeclarationNode {
|
|
1730
|
+
/** Distinguishes a named union declaration from an infix `|` expression. */
|
|
1241
1731
|
readonly kind: SyntaxKind.UnionStatement;
|
|
1732
|
+
/** Variant nodes in source order, including both named and unnamed alternatives. */
|
|
1242
1733
|
readonly options: readonly UnionVariantNode[];
|
|
1243
1734
|
/**
|
|
1244
1735
|
* Type that every variant of this union must be assignable to.
|
|
@@ -1249,17 +1740,22 @@ export interface UnionStatementNode extends BaseNode, DeclarationNode, TemplateD
|
|
|
1249
1740
|
* @experimental
|
|
1250
1741
|
*/
|
|
1251
1742
|
readonly extends?: Expression;
|
|
1743
|
+
/** Annotations on the union itself, separate from variant annotations. */
|
|
1252
1744
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1745
|
+
/** Syntactic containing file or namespace after binding. */
|
|
1253
1746
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
1254
1747
|
}
|
|
1255
1748
|
/**
|
|
1256
1749
|
* A keyword-form `union` declaration used in expression position
|
|
1257
1750
|
* (e.g. `alias U = union { string, int32 }`). May carry a name (kept on the resulting type
|
|
1258
|
-
* but never registered) and
|
|
1259
|
-
*
|
|
1751
|
+
* but never registered) and produces a union type with `expression: true`.
|
|
1752
|
+
* Checking requires the `declaration-expressions` feature. Template parameters
|
|
1753
|
+
* are syntactically accepted for error recovery but rejected by the checker.
|
|
1260
1754
|
*/
|
|
1261
1755
|
export interface UnionDeclarationExpressionNode extends BaseNode, OptionallyNamedDeclarationNode, TemplateDeclarationNode {
|
|
1756
|
+
/** Identifies keyword-form union syntax in expression position, not an infix `|` expression. */
|
|
1262
1757
|
readonly kind: SyntaxKind.UnionDeclarationExpression;
|
|
1758
|
+
/** Named or unnamed variants in source order; retained as members of this union when used in a larger `|`. */
|
|
1263
1759
|
readonly options: readonly UnionVariantNode[];
|
|
1264
1760
|
/**
|
|
1265
1761
|
* Type that every variant of this union must be assignable to.
|
|
@@ -1270,206 +1766,367 @@ export interface UnionDeclarationExpressionNode extends BaseNode, OptionallyName
|
|
|
1270
1766
|
* @experimental
|
|
1271
1767
|
*/
|
|
1272
1768
|
readonly extends?: Expression;
|
|
1769
|
+
/** Annotations applied to the union type produced by this expression. */
|
|
1273
1770
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1274
1771
|
}
|
|
1772
|
+
/** One alternative in a keyword-form union, with an optional name before `:`. */
|
|
1275
1773
|
export interface UnionVariantNode extends BaseNode {
|
|
1774
|
+
/** Identifies a declaration-body alternative rather than an operand of an infix union. */
|
|
1276
1775
|
readonly kind: SyntaxKind.UnionVariant;
|
|
1776
|
+
/** Explicit variant name; absent for an unnamed alternative such as `string`. */
|
|
1277
1777
|
readonly id?: IdentifierNode;
|
|
1778
|
+
/** Type expression for this alternative, whether or not a name was provided. */
|
|
1278
1779
|
readonly value: Expression;
|
|
1780
|
+
/** Annotations on this variant, not on its containing union. */
|
|
1279
1781
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1782
|
+
/** Containing union declaration or union declaration expression after binding. */
|
|
1280
1783
|
readonly parent?: UnionStatementNode | UnionDeclarationExpressionNode;
|
|
1281
1784
|
}
|
|
1785
|
+
/** Named enum declaration containing explicit members and enum spreads. */
|
|
1282
1786
|
export interface EnumStatementNode extends BaseNode, DeclarationNode {
|
|
1787
|
+
/** Distinguishes a namespace enum declaration from an enum declaration expression. */
|
|
1283
1788
|
readonly kind: SyntaxKind.EnumStatement;
|
|
1789
|
+
/** Members and spread references as written; spreads are not expanded in the syntax tree. */
|
|
1284
1790
|
readonly members: readonly (EnumMemberNode | EnumSpreadMemberNode)[];
|
|
1791
|
+
/** Annotations on this enum, separate from member annotations. */
|
|
1285
1792
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1793
|
+
/** Syntactic containing file or namespace after binding. */
|
|
1286
1794
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
1287
1795
|
}
|
|
1288
1796
|
/**
|
|
1289
1797
|
* An `enum` declaration used in expression position (e.g. `alias E = enum { a, b }`).
|
|
1290
|
-
* May carry a name (kept on the resulting type but never registered) and
|
|
1291
|
-
* `expression: true`.
|
|
1798
|
+
* May carry a name (kept on the resulting type but never registered) and produces
|
|
1799
|
+
* an enum type with `expression: true`. Checking requires the `declaration-expressions` feature.
|
|
1292
1800
|
*/
|
|
1293
1801
|
export interface EnumDeclarationExpressionNode extends BaseNode, OptionallyNamedDeclarationNode {
|
|
1802
|
+
/** Identifies enum syntax used as an expression without introducing a namespace binding. */
|
|
1294
1803
|
readonly kind: SyntaxKind.EnumDeclarationExpression;
|
|
1804
|
+
/** Members and spreads in source order, before enum spreads are resolved by the checker. */
|
|
1295
1805
|
readonly members: readonly (EnumMemberNode | EnumSpreadMemberNode)[];
|
|
1806
|
+
/** Annotations applied to the enum type produced by this expression. */
|
|
1296
1807
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1297
1808
|
}
|
|
1809
|
+
/** Enum member declaration with an optional explicit string or numeric literal after `:`. */
|
|
1298
1810
|
export interface EnumMemberNode extends BaseNode {
|
|
1811
|
+
/** Identifies an explicit member rather than an enum spread. */
|
|
1299
1812
|
readonly kind: SyntaxKind.EnumMember;
|
|
1813
|
+
/** Member name, including decoded names accepted through quoted-identifier syntax. */
|
|
1300
1814
|
readonly id: IdentifierNode;
|
|
1815
|
+
/** Explicit literal value; absent when the member is declared by name alone. */
|
|
1301
1816
|
readonly value?: StringLiteralNode | NumericLiteralNode;
|
|
1817
|
+
/** Annotations on this member, not its containing enum. */
|
|
1302
1818
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1819
|
+
/** Containing enum declaration or enum declaration expression after binding. */
|
|
1303
1820
|
readonly parent?: EnumStatementNode | EnumDeclarationExpressionNode;
|
|
1304
1821
|
}
|
|
1822
|
+
/** An enum-body `...OtherEnum` entry whose members are copied during type checking. */
|
|
1305
1823
|
export interface EnumSpreadMemberNode extends BaseNode {
|
|
1824
|
+
/** Distinguishes a spread reference from an explicitly named enum member. */
|
|
1306
1825
|
readonly kind: SyntaxKind.EnumSpreadMember;
|
|
1826
|
+
/** Reference to the enum supplying the copied members. */
|
|
1307
1827
|
readonly target: TypeReferenceNode;
|
|
1308
1828
|
}
|
|
1829
|
+
/** Named alias for a type expression, optionally parameterized by template parameters. */
|
|
1309
1830
|
export interface AliasStatementNode extends BaseNode, DeclarationNode, TemplateDeclarationNode {
|
|
1831
|
+
/** Identifies a named alias declaration rather than the expression it aliases. */
|
|
1310
1832
|
readonly kind: SyntaxKind.AliasStatement;
|
|
1833
|
+
/** Expression following `=`, resolved in the alias's template and namespace scope. */
|
|
1311
1834
|
readonly value: Expression;
|
|
1835
|
+
/** Enclosing file or namespace after binding. */
|
|
1312
1836
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
1313
1837
|
}
|
|
1838
|
+
/** Named constant value, optionally checked against an explicit type annotation. */
|
|
1314
1839
|
export interface ConstStatementNode extends BaseNode, DeclarationNode {
|
|
1840
|
+
/** Identifies a value declaration rather than a type alias. */
|
|
1315
1841
|
readonly kind: SyntaxKind.ConstStatement;
|
|
1842
|
+
/** Initializer following `=`, evaluated as a value by the checker. */
|
|
1316
1843
|
readonly value: Expression;
|
|
1844
|
+
/** Type annotation following `:`, or `undefined` when the value's type is inferred. */
|
|
1317
1845
|
readonly type?: Expression;
|
|
1846
|
+
/** Enclosing file or namespace after binding. */
|
|
1318
1847
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
1319
1848
|
}
|
|
1849
|
+
/**
|
|
1850
|
+
* Invocation of a function or scalar constructor in an expression.
|
|
1851
|
+
* Although included in {@link Statement}, the parser does not accept standalone call statements.
|
|
1852
|
+
*/
|
|
1320
1853
|
export interface CallExpressionNode extends BaseNode {
|
|
1854
|
+
/** Distinguishes invocation with `(...)` from a name reference with optional `<...>` arguments. */
|
|
1321
1855
|
readonly kind: SyntaxKind.CallExpression;
|
|
1856
|
+
/** Function name or qualified constructor reference, without the argument list. */
|
|
1322
1857
|
readonly target: MemberExpressionNode | IdentifierNode;
|
|
1858
|
+
/** Explicit argument expressions in source order; no implicit context argument is stored here. */
|
|
1323
1859
|
readonly arguments: Expression[];
|
|
1324
1860
|
}
|
|
1861
|
+
/** Recovery placeholder for source that could not form a recognized statement. */
|
|
1325
1862
|
export interface InvalidStatementNode extends BaseNode {
|
|
1863
|
+
/** Identifies a parser-recovery node, not a valid declaration. */
|
|
1326
1864
|
readonly kind: SyntaxKind.InvalidStatement;
|
|
1865
|
+
/** Leading decorators retained while recovering from the invalid statement. */
|
|
1327
1866
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1328
1867
|
}
|
|
1868
|
+
/** Standalone semicolon with no associated declaration or expression. */
|
|
1329
1869
|
export interface EmptyStatementNode extends BaseNode {
|
|
1870
|
+
/** Identifies an intentionally empty statement rather than a recovery placeholder. */
|
|
1330
1871
|
readonly kind: SyntaxKind.EmptyStatement;
|
|
1331
1872
|
}
|
|
1873
|
+
/**
|
|
1874
|
+
* Structural model type written `{ ... }`, also used for operation parameter lists.
|
|
1875
|
+
* Unlike a model declaration expression, it has no declaration name, modifiers, or heritage clauses.
|
|
1876
|
+
*/
|
|
1332
1877
|
export interface ModelExpressionNode extends BaseNode {
|
|
1878
|
+
/** Identifies structural model syntax rather than an object value written `#{ ... }`. */
|
|
1333
1879
|
readonly kind: SyntaxKind.ModelExpression;
|
|
1880
|
+
/** Explicit property declarations and spreads in source order, before spreads are expanded. */
|
|
1334
1881
|
readonly properties: (ModelPropertyNode | ModelSpreadPropertyNode)[];
|
|
1882
|
+
/** Range including the surrounding braces, or parentheses when used as an operation parameter list. */
|
|
1335
1883
|
readonly bodyRange: TextRange;
|
|
1336
1884
|
}
|
|
1885
|
+
/** Array type formed by applying a postfix `[]` to an element type expression. */
|
|
1337
1886
|
export interface ArrayExpressionNode extends BaseNode {
|
|
1887
|
+
/** Identifies an array type rather than an array value literal. */
|
|
1338
1888
|
readonly kind: SyntaxKind.ArrayExpression;
|
|
1889
|
+
/** Expression before this `[]`; nested array types contain another array expression here. */
|
|
1339
1890
|
readonly elementType: Expression;
|
|
1340
1891
|
}
|
|
1892
|
+
/** Fixed-length tuple type written `[A, B]`, distinct from an array value `#[a, b]`. */
|
|
1341
1893
|
export interface TupleExpressionNode extends BaseNode {
|
|
1894
|
+
/** Identifies tuple type syntax rather than value-literal syntax. */
|
|
1342
1895
|
readonly kind: SyntaxKind.TupleExpression;
|
|
1896
|
+
/** Element type expressions in tuple index order. */
|
|
1343
1897
|
readonly values: readonly Expression[];
|
|
1344
1898
|
}
|
|
1899
|
+
/** Property type declaration in a model body, or parameter declaration in an operation signature. */
|
|
1345
1900
|
export interface ModelPropertyNode extends BaseNode {
|
|
1901
|
+
/** Identifies an explicitly declared property rather than a property spread. */
|
|
1346
1902
|
readonly kind: SyntaxKind.ModelProperty;
|
|
1903
|
+
/** Property name, decoded from identifier or legacy quoted-name syntax. */
|
|
1347
1904
|
readonly id: IdentifierNode;
|
|
1905
|
+
/** Declared type expression following `:`, not the property's default value. */
|
|
1348
1906
|
readonly value: Expression;
|
|
1907
|
+
/** Property or parameter annotations in source order. */
|
|
1349
1908
|
readonly decorators: readonly DecoratorExpressionNode[];
|
|
1909
|
+
/** Whether `?` was written after the property name. */
|
|
1350
1910
|
readonly optional: boolean;
|
|
1911
|
+
/** Default-value expression following `=`, absent when no default was written. */
|
|
1351
1912
|
readonly default?: Expression;
|
|
1913
|
+
/** Containing model syntax or operation-parameter model after parent links are established. */
|
|
1352
1914
|
readonly parent?: ModelStatementNode | ModelExpressionNode | ModelDeclarationExpressionNode;
|
|
1353
1915
|
}
|
|
1916
|
+
/** Model-body or operation-parameter spread written `...SourceModel`. */
|
|
1354
1917
|
export interface ModelSpreadPropertyNode extends BaseNode {
|
|
1918
|
+
/** Identifies a spread that contributes properties during checking, not an explicit property node. */
|
|
1355
1919
|
readonly kind: SyntaxKind.ModelSpreadProperty;
|
|
1920
|
+
/** Model reference, including any template arguments, supplying the copied properties. */
|
|
1356
1921
|
readonly target: TypeReferenceNode;
|
|
1922
|
+
/** Containing model syntax or operation-parameter model after binding. */
|
|
1357
1923
|
readonly parent?: ModelStatementNode | ModelExpressionNode | ModelDeclarationExpressionNode;
|
|
1358
1924
|
}
|
|
1925
|
+
/** Object value literal written `#{ ... }`, not a structural model type. */
|
|
1359
1926
|
export interface ObjectLiteralNode extends BaseNode {
|
|
1927
|
+
/** Distinguishes value-producing object syntax from a model expression. */
|
|
1360
1928
|
readonly kind: SyntaxKind.ObjectLiteral;
|
|
1929
|
+
/** Property initializers and object spreads in source order, before evaluation. */
|
|
1361
1930
|
readonly properties: (ObjectLiteralPropertyNode | ObjectLiteralSpreadPropertyNode)[];
|
|
1931
|
+
/** Range including the `#{` opening token and closing brace. */
|
|
1362
1932
|
readonly bodyRange: TextRange;
|
|
1363
1933
|
}
|
|
1934
|
+
/** Named object-value initializer written `name: expression` inside `#{ ... }`. */
|
|
1364
1935
|
export interface ObjectLiteralPropertyNode extends BaseNode {
|
|
1936
|
+
/** Identifies an explicit initializer rather than an object spread. */
|
|
1365
1937
|
readonly kind: SyntaxKind.ObjectLiteralProperty;
|
|
1938
|
+
/** Decoded object property name. */
|
|
1366
1939
|
readonly id: IdentifierNode;
|
|
1940
|
+
/** Initializer expression, evaluated as a value rather than a property type annotation. */
|
|
1367
1941
|
readonly value: Expression;
|
|
1942
|
+
/** Object literal containing this initializer after binding. */
|
|
1368
1943
|
readonly parent?: ObjectLiteralNode;
|
|
1369
1944
|
}
|
|
1945
|
+
/** Object-value spread written `...source` inside `#{ ... }`. */
|
|
1370
1946
|
export interface ObjectLiteralSpreadPropertyNode extends BaseNode {
|
|
1947
|
+
/** Identifies property copying from an object value rather than from a model type. */
|
|
1371
1948
|
readonly kind: SyntaxKind.ObjectLiteralSpreadProperty;
|
|
1949
|
+
/** Reference to the object value whose properties are copied during evaluation. */
|
|
1372
1950
|
readonly target: TypeReferenceNode;
|
|
1951
|
+
/** Object literal containing this spread after binding. */
|
|
1373
1952
|
readonly parent?: ObjectLiteralNode;
|
|
1374
1953
|
}
|
|
1954
|
+
/** Array value literal written `#[ ... ]`, not a tuple type expression. */
|
|
1375
1955
|
export interface ArrayLiteralNode extends BaseNode {
|
|
1956
|
+
/** Distinguishes value-producing array syntax from tuple and array type syntax. */
|
|
1376
1957
|
readonly kind: SyntaxKind.ArrayLiteral;
|
|
1958
|
+
/** Element expressions in array index order, evaluated as values. */
|
|
1377
1959
|
readonly values: readonly Expression[];
|
|
1378
1960
|
}
|
|
1961
|
+
/** Primitive literal nodes and string-template text fragments; excludes whole templates and structural literals. */
|
|
1379
1962
|
export type LiteralNode = StringLiteralNode | NumericLiteralNode | BooleanLiteralNode | StringTemplateHeadNode | StringTemplateMiddleNode | StringTemplateTailNode;
|
|
1963
|
+
/** Quoted string without unescaped interpolation, including triple-quoted strings. */
|
|
1380
1964
|
export interface StringLiteralNode extends BaseNode {
|
|
1965
|
+
/** Identifies a complete string literal rather than a fragment of an interpolated string. */
|
|
1381
1966
|
readonly kind: SyntaxKind.StringLiteral;
|
|
1967
|
+
/** Decoded content without delimiters; triple-quoted strings also have indentation removed. */
|
|
1382
1968
|
readonly value: string;
|
|
1383
1969
|
}
|
|
1970
|
+
/** Numeric literal retaining its source spelling independently of JavaScript number precision. */
|
|
1384
1971
|
export interface NumericLiteralNode extends BaseNode {
|
|
1972
|
+
/** Identifies numeric literal syntax, including decimal, hexadecimal, and binary forms. */
|
|
1385
1973
|
readonly kind: SyntaxKind.NumericLiteral;
|
|
1974
|
+
/** JavaScript `Number` conversion of the token, which may lose precision or overflow. */
|
|
1386
1975
|
readonly value: number;
|
|
1976
|
+
/** Original numeric token spelling, preserving radix, exponent, and precision for exact numeric handling. */
|
|
1387
1977
|
readonly valueAsString: string;
|
|
1388
1978
|
}
|
|
1979
|
+
/** Boolean literal written `true` or `false`. */
|
|
1389
1980
|
export interface BooleanLiteralNode extends BaseNode {
|
|
1981
|
+
/** Identifies a boolean literal rather than a reference named by an identifier. */
|
|
1390
1982
|
readonly kind: SyntaxKind.BooleanLiteral;
|
|
1983
|
+
/** `true` for the `true` keyword and `false` for the `false` keyword. */
|
|
1391
1984
|
readonly value: boolean;
|
|
1392
1985
|
}
|
|
1986
|
+
/** Interpolated string split into initial text and ordered expression/text pairs. */
|
|
1393
1987
|
export interface StringTemplateExpressionNode extends BaseNode {
|
|
1988
|
+
/** Identifies a string containing substitutions rather than a plain string literal. */
|
|
1394
1989
|
readonly kind: SyntaxKind.StringTemplateExpression;
|
|
1990
|
+
/** Text before the first substitution, possibly empty. */
|
|
1395
1991
|
readonly head: StringTemplateHeadNode;
|
|
1992
|
+
/** One span per substitution in source order; the final span ends in a tail node. */
|
|
1396
1993
|
readonly spans: readonly StringTemplateSpanNode[];
|
|
1397
1994
|
}
|
|
1995
|
+
/** A `${expression}` substitution paired with the string text immediately following it. */
|
|
1398
1996
|
export interface StringTemplateSpanNode extends BaseNode {
|
|
1997
|
+
/** Identifies an expression/text pair, not a standalone string token. */
|
|
1399
1998
|
readonly kind: SyntaxKind.StringTemplateSpan;
|
|
1999
|
+
/** Expression inside the substitution's braces. */
|
|
1400
2000
|
readonly expression: Expression;
|
|
2001
|
+
/** Following text: a middle fragment if another substitution follows, otherwise the closing tail. */
|
|
1401
2002
|
readonly literal: StringTemplateMiddleNode | StringTemplateTailNode;
|
|
1402
2003
|
}
|
|
2004
|
+
/** Shared decoded-text contract for the head, middle, and tail fragments of an interpolated string. */
|
|
1403
2005
|
export interface StringTemplateLiteralLikeNode extends BaseNode {
|
|
2006
|
+
/** Text without string or substitution delimiters, with escapes and triple-quote indentation processed. */
|
|
1404
2007
|
readonly value: string;
|
|
1405
2008
|
}
|
|
2009
|
+
/** Opening text fragment before an interpolated string's first `${...}` substitution. */
|
|
1406
2010
|
export interface StringTemplateHeadNode extends StringTemplateLiteralLikeNode {
|
|
2011
|
+
/** Identifies the initial fragment stored in {@link StringTemplateExpressionNode.head}. */
|
|
1407
2012
|
readonly kind: SyntaxKind.StringTemplateHead;
|
|
1408
2013
|
}
|
|
2014
|
+
/** Text fragment after one substitution and before the next in an interpolated string. */
|
|
1409
2015
|
export interface StringTemplateMiddleNode extends StringTemplateLiteralLikeNode {
|
|
2016
|
+
/** Indicates that another substitution follows this fragment. */
|
|
1410
2017
|
readonly kind: SyntaxKind.StringTemplateMiddle;
|
|
1411
2018
|
}
|
|
2019
|
+
/** Closing text fragment after the last substitution in an interpolated string. */
|
|
1412
2020
|
export interface StringTemplateTailNode extends StringTemplateLiteralLikeNode {
|
|
2021
|
+
/** Indicates that this fragment ends the interpolated string. */
|
|
1413
2022
|
readonly kind: SyntaxKind.StringTemplateTail;
|
|
1414
2023
|
}
|
|
2024
|
+
/** `extern` modifier token for a declaration implemented in JavaScript. */
|
|
1415
2025
|
export interface ExternKeywordNode extends BaseNode {
|
|
2026
|
+
/** Selects the externally implemented declaration modifier in {@link Modifier}. */
|
|
1416
2027
|
readonly kind: SyntaxKind.ExternKeyword;
|
|
1417
2028
|
}
|
|
2029
|
+
/** `internal` modifier token restricting a declaration's visibility to its package. */
|
|
1418
2030
|
export interface InternalKeywordNode extends BaseNode {
|
|
2031
|
+
/** Selects the package-visibility modifier in {@link Modifier}. */
|
|
1419
2032
|
readonly kind: SyntaxKind.InternalKeyword;
|
|
1420
2033
|
}
|
|
2034
|
+
/** `auto` modifier token requesting a compiler-provided decorator implementation. */
|
|
1421
2035
|
export interface AutoKeywordNode extends BaseNode {
|
|
2036
|
+
/** Selects the automatic-implementation modifier, mutually exclusive with `extern` on decorators. */
|
|
1422
2037
|
readonly kind: SyntaxKind.AutoKeyword;
|
|
1423
2038
|
}
|
|
2039
|
+
/** Intrinsic `void` type syntax, used for operations with no return value. */
|
|
1424
2040
|
export interface VoidKeywordNode extends BaseNode {
|
|
2041
|
+
/** Identifies the intrinsic keyword rather than an identifier named `void`. */
|
|
1425
2042
|
readonly kind: SyntaxKind.VoidKeyword;
|
|
1426
2043
|
}
|
|
2044
|
+
/** Intrinsic `never` type syntax, denoting a type with no possible values. */
|
|
1427
2045
|
export interface NeverKeywordNode extends BaseNode {
|
|
2046
|
+
/** Identifies the intrinsic keyword rather than a name resolved through lookup. */
|
|
1428
2047
|
readonly kind: SyntaxKind.NeverKeyword;
|
|
1429
2048
|
}
|
|
2049
|
+
/** Intrinsic `unknown` type syntax; the historical interface name does not imply an `any` keyword. */
|
|
1430
2050
|
export interface AnyKeywordNode extends BaseNode {
|
|
2051
|
+
/** Uses `UnknownKeyword` because the source spelling is `unknown`. */
|
|
1431
2052
|
readonly kind: SyntaxKind.UnknownKeyword;
|
|
1432
2053
|
}
|
|
2054
|
+
/** Infix type union such as `A | B`, distinct from a keyword-form union with variant declarations. */
|
|
1433
2055
|
export interface UnionExpressionNode extends BaseNode {
|
|
2056
|
+
/** Identifies infix union syntax rather than a named or inline keyword-form declaration. */
|
|
1434
2057
|
readonly kind: SyntaxKind.UnionExpression;
|
|
2058
|
+
/** Operand expressions in source order; parenthesized unions remain nested rather than being flattened here. */
|
|
1435
2059
|
readonly options: readonly Expression[];
|
|
1436
2060
|
}
|
|
2061
|
+
/** Infix intersection such as `A & B`, resolved to a model type by the checker. */
|
|
1437
2062
|
export interface IntersectionExpressionNode extends BaseNode {
|
|
2063
|
+
/** Identifies intersection syntax rather than an explicit model body. */
|
|
1438
2064
|
readonly kind: SyntaxKind.IntersectionExpression;
|
|
2065
|
+
/** Operand expressions in source order, before their properties are combined during checking. */
|
|
1439
2066
|
readonly options: readonly Expression[];
|
|
1440
2067
|
}
|
|
2068
|
+
/** Value constraint `valueof T`, permitting values whose types are assignable to the target type. */
|
|
1441
2069
|
export interface ValueOfExpressionNode extends BaseNode {
|
|
2070
|
+
/** Identifies a value constraint, not the type-of-value query written `typeof`. */
|
|
1442
2071
|
readonly kind: SyntaxKind.ValueOfExpression;
|
|
2072
|
+
/** Type expression following `valueof`. */
|
|
1443
2073
|
readonly target: Expression;
|
|
1444
2074
|
}
|
|
2075
|
+
/** Type query `typeof value`, obtaining the type of a value-producing expression. */
|
|
1445
2076
|
export interface TypeOfExpressionNode extends BaseNode {
|
|
2077
|
+
/** Identifies a type query rather than a `valueof` constraint. */
|
|
1446
2078
|
readonly kind: SyntaxKind.TypeOfExpression;
|
|
2079
|
+
/** Value-producing expression whose type is requested. */
|
|
1447
2080
|
readonly target: Expression;
|
|
1448
2081
|
}
|
|
2082
|
+
/** Name reference with an optional template argument list, interpreted in its checking context. */
|
|
1449
2083
|
export interface TypeReferenceNode extends BaseNode {
|
|
2084
|
+
/** Identifies a complete reference rather than a bare identifier or member-selection segment. */
|
|
1450
2085
|
readonly kind: SyntaxKind.TypeReference;
|
|
2086
|
+
/** Unqualified name or nested qualified name, excluding template arguments. */
|
|
1451
2087
|
readonly target: MemberExpressionNode | IdentifierNode;
|
|
2088
|
+
/** Explicit template arguments in source order; does not include inferred or default arguments. */
|
|
1452
2089
|
readonly arguments: readonly TemplateArgumentNode[];
|
|
1453
2090
|
}
|
|
2091
|
+
/** One positional expression or `name = expression` argument in a reference's `<...>` list. */
|
|
1454
2092
|
export interface TemplateArgumentNode extends BaseNode {
|
|
2093
|
+
/** Identifies an argument at a reference site, not a parameter declaration. */
|
|
1455
2094
|
readonly kind: SyntaxKind.TemplateArgument;
|
|
2095
|
+
/** Parameter name for a named argument; absent for positional arguments. */
|
|
1456
2096
|
readonly name?: IdentifierNode;
|
|
2097
|
+
/** Supplied argument expression, which may be checked as a type or value according to the parameter. */
|
|
1457
2098
|
readonly argument: Expression;
|
|
1458
2099
|
}
|
|
2100
|
+
/** Template parameter syntax, optionally constrained with `extends` and defaulted with `=`. */
|
|
1459
2101
|
export interface TemplateParameterDeclarationNode extends BaseNode {
|
|
2102
|
+
/** Identifies a declared template parameter rather than an argument supplied at a reference. */
|
|
1460
2103
|
readonly kind: SyntaxKind.TemplateParameterDeclaration;
|
|
2104
|
+
/** Explicit type, value, or mixed constraint following `extends`, absent when omitted. */
|
|
1461
2105
|
readonly constraint?: Expression;
|
|
2106
|
+
/** Argument expression to use when this parameter is omitted, absent when no default was written. */
|
|
1462
2107
|
readonly default?: Expression;
|
|
2108
|
+
/** Owning declaration after binding; declaration-expression owners may retain invalid template syntax for recovery. */
|
|
1463
2109
|
readonly parent?: TemplateableNode;
|
|
2110
|
+
/** Name introduced into the owning declaration's template scope. */
|
|
1464
2111
|
readonly id: IdentifierNode;
|
|
1465
2112
|
}
|
|
2113
|
+
/**
|
|
2114
|
+
* Bit mask derived from a declaration's modifier tokens.
|
|
2115
|
+
* Presence records parsed syntax, not validity; the checker enforces allowed and required combinations.
|
|
2116
|
+
*/
|
|
1466
2117
|
export declare const enum ModifierFlags {
|
|
2118
|
+
/** No modifier tokens were written. */
|
|
1467
2119
|
None = 0,
|
|
2120
|
+
/** An `extern` token requests a JavaScript implementation. */
|
|
1468
2121
|
Extern = 2,
|
|
2122
|
+
/** An `internal` token requests package-local visibility. */
|
|
1469
2123
|
Internal = 4,
|
|
2124
|
+
/** An `auto` token requests a compiler-provided decorator implementation. */
|
|
1470
2125
|
Auto = 8,
|
|
2126
|
+
/** Mask of every recognized modifier bit, not a combination valid on every declaration. */
|
|
1471
2127
|
All = 14
|
|
1472
2128
|
}
|
|
2129
|
+
/** Individual declaration modifier tokens, preserved separately from their combined bit mask. */
|
|
1473
2130
|
export type Modifier = ExternKeywordNode | InternalKeywordNode | AutoKeywordNode;
|
|
1474
2131
|
/**
|
|
1475
2132
|
* Represent a decorator declaration
|
|
@@ -1479,6 +2136,7 @@ export type Modifier = ExternKeywordNode | InternalKeywordNode | AutoKeywordNode
|
|
|
1479
2136
|
* ```
|
|
1480
2137
|
*/
|
|
1481
2138
|
export interface DecoratorDeclarationStatementNode extends BaseNode, DeclarationNode {
|
|
2139
|
+
/** Identifies a decorator signature declaration, not an application of that decorator. */
|
|
1482
2140
|
readonly kind: SyntaxKind.DecoratorDeclarationStatement;
|
|
1483
2141
|
/**
|
|
1484
2142
|
* Decorator target. First parameter.
|
|
@@ -1488,11 +2146,19 @@ export interface DecoratorDeclarationStatementNode extends BaseNode, Declaration
|
|
|
1488
2146
|
* Additional parameters
|
|
1489
2147
|
*/
|
|
1490
2148
|
readonly parameters: FunctionParameterNode[];
|
|
2149
|
+
/** Syntactic containing file or namespace after binding. */
|
|
1491
2150
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
1492
2151
|
}
|
|
2152
|
+
/**
|
|
2153
|
+
* Parameter syntax shared by functions, decorators, and scalar constructors.
|
|
2154
|
+
* Invalid optional/rest combinations remain in the AST and are reported as diagnostics.
|
|
2155
|
+
*/
|
|
1493
2156
|
export interface FunctionParameterNode extends BaseNode {
|
|
2157
|
+
/** Identifies signature-parameter syntax rather than an operation's model-property parameter. */
|
|
1494
2158
|
readonly kind: SyntaxKind.FunctionParameter;
|
|
2159
|
+
/** Parameter name without an optional marker or rest prefix. */
|
|
1495
2160
|
readonly id: IdentifierNode;
|
|
2161
|
+
/** Constraint following `:`; absent when omitted, in which case checking uses `unknown`. */
|
|
1496
2162
|
readonly type?: Expression;
|
|
1497
2163
|
/**
|
|
1498
2164
|
* Parameter defined with `?`
|
|
@@ -1512,9 +2178,13 @@ export interface FunctionParameterNode extends BaseNode {
|
|
|
1512
2178
|
* ```
|
|
1513
2179
|
*/
|
|
1514
2180
|
export interface FunctionDeclarationStatementNode extends BaseNode, DeclarationNode {
|
|
2181
|
+
/** Identifies a named function declaration, distinct from an anonymous function type expression. */
|
|
1515
2182
|
readonly kind: SyntaxKind.FunctionDeclarationStatement;
|
|
2183
|
+
/** Declared parameters in source order; the JavaScript context parameter is not part of this list. */
|
|
1516
2184
|
readonly parameters: FunctionParameterNode[];
|
|
2185
|
+
/** Constraint following `:`, absent when omitted; checking defaults the result constraint to `unknown`. */
|
|
1517
2186
|
readonly returnType?: Expression;
|
|
2187
|
+
/** Syntactic containing file or namespace after binding. */
|
|
1518
2188
|
readonly parent?: TypeSpecScriptNode | NamespaceStatementNode;
|
|
1519
2189
|
}
|
|
1520
2190
|
/**
|
|
@@ -1526,60 +2196,107 @@ export interface FunctionDeclarationStatementNode extends BaseNode, DeclarationN
|
|
|
1526
2196
|
* ```
|
|
1527
2197
|
*/
|
|
1528
2198
|
export interface FunctionTypeExpressionNode extends BaseNode {
|
|
2199
|
+
/** Identifies anonymous function type syntax, not a named function declaration. */
|
|
1529
2200
|
readonly kind: SyntaxKind.FunctionTypeExpression;
|
|
2201
|
+
/** Signature parameters in source order, including optional and rest markers. */
|
|
1530
2202
|
readonly parameters: FunctionParameterNode[];
|
|
2203
|
+
/** Constraint following `=>`, absent when omitted; checking defaults the result constraint to `unknown`. */
|
|
1531
2204
|
readonly returnType?: Expression;
|
|
1532
2205
|
}
|
|
2206
|
+
/** Syntactic role of an identifier, used to choose reference resolution and completion behavior. */
|
|
1533
2207
|
export interface IdentifierContext {
|
|
2208
|
+
/** Context category, not the semantic type or symbol category of the identifier. */
|
|
1534
2209
|
kind: IdentifierKind;
|
|
2210
|
+
/** First ancestor that is not a member-expression segment, retaining the construct that gives the name its role. */
|
|
1535
2211
|
node: Node;
|
|
1536
2212
|
}
|
|
2213
|
+
/** Identifier roles classified by `getIdentifierContext`, independently of whether lookup succeeds. */
|
|
1537
2214
|
export declare enum IdentifierKind {
|
|
2215
|
+
/** Name within a type reference, including segments of a qualified target. */
|
|
1538
2216
|
TypeReference = 0,
|
|
2217
|
+
/** Named template argument's parameter name, not the expression supplied as its argument. */
|
|
1539
2218
|
TemplateArgument = 1,
|
|
2219
|
+
/** Decorator name in an attached annotation or out-of-line augment statement. */
|
|
1540
2220
|
Decorator = 2,
|
|
2221
|
+
/** Invocation target in a call expression, not a function declaration's name. */
|
|
1541
2222
|
Function = 3,
|
|
2223
|
+
/** Namespace name targeted by a `using` statement. */
|
|
1542
2224
|
Using = 4,
|
|
2225
|
+
/** Declaration name not classified by one of the property-specific roles. */
|
|
1543
2226
|
Declaration = 5,
|
|
2227
|
+
/** Property name in a structural model expression, including operation parameters. */
|
|
1544
2228
|
ModelExpressionProperty = 6,
|
|
2229
|
+
/** Property name in a model statement or keyword-form model declaration expression. */
|
|
1545
2230
|
ModelStatementProperty = 7,
|
|
2231
|
+
/** Property name in a `#{ ... }` object value literal. */
|
|
1546
2232
|
ObjectLiteralProperty = 8,
|
|
2233
|
+
/** Name in syntax without a more specific resolution or declaration role. */
|
|
1547
2234
|
Other = 9
|
|
1548
2235
|
}
|
|
2236
|
+
/**
|
|
2237
|
+
* Parsed documentation comment, with free-form text separated from its block tags.
|
|
2238
|
+
* These nodes are available when documentation parsing is enabled.
|
|
2239
|
+
*/
|
|
1549
2240
|
export interface DocNode extends BaseNode {
|
|
2241
|
+
/** Identifies a complete documentation comment. */
|
|
1550
2242
|
readonly kind: SyntaxKind.Doc;
|
|
2243
|
+
/** Text outside block tags, in source order; inspect node text rather than array length for a description. */
|
|
1551
2244
|
readonly content: readonly DocContent[];
|
|
2245
|
+
/** Recognized and unrecognized block tags, in source order. */
|
|
1552
2246
|
readonly tags: readonly DocTag[];
|
|
1553
2247
|
}
|
|
2248
|
+
/** Common syntax retained for every documentation block tag. */
|
|
1554
2249
|
export interface DocTagBaseNode extends BaseNode {
|
|
2250
|
+
/** Written tag name without the leading `@`, including unrecognized names. */
|
|
1555
2251
|
readonly tagName: IdentifierNode;
|
|
2252
|
+
/** Descriptive text after the tag name and any parameter or property name. */
|
|
1556
2253
|
readonly content: readonly DocContent[];
|
|
1557
2254
|
}
|
|
2255
|
+
/** Supported documentation block tags, including a fallback for unrecognized tags. */
|
|
1558
2256
|
export type DocTag = DocReturnsTagNode | DocErrorsTagNode | DocParamTagNode | DocPropTagNode | DocTemplateTagNode | DocUnknownTagNode;
|
|
2257
|
+
/** Content within a documentation comment or tag; currently stored as text rather than parsed Markdown. */
|
|
1559
2258
|
export type DocContent = DocTextNode;
|
|
2259
|
+
/** A text segment from a documentation comment, retaining Markdown as text. */
|
|
1560
2260
|
export interface DocTextNode extends BaseNode {
|
|
2261
|
+
/** Identifies documentation text rather than a block tag. */
|
|
1561
2262
|
readonly kind: SyntaxKind.DocText;
|
|
2263
|
+
/** Text with comment-line prefixes removed, line endings normalized, and outer whitespace trimmed. */
|
|
1562
2264
|
readonly text: string;
|
|
1563
2265
|
}
|
|
2266
|
+
/** Return-value documentation introduced by either `@return` or `@returns`. */
|
|
1564
2267
|
export interface DocReturnsTagNode extends DocTagBaseNode {
|
|
2268
|
+
/** Identifies either spelling of the return-documentation tag. */
|
|
1565
2269
|
readonly kind: SyntaxKind.DocReturnsTag;
|
|
1566
2270
|
}
|
|
2271
|
+
/** Error-response documentation introduced by `@errors`. */
|
|
1567
2272
|
export interface DocErrorsTagNode extends DocTagBaseNode {
|
|
2273
|
+
/** Identifies an error-documentation tag. */
|
|
1568
2274
|
readonly kind: SyntaxKind.DocErrorsTag;
|
|
1569
2275
|
}
|
|
2276
|
+
/** Documentation associated with the named parameter of a declaration. */
|
|
1570
2277
|
export interface DocParamTagNode extends DocTagBaseNode {
|
|
2278
|
+
/** Identifies an `@param` tag. */
|
|
1571
2279
|
readonly kind: SyntaxKind.DocParamTag;
|
|
2280
|
+
/** Parameter name as written in the comment, not a resolved parameter declaration. */
|
|
1572
2281
|
readonly paramName: IdentifierNode;
|
|
1573
2282
|
}
|
|
2283
|
+
/** Documentation associated with the named property of a model. */
|
|
1574
2284
|
export interface DocPropTagNode extends DocTagBaseNode {
|
|
2285
|
+
/** Identifies an `@prop` tag. */
|
|
1575
2286
|
readonly kind: SyntaxKind.DocPropTag;
|
|
2287
|
+
/** Property name as written in the comment, not a resolved property declaration. */
|
|
1576
2288
|
readonly propName: IdentifierNode;
|
|
1577
2289
|
}
|
|
2290
|
+
/** Documentation associated with a named template parameter. */
|
|
1578
2291
|
export interface DocTemplateTagNode extends DocTagBaseNode {
|
|
2292
|
+
/** Identifies an `@template` tag. */
|
|
1579
2293
|
readonly kind: SyntaxKind.DocTemplateTag;
|
|
2294
|
+
/** Template parameter name as written in the comment. */
|
|
1580
2295
|
readonly paramName: IdentifierNode;
|
|
1581
2296
|
}
|
|
2297
|
+
/** Unrecognized block tag retained for tools without assigning built-in semantics. */
|
|
1582
2298
|
export interface DocUnknownTagNode extends DocTagBaseNode {
|
|
2299
|
+
/** Identifies a tag whose name has no specialized documentation node. */
|
|
1583
2300
|
readonly kind: SyntaxKind.DocUnknownTag;
|
|
1584
2301
|
}
|
|
1585
2302
|
/**
|
|
@@ -1601,15 +2318,30 @@ export interface LineAndCharacter {
|
|
|
1601
2318
|
*/
|
|
1602
2319
|
character: number;
|
|
1603
2320
|
}
|
|
2321
|
+
/** Loaded JavaScript module represented in the syntax graph without parsing its JavaScript source. */
|
|
1604
2322
|
export interface JsSourceFileNode extends DeclarationNode, BaseNode {
|
|
2323
|
+
/** Distinguishes a loaded JavaScript module from a parsed TypeSpec script. */
|
|
1605
2324
|
readonly kind: SyntaxKind.JsSourceFile;
|
|
2325
|
+
/** Empty source file carrying the module's path for diagnostic locations. */
|
|
1606
2326
|
readonly file: SourceFile;
|
|
2327
|
+
/** Module namespace object returned by the host's JavaScript import operation. */
|
|
1607
2328
|
readonly esmExports: any;
|
|
1608
2329
|
}
|
|
2330
|
+
/** Namespace declaration synthesized while binding JavaScript implementations to TypeSpec namespaces. */
|
|
1609
2331
|
export interface JsNamespaceDeclarationNode extends DeclarationNode, BaseNode {
|
|
2332
|
+
/** Distinguishes a JavaScript-provided namespace from a namespace written in TypeSpec. */
|
|
1610
2333
|
readonly kind: SyntaxKind.JsNamespaceDeclaration;
|
|
1611
2334
|
}
|
|
2335
|
+
/**
|
|
2336
|
+
* Implementation of a library's `$onEmit` hook, invoked during emission after checking,
|
|
2337
|
+
* validation, and linting. The compiler awaits a returned promise before continuing.
|
|
2338
|
+
* Report issues through the context's program rather than returning diagnostics.
|
|
2339
|
+
*/
|
|
1612
2340
|
export type EmitterFunc = (context: EmitContext) => Promise<void> | void;
|
|
2341
|
+
/**
|
|
2342
|
+
* Source text and diagnostic identity shared by syntax nodes and source locations.
|
|
2343
|
+
* Positions and line mappings refer to this text snapshot, not a subsequently modified file.
|
|
2344
|
+
*/
|
|
1613
2345
|
export interface SourceFile {
|
|
1614
2346
|
/** The source code text. */
|
|
1615
2347
|
readonly text: string;
|
|
@@ -1643,19 +2375,24 @@ export interface SourceFile {
|
|
|
1643
2375
|
export type LocationContext = ProjectLocationContext | CompilerLocationContext | SyntheticLocationContext | LibraryLocationContext;
|
|
1644
2376
|
/** Defined in the user project. */
|
|
1645
2377
|
export interface ProjectLocationContext {
|
|
2378
|
+
/** Identifies source belonging to the consuming project rather than a dependency. */
|
|
1646
2379
|
readonly type: "project";
|
|
2380
|
+
/** Package flags exported by the project's JavaScript code, when available. */
|
|
1647
2381
|
readonly flags?: PackageFlags;
|
|
1648
2382
|
}
|
|
1649
2383
|
/** Built-in */
|
|
1650
2384
|
export interface CompilerLocationContext {
|
|
2385
|
+
/** Identifies the compiler's standard-library source. */
|
|
1651
2386
|
readonly type: "compiler";
|
|
1652
2387
|
}
|
|
1653
2388
|
/** Refer to a type that was not declared in a file */
|
|
1654
2389
|
export interface SyntheticLocationContext {
|
|
2390
|
+
/** Identifies a target for which no source-file location exists. */
|
|
1655
2391
|
readonly type: "synthetic";
|
|
1656
2392
|
}
|
|
1657
2393
|
/** Defined in a library. */
|
|
1658
2394
|
export interface LibraryLocationContext {
|
|
2395
|
+
/** Identifies source loaded from a library package. */
|
|
1659
2396
|
readonly type: "library";
|
|
1660
2397
|
/** Library metadata */
|
|
1661
2398
|
readonly metadata: ModuleLibraryMetadata;
|
|
@@ -1668,38 +2405,51 @@ export interface LibraryLocationContext {
|
|
|
1668
2405
|
*/
|
|
1669
2406
|
readonly features?: readonly string[];
|
|
1670
2407
|
}
|
|
2408
|
+
/** Resolution and exported contracts of a JavaScript library loaded by the program. */
|
|
1671
2409
|
export interface LibraryInstance {
|
|
2410
|
+
/** Resolved package or standalone file from which the JavaScript entry point was loaded. */
|
|
1672
2411
|
module: ModuleResolutionResult;
|
|
2412
|
+
/** Loaded JavaScript entry point and its exports. */
|
|
1673
2413
|
entrypoint: JsSourceFileNode;
|
|
2414
|
+
/** Package metadata, or standalone-file metadata when no package was resolved. */
|
|
1674
2415
|
metadata: LibraryMetadata;
|
|
2416
|
+
/** The entry point's `$lib` export, if it declares a TypeSpec library. */
|
|
1675
2417
|
definition?: TypeSpecLibrary<any>;
|
|
2418
|
+
/** Resolved `$linter` export; populated when the entry point provides a linter. */
|
|
1676
2419
|
linter: LinterResolvedDefinition;
|
|
1677
2420
|
}
|
|
2421
|
+
/** Metadata discriminated by whether the library resolved to a package or a standalone file. */
|
|
1678
2422
|
export type LibraryMetadata = FileLibraryMetadata | ModuleLibraryMetadata;
|
|
2423
|
+
/** Optional package information used to describe a library and direct consumers to support resources. */
|
|
1679
2424
|
interface LibraryMetadataBase {
|
|
1680
2425
|
/** Library homepage. */
|
|
1681
2426
|
homepage?: string;
|
|
1682
2427
|
/** Library version */
|
|
1683
2428
|
version?: string;
|
|
2429
|
+
/** Issue-tracker metadata, when supplied by the package. */
|
|
1684
2430
|
bugs?: {
|
|
1685
2431
|
/** Url where to file bugs for this library. */
|
|
1686
2432
|
url?: string;
|
|
1687
2433
|
};
|
|
1688
2434
|
}
|
|
2435
|
+
/** Metadata for a standalone JavaScript file, whose name may come from its `$lib` export. */
|
|
1689
2436
|
export interface FileLibraryMetadata extends LibraryMetadataBase {
|
|
2437
|
+
/** Identifies a library resolved directly to a file rather than a package. */
|
|
1690
2438
|
type: "file";
|
|
1691
2439
|
/** Library name as specified in the package.json or in exported $lib. */
|
|
1692
2440
|
name?: string;
|
|
1693
2441
|
}
|
|
1694
2442
|
/** Data for a library. Either loaded via a node_modules package or a standalone js file */
|
|
1695
2443
|
export interface ModuleLibraryMetadata extends LibraryMetadataBase {
|
|
2444
|
+
/** Identifies a library resolved through a package manifest. */
|
|
1696
2445
|
readonly type: "module";
|
|
1697
2446
|
/** Library name as specified in the package.json or in exported $lib. */
|
|
1698
2447
|
readonly name: string;
|
|
1699
2448
|
}
|
|
2449
|
+
/** Half-open range of UTF-16 code-unit offsets in a source string. */
|
|
1700
2450
|
export interface TextRange {
|
|
1701
2451
|
/**
|
|
1702
|
-
* The starting position of the
|
|
2452
|
+
* The starting position of the range measured in UTF-16 code units from the
|
|
1703
2453
|
* start of the full string. Inclusive.
|
|
1704
2454
|
*/
|
|
1705
2455
|
readonly pos: number;
|
|
@@ -1709,8 +2459,11 @@ export interface TextRange {
|
|
|
1709
2459
|
*/
|
|
1710
2460
|
readonly end: number;
|
|
1711
2461
|
}
|
|
2462
|
+
/** A source range together with the text snapshot to which its offsets refer. */
|
|
1712
2463
|
export interface SourceLocation extends TextRange {
|
|
2464
|
+
/** Source text and path used to resolve the range into line and character coordinates. */
|
|
1713
2465
|
file: SourceFile;
|
|
2466
|
+
/** True when the location is a placeholder rather than a range in actual source text. */
|
|
1714
2467
|
isSynthetic?: boolean;
|
|
1715
2468
|
}
|
|
1716
2469
|
/** Used to explicitly specify that a diagnostic has no target. */
|
|
@@ -1724,24 +2477,50 @@ export interface TemplateInstanceTarget {
|
|
|
1724
2477
|
/** Template mapper used. */
|
|
1725
2478
|
readonly templateMapper: TypeMapper;
|
|
1726
2479
|
}
|
|
2480
|
+
/** Semantic or syntax target resolved to a location when reporting, or an explicit source range. */
|
|
1727
2481
|
export type DiagnosticTarget = TypeSpecDiagnosticTarget | SourceLocation;
|
|
2482
|
+
/** Whether an issue prevents successful compilation or is a potentially suppressible warning. */
|
|
1728
2483
|
export type DiagnosticSeverity = "error" | "warning";
|
|
2484
|
+
/**
|
|
2485
|
+
* A fully formatted compiler or library issue. Creating a diagnostic does not report it;
|
|
2486
|
+
* pass it to the program's reporting APIs or return it to the caller as appropriate.
|
|
2487
|
+
*/
|
|
1729
2488
|
export interface Diagnostic {
|
|
2489
|
+
/** Diagnostic identifier, qualified as `<library-name>/<code>` for library diagnostics. */
|
|
1730
2490
|
code: string;
|
|
2491
|
+
/**
|
|
2492
|
+
* Factories use the definition's severity. Program reporting may promote warnings
|
|
2493
|
+
* to errors in `program.diagnostics` when `warningAsError` is enabled.
|
|
2494
|
+
*/
|
|
1731
2495
|
severity: DiagnosticSeverity;
|
|
2496
|
+
/** Human-readable message with any diagnostic format arguments already substituted. */
|
|
1732
2497
|
message: string;
|
|
2498
|
+
/** Location-bearing target, or {@link NoTarget} for an issue without a source location. */
|
|
1733
2499
|
target: DiagnosticTarget | typeof NoTarget;
|
|
2500
|
+
/** Available fixes offered to consumers; attaching a fix does not execute it. */
|
|
1734
2501
|
readonly codefixes?: readonly CodeFix[];
|
|
1735
2502
|
}
|
|
2503
|
+
/** A suggested source change that is resolved only when a consumer requests the fix. */
|
|
1736
2504
|
export interface CodeFix {
|
|
2505
|
+
/** Stable identifier used to select this fix, including by command-line code-fix selection. */
|
|
1737
2506
|
readonly id: string;
|
|
2507
|
+
/** Human-readable action label shown to users choosing a fix. */
|
|
1738
2508
|
readonly label: string;
|
|
2509
|
+
/**
|
|
2510
|
+
* Computes edits when the fix is resolved, not when its diagnostic is reported.
|
|
2511
|
+
* Context helpers only construct edits: return them to have the caller apply them.
|
|
2512
|
+
* Returning nothing, including from an asynchronous callback, contributes no edits.
|
|
2513
|
+
*/
|
|
1739
2514
|
readonly fix: (fixContext: CodeFixContext) => CodeFixEdit | CodeFixEdit[] | Promise<void> | void;
|
|
1740
2515
|
}
|
|
2516
|
+
/** A UTF-16 insertion offset associated with a particular source-text snapshot. */
|
|
1741
2517
|
export interface FilePos {
|
|
2518
|
+
/** Zero-based offset from the start of the file's text. */
|
|
1742
2519
|
readonly pos: number;
|
|
2520
|
+
/** Source snapshot whose text the offset indexes. */
|
|
1743
2521
|
readonly file: SourceFile;
|
|
1744
2522
|
}
|
|
2523
|
+
/** Factories for text edits; calling them does not modify the source file. */
|
|
1745
2524
|
export interface CodeFixContext {
|
|
1746
2525
|
/** Add the given text before the range or pos given. */
|
|
1747
2526
|
readonly prependText: (location: SourceLocation | FilePos, text: string) => InsertTextCodeFixEdit;
|
|
@@ -1750,38 +2529,65 @@ export interface CodeFixContext {
|
|
|
1750
2529
|
/** Replace the text at the given range. */
|
|
1751
2530
|
readonly replaceText: (location: SourceLocation, newText: string) => ReplaceTextCodeFixEdit;
|
|
1752
2531
|
}
|
|
2532
|
+
/**
|
|
2533
|
+
* Text insertion or half-open range replacement against an original source snapshot.
|
|
2534
|
+
* Fixes must provide compatible, non-overlapping edits; application orders edits by offset.
|
|
2535
|
+
*/
|
|
1753
2536
|
export type CodeFixEdit = InsertTextCodeFixEdit | ReplaceTextCodeFixEdit;
|
|
2537
|
+
/** Inserts text at an offset without removing any existing characters. */
|
|
1754
2538
|
export interface InsertTextCodeFixEdit {
|
|
2539
|
+
/** Selects insertion rather than range replacement. */
|
|
1755
2540
|
readonly kind: "insert-text";
|
|
2541
|
+
/** Text to insert verbatim. */
|
|
1756
2542
|
readonly text: string;
|
|
2543
|
+
/** Zero-based UTF-16 offset in the original file text. */
|
|
1757
2544
|
readonly pos: number;
|
|
2545
|
+
/** Source snapshot to edit; its path identifies the output file. */
|
|
1758
2546
|
readonly file: SourceFile;
|
|
1759
2547
|
}
|
|
2548
|
+
/** Replaces the inherited half-open range; an empty replacement deletes the range. */
|
|
1760
2549
|
export interface ReplaceTextCodeFixEdit extends TextRange {
|
|
2550
|
+
/** Selects replacement of a source range. */
|
|
1761
2551
|
readonly kind: "replace-text";
|
|
2552
|
+
/** Replacement text, or an empty string to remove the range. */
|
|
1762
2553
|
readonly text: string;
|
|
2554
|
+
/** Source snapshot to edit; range offsets refer to its original text. */
|
|
1763
2555
|
readonly file: SourceFile;
|
|
1764
2556
|
}
|
|
1765
2557
|
/**
|
|
1766
2558
|
* Return type of accessor functions in TypeSpec.
|
|
1767
2559
|
* Tuple composed of:
|
|
1768
2560
|
* - 0: Actual result of an accessor function
|
|
1769
|
-
* - 1:
|
|
2561
|
+
* - 1: Diagnostics produced while retrieving the data, in collection order.
|
|
2562
|
+
*
|
|
2563
|
+
* Callers own reporting or propagating the returned diagnostics; the tuple itself
|
|
2564
|
+
* does not report them to a program. An empty list indicates no collected issues.
|
|
1770
2565
|
*/
|
|
1771
2566
|
export type DiagnosticResult<T> = [T, readonly Diagnostic[]];
|
|
2567
|
+
/** Syntax origin shared by interpreted compiler directives. */
|
|
1772
2568
|
export interface DirectiveBase {
|
|
2569
|
+
/** Original directive expression used to locate diagnostics about the directive. */
|
|
1773
2570
|
node: DirectiveExpressionNode;
|
|
1774
2571
|
}
|
|
2572
|
+
/** Interpreted suppression or deprecation directive attached to a declaration. */
|
|
1775
2573
|
export type Directive = SuppressDirective | DeprecatedDirective;
|
|
2574
|
+
/** A `#suppress` directive requesting suppression of a matching warning in its scope. */
|
|
1776
2575
|
export interface SuppressDirective extends DirectiveBase {
|
|
2576
|
+
/** Selects warning-suppression semantics. */
|
|
1777
2577
|
name: "suppress";
|
|
2578
|
+
/** Diagnostic or linter rule code to suppress; error diagnostics cannot be suppressed. */
|
|
1778
2579
|
code: string;
|
|
2580
|
+
/** Author-supplied explanation for suppressing the warning. */
|
|
1779
2581
|
message: string;
|
|
1780
2582
|
}
|
|
2583
|
+
/** A `#deprecated` directive marking a declaration as deprecated for its consumers. */
|
|
1781
2584
|
export interface DeprecatedDirective extends DirectiveBase {
|
|
2585
|
+
/** Selects deprecation rather than warning suppression. */
|
|
1782
2586
|
name: "deprecated";
|
|
2587
|
+
/** Explanation surfaced when the deprecated declaration is used. */
|
|
1783
2588
|
message: string;
|
|
1784
2589
|
}
|
|
2590
|
+
/** Controls whether a host removal operation descends into a directory's contents. */
|
|
1785
2591
|
export interface RmOptions {
|
|
1786
2592
|
/**
|
|
1787
2593
|
* If `true`, perform a recursive directory removal. In
|
|
@@ -1791,6 +2597,10 @@ export interface RmOptions {
|
|
|
1791
2597
|
*/
|
|
1792
2598
|
recursive?: boolean;
|
|
1793
2599
|
}
|
|
2600
|
+
/**
|
|
2601
|
+
* Asynchronous file-system and URL capabilities used by compiler infrastructure.
|
|
2602
|
+
* Hosts can be backed by a real or virtual file system; I/O failures reject the returned promises.
|
|
2603
|
+
*/
|
|
1794
2604
|
export interface SystemHost {
|
|
1795
2605
|
/** read a file at the given url. */
|
|
1796
2606
|
readUrl(url: string): Promise<SourceFile>;
|
|
@@ -1818,23 +2628,38 @@ export interface SystemHost {
|
|
|
1818
2628
|
* @param path Path to the directory.
|
|
1819
2629
|
*/
|
|
1820
2630
|
mkdirp(path: string): Promise<string | undefined>;
|
|
2631
|
+
/** Inspects a path; the returned predicates identify directories and regular files respectively. */
|
|
1821
2632
|
stat(path: string): Promise<{
|
|
1822
2633
|
isDirectory(): boolean;
|
|
1823
2634
|
isFile(): boolean;
|
|
1824
2635
|
}>;
|
|
2636
|
+
/** Resolves a possibly symlinked path to its real file-system path. */
|
|
1825
2637
|
realpath(path: string): Promise<string>;
|
|
1826
2638
|
}
|
|
2639
|
+
/**
|
|
2640
|
+
* Host capabilities required to compile TypeSpec, extending file I/O with module loading,
|
|
2641
|
+
* source-kind detection, standard-library discovery, and log delivery.
|
|
2642
|
+
*/
|
|
1827
2643
|
export interface CompilerHost extends SystemHost {
|
|
1828
2644
|
/**
|
|
1829
2645
|
* Optional cache to reuse the results of parsing and binding across programs.
|
|
2646
|
+
* Entries are keyed by source-file identity, not path; reuse a source snapshot only
|
|
2647
|
+
* while its text is unchanged.
|
|
1830
2648
|
*/
|
|
1831
2649
|
parseCache?: WeakMap<SourceFile, TypeSpecScriptNode>;
|
|
2650
|
+
/** Returns the compiler's installation root, used to locate bundled compiler resources. */
|
|
1832
2651
|
getExecutionRoot(): string;
|
|
2652
|
+
/** Returns directories containing standard-library entry points to load for compilation. */
|
|
1833
2653
|
getLibDirs(): string[];
|
|
2654
|
+
/** Loads a JavaScript module and returns its module namespace object, including TypeSpec hook exports. */
|
|
1834
2655
|
getJsImport(path: string): Promise<Record<string, any>>;
|
|
2656
|
+
/** Classifies a source path for loading, or returns undefined when the host does not recognize it. */
|
|
1835
2657
|
getSourceFileKind(path: string): SourceFileKind | undefined;
|
|
2658
|
+
/** Converts a file URL into a path understood by this host's file-system operations. */
|
|
1836
2659
|
fileURLToPath(url: string): string;
|
|
2660
|
+
/** Converts a host file-system path into a file URL. */
|
|
1837
2661
|
pathToFileURL(path: string): string;
|
|
2662
|
+
/** Receives processed log messages produced by compiler logging. */
|
|
1838
2663
|
logSink: LogSink;
|
|
1839
2664
|
}
|
|
1840
2665
|
/**
|
|
@@ -1842,9 +2667,11 @@ export interface CompilerHost extends SystemHost {
|
|
|
1842
2667
|
*/
|
|
1843
2668
|
export type SourceFileKind = "typespec" | "js";
|
|
1844
2669
|
type UnionToIntersection<T> = (T extends any ? (k: T) => void : never) extends (k: infer I) => void ? I : never;
|
|
2670
|
+
/** Traversal control returned by semantic listeners when the navigation API honors callback results. */
|
|
1845
2671
|
export declare enum ListenerFlow {
|
|
1846
2672
|
/**
|
|
1847
|
-
*
|
|
2673
|
+
* Skip recursive traversal from the current type, and its exit callback when
|
|
2674
|
+
* that navigation path checks this result. This does not stop the whole walk.
|
|
1848
2675
|
*/
|
|
1849
2676
|
NoRecursion = 1
|
|
1850
2677
|
}
|
|
@@ -1856,14 +2683,26 @@ type exitListener<T extends string | number | symbol> = T extends string ? `exit
|
|
|
1856
2683
|
type ListenerForType<T extends Type> = T extends Type ? {
|
|
1857
2684
|
[k in Uncapitalize<T["kind"]> | exitListener<T["kind"]>]?: TypeListener<T>;
|
|
1858
2685
|
} : never;
|
|
2686
|
+
/**
|
|
2687
|
+
* Optional synchronous callbacks keyed by uncapitalized type kind, such as `model`,
|
|
2688
|
+
* and corresponding exit names, such as `exitModel`.
|
|
2689
|
+
* Entry callbacks run before following the type's relationships; exit callbacks,
|
|
2690
|
+
* where emitted by the walker, run afterward. This walks the semantic graph, not syntax.
|
|
2691
|
+
*/
|
|
1859
2692
|
export type TypeListeners = UnionToIntersection<ListenerForType<Type>>;
|
|
1860
2693
|
type ValueListener<V> = (context: V) => ListenerFlow | undefined | void;
|
|
1861
2694
|
type exitValueListener<T extends string | number | symbol> = T extends string ? `exit${T}` : T;
|
|
1862
2695
|
type ListenerForValue<V extends Value> = V extends Value ? {
|
|
1863
2696
|
[k in Uncapitalize<V["valueKind"]> | exitValueListener<V["valueKind"]>]?: ValueListener<V>;
|
|
1864
2697
|
} : never;
|
|
2698
|
+
/**
|
|
2699
|
+
* Optional synchronous callbacks keyed by uncapitalized value kind and corresponding
|
|
2700
|
+
* exit names. A callback is invoked only when the selected navigation API visits that value.
|
|
2701
|
+
*/
|
|
1865
2702
|
export type ValueListeners = UnionToIntersection<ListenerForValue<Value>>;
|
|
2703
|
+
/** Callbacks for semantic navigation, with an optional program-level entry event. */
|
|
1866
2704
|
export type SemanticNodeListener = {
|
|
2705
|
+
/** Called once by program navigation before visiting the global namespace. */
|
|
1867
2706
|
root?: (context: Program) => void | undefined;
|
|
1868
2707
|
} & TypeListeners & ValueListeners;
|
|
1869
2708
|
/**
|
|
@@ -1896,18 +2735,24 @@ export interface TypeInfoContext {
|
|
|
1896
2735
|
* Providers are gated behind the experimental `type-info-provider` compiler feature.
|
|
1897
2736
|
*/
|
|
1898
2737
|
export type TypeInfoProvider = (context: TypeInfoContext) => TypeInfo | undefined;
|
|
2738
|
+
/** Input to a diagnostic factory before a source target is attached. */
|
|
1899
2739
|
export type DiagnosticReportWithoutTarget<T extends {
|
|
1900
2740
|
[code: string]: DiagnosticMessages;
|
|
1901
2741
|
}, C extends keyof T, M extends keyof T[C] = "default"> = {
|
|
2742
|
+
/** Unqualified code declared in the diagnostic map. */
|
|
1902
2743
|
code: C;
|
|
2744
|
+
/** Message variant to format; omitted selects `"default"`. */
|
|
1903
2745
|
messageId?: M;
|
|
2746
|
+
/** Optional fixes to attach to the created diagnostic without executing them. */
|
|
1904
2747
|
readonly codefixes?: readonly CodeFix[];
|
|
1905
2748
|
} & DiagnosticFormat<T, C, M>;
|
|
2749
|
+
/** Complete diagnostic-factory input, including a source-location target or explicit {@link NoTarget}. */
|
|
1906
2750
|
export type DiagnosticReport<T extends {
|
|
1907
2751
|
[code: string]: DiagnosticMessages;
|
|
1908
2752
|
}, C extends keyof T, M extends keyof T[C] = "default"> = DiagnosticReportWithoutTarget<T, C, M> & {
|
|
1909
2753
|
target: DiagnosticTarget | typeof NoTarget;
|
|
1910
2754
|
};
|
|
2755
|
+
/** Requires a `format` map of named string substitutions when the selected message is a callable message template. */
|
|
1911
2756
|
export type DiagnosticFormat<T extends {
|
|
1912
2757
|
[code: string]: DiagnosticMessages;
|
|
1913
2758
|
}, C extends keyof T, M extends keyof T[C] = "default"> = T[C][M] extends CallableMessage<infer A> ? {
|
|
@@ -1949,38 +2794,62 @@ export interface DiagnosticDefinition<M extends DiagnosticMessages> {
|
|
|
1949
2794
|
*/
|
|
1950
2795
|
readonly docs?: string | FileRef;
|
|
1951
2796
|
}
|
|
2797
|
+
/** Named message variants for one diagnostic or linter rule; `"default"` is used when no variant is selected. */
|
|
1952
2798
|
export interface DiagnosticMessages {
|
|
2799
|
+
/** Literal text or a formatter keyed by the message variant name. */
|
|
1953
2800
|
readonly [messageId: string]: string | CallableMessage<string[]>;
|
|
1954
2801
|
}
|
|
2802
|
+
/** Message formatter produced by {@link paramMessage}, with its substitution names retained for typing. */
|
|
1955
2803
|
export interface CallableMessage<T extends string[]> {
|
|
2804
|
+
/** Substitution names in template order; names may repeat when referenced more than once. */
|
|
1956
2805
|
keys: T;
|
|
2806
|
+
/** Formats the message using the supplied string value for each substitution name. */
|
|
1957
2807
|
(dict: Record<T[number], string>): string;
|
|
1958
2808
|
}
|
|
2809
|
+
/** Diagnostic definitions keyed by unqualified diagnostic code, preserving each code's message variants. */
|
|
1959
2810
|
export type DiagnosticMap<T extends {
|
|
1960
2811
|
[code: string]: DiagnosticMessages;
|
|
1961
2812
|
}> = {
|
|
2813
|
+
/** Severity, message variants, and optional metadata for this diagnostic code. */
|
|
1962
2814
|
readonly [code in keyof T]: DiagnosticDefinition<T[code]>;
|
|
1963
2815
|
};
|
|
2816
|
+
/** Typed factory and reporting operations for a fixed set of diagnostic definitions. */
|
|
1964
2817
|
export interface DiagnosticCreator<T extends {
|
|
1965
2818
|
[code: string]: DiagnosticMessages;
|
|
1966
2819
|
}> {
|
|
2820
|
+
/** Type-only carrier for message inference; not populated by the diagnostic creator at runtime. */
|
|
1967
2821
|
readonly type: T;
|
|
2822
|
+
/** Definitions used to determine severity and format messages. */
|
|
1968
2823
|
readonly diagnostics: DiagnosticMap<T>;
|
|
2824
|
+
/**
|
|
2825
|
+
* Formats a diagnostic without reporting it. Throws if the code or selected message
|
|
2826
|
+
* is not defined; library-scoped creators qualify the resulting diagnostic code.
|
|
2827
|
+
*/
|
|
1969
2828
|
createDiagnostic<C extends keyof T, M extends keyof T[C] = "default">(diag: DiagnosticReport<T, C, M>): Diagnostic;
|
|
2829
|
+
/** Creates and reports the diagnostic through the program, which applies its reporting policies. */
|
|
1970
2830
|
reportDiagnostic<C extends keyof T, M extends keyof T[C] = "default">(program: Program, diag: DiagnosticReport<T, C, M>): void;
|
|
1971
2831
|
}
|
|
2832
|
+
/** Extracts the code-to-message type from a diagnostic definition map for reuse in generic APIs. */
|
|
1972
2833
|
export type TypeOfDiagnostics<T extends DiagnosticMap<any>> = T extends DiagnosticMap<infer D> ? D : never;
|
|
2834
|
+
/** JSON Schema typed against an emitter's options, used to validate configured option values. */
|
|
1973
2835
|
export type JSONSchemaType<T> = AjvJSONSchemaType<T>;
|
|
2836
|
+
/** Metadata for a library state key whose symbol is created with the library. */
|
|
1974
2837
|
export interface StateDef {
|
|
1975
2838
|
/**
|
|
1976
2839
|
* Description for this state.
|
|
1977
2840
|
*/
|
|
1978
2841
|
readonly description?: string;
|
|
1979
2842
|
}
|
|
2843
|
+
/** Opt-in compiler behavior supported by a library or emitter. */
|
|
1980
2844
|
export interface TypeSpecLibraryCapabilities {
|
|
1981
|
-
/**
|
|
2845
|
+
/**
|
|
2846
|
+
* Allows an emitter to run during dry-run compilation. The emitter must inspect
|
|
2847
|
+
* the program's dry-run option and avoid writing output while still reporting diagnostics.
|
|
2848
|
+
* Emitters without this capability are skipped in dry-run mode.
|
|
2849
|
+
*/
|
|
1982
2850
|
readonly dryRun?: boolean;
|
|
1983
2851
|
}
|
|
2852
|
+
/** Definition supplied to {@link createTypeSpecLibrary} and typically exported as `$lib`. */
|
|
1984
2853
|
export interface TypeSpecLibraryDef<T extends {
|
|
1985
2854
|
[code: string]: DiagnosticMessages;
|
|
1986
2855
|
}, E extends Record<string, any> = Record<string, never>, State extends string = never> {
|
|
@@ -2007,11 +2876,13 @@ export interface TypeSpecLibraryDef<T extends {
|
|
|
2007
2876
|
*/
|
|
2008
2877
|
readonly requireImports?: readonly string[];
|
|
2009
2878
|
/**
|
|
2010
|
-
* Emitter configuration if library is an emitter.
|
|
2879
|
+
* Emitter configuration if library is an emitter. Its optional `options` JSON Schema
|
|
2880
|
+
* validates custom configuration before the emitter runs; omit it when no schema is supplied.
|
|
2011
2881
|
*/
|
|
2012
2882
|
readonly emitter?: {
|
|
2013
2883
|
options?: JSONSchemaType<E>;
|
|
2014
2884
|
};
|
|
2885
|
+
/** Named state definitions used to create the corresponding symbols in the library's `stateKeys` map. */
|
|
2015
2886
|
readonly state?: Record<State, StateDef>;
|
|
2016
2887
|
}
|
|
2017
2888
|
/**
|
|
@@ -2028,7 +2899,9 @@ export interface TypeSpecLibraryDef<T extends {
|
|
|
2028
2899
|
* ```
|
|
2029
2900
|
*/
|
|
2030
2901
|
export interface DecoratorImplementations {
|
|
2902
|
+
/** Implementations grouped by fully qualified TypeSpec namespace, not JavaScript module path. */
|
|
2031
2903
|
readonly [namespace: string]: {
|
|
2904
|
+
/** Decorator implementations keyed by their TypeSpec names, without the JavaScript `$` prefix. */
|
|
2032
2905
|
readonly [name: string]: DecoratorFunction;
|
|
2033
2906
|
};
|
|
2034
2907
|
}
|
|
@@ -2037,18 +2910,29 @@ export interface FunctionImplementations {
|
|
|
2037
2910
|
readonly [name: string]: (ctx: FunctionContext, ...parameters: never[]) => unknown;
|
|
2038
2911
|
};
|
|
2039
2912
|
}
|
|
2913
|
+
/** Extension point for package-level flags exported as `$flags`; no flags are currently predefined. */
|
|
2040
2914
|
export interface PackageFlags {
|
|
2041
2915
|
}
|
|
2916
|
+
/** A library's `$linter` export: available rules and optional named rule-set configurations. */
|
|
2042
2917
|
export interface LinterDefinition {
|
|
2918
|
+
/** Rule definitions in registration order; listing a rule does not enable it. */
|
|
2043
2919
|
rules: LinterRuleDefinition<string, DiagnosticMessages, any>[];
|
|
2920
|
+
/** Named presets consumers can extend, with names local to this library. */
|
|
2044
2921
|
ruleSets?: Record<string, LinterRuleSet>;
|
|
2045
2922
|
}
|
|
2923
|
+
/** Loaded linter definition with library-qualified rule IDs and a materialized rule-set map. */
|
|
2046
2924
|
export interface LinterResolvedDefinition {
|
|
2925
|
+
/** Rules in definition order, each with its library-qualified ID. */
|
|
2047
2926
|
readonly rules: LinterRule<string, DiagnosticMessages, any>[];
|
|
2927
|
+
/**
|
|
2928
|
+
* Named presets. A nonempty rule list gets an `"all"` preset enabling every rule
|
|
2929
|
+
* unless the library explicitly defines one; otherwise this map may be empty.
|
|
2930
|
+
*/
|
|
2048
2931
|
readonly ruleSets: {
|
|
2049
2932
|
[name: string]: LinterRuleSet;
|
|
2050
2933
|
};
|
|
2051
2934
|
}
|
|
2935
|
+
/** Shared diagnostic metadata and option configuration for synchronous and asynchronous rules. */
|
|
2052
2936
|
interface LinterRuleDefinitionBase<N extends string, DM extends DiagnosticMessages, Options extends Record<string, unknown> = Record<string, never>> {
|
|
2053
2937
|
/** Rule name (without the library name) */
|
|
2054
2938
|
name: N;
|
|
@@ -2071,32 +2955,46 @@ interface LinterRuleDefinitionBase<N extends string, DM extends DiagnosticMessag
|
|
|
2071
2955
|
* When provided, options will be validated against this schema before the rule runs.
|
|
2072
2956
|
*/
|
|
2073
2957
|
optionSchema?: Record<string, unknown>;
|
|
2074
|
-
/**
|
|
2958
|
+
/** Defaults used with `true` and shallowly merged with explicitly configured option properties. */
|
|
2075
2959
|
defaultOptions?: Options;
|
|
2076
2960
|
}
|
|
2961
|
+
/** Rule whose navigation callbacks and post-navigation `exit` callback must all complete synchronously. */
|
|
2077
2962
|
interface LinterRuleDefinitionSync<N extends string, DM extends DiagnosticMessages, Options extends Record<string, unknown> = Record<string, never>> extends LinterRuleDefinitionBase<N, DM, Options> {
|
|
2078
2963
|
/** Whether this is an async rule. Default is false */
|
|
2079
2964
|
async?: false;
|
|
2080
|
-
/**
|
|
2965
|
+
/**
|
|
2966
|
+
* Creates a fresh listener before navigation. Its optional `exit` callback runs
|
|
2967
|
+
* after the walk with the program. Linter dispatch ignores listener return values,
|
|
2968
|
+
* including {@link ListenerFlow.NoRecursion}.
|
|
2969
|
+
*/
|
|
2081
2970
|
create(context: LinterRuleContext<DM, Options>): SemanticNodeListener & {
|
|
2082
2971
|
exit?: (context: Program) => void | undefined;
|
|
2083
2972
|
};
|
|
2084
2973
|
}
|
|
2974
|
+
/**
|
|
2975
|
+
* Rule run in the asynchronous-rule pass after synchronous rules finish.
|
|
2976
|
+
* Navigation callbacks remain synchronous; only the post-navigation `exit` callback may return a promise.
|
|
2977
|
+
*/
|
|
2085
2978
|
interface LinterRuleDefinitionAsync<N extends string, DM extends DiagnosticMessages, Options extends Record<string, unknown> = Record<string, never>> extends LinterRuleDefinitionBase<N, DM, Options> {
|
|
2086
|
-
/**
|
|
2979
|
+
/** Enables awaiting the promise returned by the post-navigation `exit` callback. */
|
|
2087
2980
|
async: true;
|
|
2088
|
-
/**
|
|
2981
|
+
/**
|
|
2982
|
+
* Creates a fresh listener before navigation. `exit` runs after the walk, and
|
|
2983
|
+
* its promise is awaited before the asynchronous-rule pass completes.
|
|
2984
|
+
* Linter dispatch ignores navigation callback return values.
|
|
2985
|
+
*/
|
|
2089
2986
|
create(context: LinterRuleContext<DM, Options>): SemanticNodeListener & {
|
|
2090
2987
|
exit?: (context: Program) => Promise<void | undefined>;
|
|
2091
2988
|
};
|
|
2092
2989
|
}
|
|
2990
|
+
/** Rule definition discriminated by whether its post-navigation callback can perform asynchronous work. */
|
|
2093
2991
|
export type LinterRuleDefinition<N extends string, DM extends DiagnosticMessages, Options extends Record<string, unknown> = Record<string, never>> = LinterRuleDefinitionSync<N, DM, Options> | LinterRuleDefinitionAsync<N, DM, Options>;
|
|
2094
2992
|
/** Resolved instance of a linter rule that will run. */
|
|
2095
2993
|
export type LinterRule<N extends string, DM extends DiagnosticMessages, Options extends Record<string, unknown> = Record<string, never>> = LinterRuleDefinition<N, DM, Options> & {
|
|
2096
|
-
/** Expanded rule
|
|
2994
|
+
/** Expanded rule ID in the form `<library-name>/<rule-name>`, used as its diagnostic code. */
|
|
2097
2995
|
id: string;
|
|
2098
2996
|
};
|
|
2099
|
-
/**
|
|
2997
|
+
/** Library-qualified reference in the form `<library-name>/<rule-or-ruleset-name>`. */
|
|
2100
2998
|
export type RuleRef = `${string}/${string}`;
|
|
2101
2999
|
/**
|
|
2102
3000
|
* Reference to a ruleset defined in a yaml file. In this format `file:<path to the yaml file>`.
|
|
@@ -2109,39 +3007,59 @@ export type RuleSetRef = RuleRef | RuleSetFileRef;
|
|
|
2109
3007
|
/**
|
|
2110
3008
|
* Value for enabling a linter rule.
|
|
2111
3009
|
* - `true` enables the rule with default options.
|
|
2112
|
-
* -
|
|
3010
|
+
* - `false` skips enabling the rule; it does not disable a rule enabled by an extended preset.
|
|
3011
|
+
* - An object enables the rule with its properties shallowly merged over default options.
|
|
2113
3012
|
*/
|
|
2114
3013
|
export type LinterRuleEnableValue = boolean | Record<string, unknown>;
|
|
3014
|
+
/** Preset applied by extending other rule sets, then applying local enable and disable entries. */
|
|
2115
3015
|
export interface LinterRuleSet {
|
|
2116
|
-
/**
|
|
3016
|
+
/** Rule sets to apply first, in array order, before this preset's own entries. */
|
|
2117
3017
|
extends?: RuleSetRef[];
|
|
2118
|
-
/** Rules to enable/configure */
|
|
3018
|
+
/** Rules to enable/configure, keyed by library-qualified reference. Entries set to `false` are ignored. */
|
|
2119
3019
|
enable?: Record<RuleRef, LinterRuleEnableValue>;
|
|
2120
|
-
/** Rules to disable. A rule
|
|
3020
|
+
/** Rules to disable, with explanatory strings as values. A rule cannot also be enabled in this preset. */
|
|
2121
3021
|
disable?: Record<RuleRef, string>;
|
|
2122
3022
|
}
|
|
3023
|
+
/** Per-run rule context providing resolved options and a rule-scoped diagnostic collector. */
|
|
2123
3024
|
export interface LinterRuleContext<DM extends DiagnosticMessages, Options extends Record<string, unknown> = Record<string, never>> {
|
|
3025
|
+
/** Program being linted; report rule findings through this context rather than directly to the program. */
|
|
2124
3026
|
readonly program: Program;
|
|
2125
|
-
/**
|
|
3027
|
+
/** Configured properties merged over rule defaults, or an empty object when neither is provided. */
|
|
2126
3028
|
readonly options: Options;
|
|
3029
|
+
/**
|
|
3030
|
+
* Formats a warning using this rule's ID and messages and adds it to the linter's results.
|
|
3031
|
+
* Only targets belonging to the user project are collected: library, compiler,
|
|
3032
|
+
* synthetic, and {@link NoTarget} findings are ignored. The program later reports collected findings.
|
|
3033
|
+
*/
|
|
2127
3034
|
reportDiagnostic<M extends keyof DM>(diag: LinterRuleDiagnosticReport<DM, M>): void;
|
|
2128
3035
|
}
|
|
3036
|
+
/** Requires a `format` substitution map when the selected rule message is callable. */
|
|
2129
3037
|
export type LinterRuleDiagnosticFormat<T extends DiagnosticMessages, M extends keyof T = "default"> = T[M] extends CallableMessage<infer A> ? {
|
|
2130
3038
|
format: Record<A[number], string>;
|
|
2131
3039
|
} : Record<string, unknown>;
|
|
3040
|
+
/** Rule finding before its source target is attached; the context supplies the rule code and severity. */
|
|
2132
3041
|
export type LinterRuleDiagnosticReportWithoutTarget<T extends DiagnosticMessages, M extends keyof T = "default"> = {
|
|
3042
|
+
/** Message variant to use; omitted selects `"default"`. */
|
|
2133
3043
|
messageId?: M;
|
|
3044
|
+
/** Optional actions offered with the finding, without executing them during linting. */
|
|
2134
3045
|
codefixes?: CodeFix[];
|
|
2135
3046
|
} & LinterRuleDiagnosticFormat<T, M>;
|
|
3047
|
+
/**
|
|
3048
|
+
* Rule finding with a source-location target. Although {@link NoTarget} is accepted
|
|
3049
|
+
* by the shape, the linter only collects findings whose targets belong to the user project.
|
|
3050
|
+
*/
|
|
2136
3051
|
export type LinterRuleDiagnosticReport<T extends DiagnosticMessages, M extends keyof T = "default"> = LinterRuleDiagnosticReportWithoutTarget<T, M> & {
|
|
2137
3052
|
target: DiagnosticTarget | typeof NoTarget;
|
|
2138
3053
|
};
|
|
3054
|
+
/** Library definition enriched with diagnostic, state-key, and tracing helpers by {@link createTypeSpecLibrary}. */
|
|
2139
3055
|
export interface TypeSpecLibrary<T extends {
|
|
2140
3056
|
[code: string]: DiagnosticMessages;
|
|
2141
3057
|
}, E extends Record<string, any> = Record<string, never>, State extends string = never> extends TypeSpecLibraryDef<T, E, State> {
|
|
2142
3058
|
/** Library name */
|
|
2143
3059
|
readonly name: string;
|
|
3060
|
+
/** Creates a library-qualified diagnostic and reports it through the program's reporting policies. */
|
|
2144
3061
|
reportDiagnostic<C extends keyof T, M extends keyof T[C]>(program: Program, diag: DiagnosticReport<T, C, M>): void;
|
|
3062
|
+
/** Creates a library-qualified diagnostic without reporting it; the caller owns reporting or returning it. */
|
|
2145
3063
|
createDiagnostic<C extends keyof T, M extends keyof T[C]>(diag: DiagnosticReport<T, C, M>): Diagnostic;
|
|
2146
3064
|
/**
|
|
2147
3065
|
* Get or create a symbol with the given name unique for that library.
|
|
@@ -2153,10 +3071,11 @@ export interface TypeSpecLibrary<T extends {
|
|
|
2153
3071
|
* All trace area logged via this tracer will be prefixed with the library name.
|
|
2154
3072
|
*/
|
|
2155
3073
|
getTracer(program: Program): Tracer;
|
|
3074
|
+
/** Symbols for declared state names, registered as `<library-name>/<state-name>` for program state maps and sets. */
|
|
2156
3075
|
readonly stateKeys: Record<State, symbol>;
|
|
2157
3076
|
}
|
|
2158
3077
|
/**
|
|
2159
|
-
*
|
|
3078
|
+
* Extracts the custom emitter-option type declared by a TypeSpec library for its `$onEmit` hook.
|
|
2160
3079
|
*/
|
|
2161
3080
|
export type EmitOptionsFor<C> = C extends TypeSpecLibrary<infer _T, infer E> ? E : never;
|
|
2162
3081
|
/**
|
|
@@ -2224,17 +3143,20 @@ export interface FunctionContext extends InvocationContext {
|
|
|
2224
3143
|
*/
|
|
2225
3144
|
functionCallTarget: DiagnosticTarget;
|
|
2226
3145
|
}
|
|
3146
|
+
/** Per-emitter compilation context supplied to `$onEmit`, including options and performance reporting. */
|
|
2227
3147
|
export interface EmitContext<TOptions extends object = Record<string, never>> {
|
|
2228
3148
|
/**
|
|
2229
|
-
*
|
|
3149
|
+
* Checked program being emitted. Use its reporting APIs to report emitter diagnostics.
|
|
2230
3150
|
*/
|
|
2231
3151
|
program: Program;
|
|
2232
3152
|
/**
|
|
2233
|
-
*
|
|
3153
|
+
* Resolved output directory for this emitter, including its configured override if any.
|
|
3154
|
+
* Emit all output beneath this directory rather than the program's shared output directory.
|
|
2234
3155
|
*/
|
|
2235
3156
|
emitterOutputDir: string;
|
|
2236
3157
|
/**
|
|
2237
|
-
*
|
|
3158
|
+
* Custom options configured for this emitter, validated when the library declares an options schema.
|
|
3159
|
+
* The compiler's `emitter-output-dir` option is removed and exposed as `emitterOutputDir` instead.
|
|
2238
3160
|
*/
|
|
2239
3161
|
options: TOptions;
|
|
2240
3162
|
/**
|
|
@@ -2244,12 +3166,21 @@ export interface EmitContext<TOptions extends object = Record<string, never>> {
|
|
|
2244
3166
|
*/
|
|
2245
3167
|
readonly perf: PerfReporter;
|
|
2246
3168
|
}
|
|
3169
|
+
/** Elapsed-time measurement handle returned by compiler performance utilities. */
|
|
2247
3170
|
export interface Timer {
|
|
3171
|
+
/**
|
|
3172
|
+
* Returns milliseconds since the timer started. A reporting timer also records
|
|
3173
|
+
* the measurement under its label; repeated calls measure again from the original start.
|
|
3174
|
+
*/
|
|
2248
3175
|
end: () => number;
|
|
2249
3176
|
}
|
|
3177
|
+
/**
|
|
3178
|
+
* Records an emitter's named performance measurements for compiler statistics.
|
|
3179
|
+
* Measurements use milliseconds; recording the same label replaces its previous value.
|
|
3180
|
+
*/
|
|
2250
3181
|
export interface PerfReporter {
|
|
2251
3182
|
/**
|
|
2252
|
-
*
|
|
3183
|
+
* Starts a timer whose measurement is recorded under the label when `end()` is called.
|
|
2253
3184
|
*
|
|
2254
3185
|
* @example
|
|
2255
3186
|
* ```ts
|
|
@@ -2259,9 +3190,9 @@ export interface PerfReporter {
|
|
|
2259
3190
|
* ```
|
|
2260
3191
|
*/
|
|
2261
3192
|
startTimer(label: string): Timer;
|
|
2262
|
-
/**
|
|
3193
|
+
/** Calls the callback immediately, records elapsed time on successful return, and returns its result. */
|
|
2263
3194
|
time<T>(label: string, callback: () => T): T;
|
|
2264
|
-
/**
|
|
3195
|
+
/** Calls and awaits the callback, records elapsed time on successful resolution, and returns its result. */
|
|
2265
3196
|
timeAsync<T>(label: string, callback: () => Promise<T>): Promise<T>;
|
|
2266
3197
|
/**
|
|
2267
3198
|
* Report a custom elapsed time for the given label.
|
|
@@ -2280,43 +3211,70 @@ export interface PerfReporter {
|
|
|
2280
3211
|
*/
|
|
2281
3212
|
report(label: string, milliseconds: number): void;
|
|
2282
3213
|
}
|
|
3214
|
+
/** Log severity, ordered from verbose tracing through warnings to errors for logger filtering. */
|
|
2283
3215
|
export type LogLevel = "trace" | "warning" | "error";
|
|
3216
|
+
/** Input to a logger before its optional target is resolved to a source location. */
|
|
2284
3217
|
export interface LogInfo {
|
|
3218
|
+
/** Severity used by the logger's configured minimum-level filter. */
|
|
2285
3219
|
level: LogLevel;
|
|
3220
|
+
/** Human-readable text delivered to the sink when the message passes filtering. */
|
|
2286
3221
|
message: string;
|
|
3222
|
+
/** Optional diagnostic identifier or trace-area name; absent for messages without a code. */
|
|
2287
3223
|
code?: string;
|
|
3224
|
+
/** Optional location-bearing target; absent or {@link NoTarget} produces no source location. */
|
|
2288
3225
|
target?: DiagnosticTarget | typeof NoTarget;
|
|
2289
3226
|
}
|
|
3227
|
+
/** Log entry ready for a sink, with any source target already resolved to a location. */
|
|
2290
3228
|
export interface ProcessedLog {
|
|
3229
|
+
/** Severity to display; filtering is normally performed before sink delivery. */
|
|
2291
3230
|
level: LogLevel;
|
|
3231
|
+
/** Human-readable message to display. */
|
|
2292
3232
|
message: string;
|
|
3233
|
+
/** Optional diagnostic identifier or trace-area name associated with the message. */
|
|
2293
3234
|
code?: string;
|
|
2294
3235
|
/** Documentation for the error code. */
|
|
2295
3236
|
url?: string;
|
|
2296
|
-
/**
|
|
3237
|
+
/** Resolved location when a target was supplied; may be synthetic when no actual source is available. */
|
|
2297
3238
|
sourceLocation?: SourceLocation;
|
|
2298
3239
|
}
|
|
3240
|
+
/** Destination for processed compiler log entries, such as a console or editor integration. */
|
|
2299
3241
|
export interface LogSink {
|
|
3242
|
+
/** Consumes one processed log entry; delivery does not itself add a diagnostic to a program. */
|
|
2300
3243
|
log(log: ProcessedLog): void;
|
|
2301
3244
|
}
|
|
3245
|
+
/**
|
|
3246
|
+
* Filters and forwards log messages to a sink. Logging warnings or errors does not
|
|
3247
|
+
* report program diagnostics or change compilation success.
|
|
3248
|
+
*/
|
|
2302
3249
|
export interface Logger {
|
|
3250
|
+
/** Logs a trace message without a code, subject to the configured minimum log level. */
|
|
2303
3251
|
trace(message: string): void;
|
|
3252
|
+
/** Logs a warning without a code or a program diagnostic. */
|
|
2304
3253
|
warn(message: string): void;
|
|
3254
|
+
/** Logs an error without a code or a program diagnostic. */
|
|
2305
3255
|
error(message: string): void;
|
|
3256
|
+
/** Filters by severity, resolves the optional target, and forwards the entry to the sink. */
|
|
2306
3257
|
log(log: LogInfo): void;
|
|
2307
3258
|
}
|
|
3259
|
+
/** Selects which dot-separated trace areas a tracer forwards to its logger. */
|
|
2308
3260
|
export interface TracerOptions {
|
|
3261
|
+
/**
|
|
3262
|
+
* Area prefixes to enable, such as `"http"` or `"http.route"`; `"*"` enables all areas.
|
|
3263
|
+
* A prefix enables its descendants. Omitted or empty filters disable tracing.
|
|
3264
|
+
*/
|
|
2309
3265
|
filter?: string[];
|
|
2310
3266
|
}
|
|
3267
|
+
/** Hierarchical tracing whose enabled areas are controlled by {@link TracerOptions}. */
|
|
2311
3268
|
export interface Tracer {
|
|
2312
3269
|
/**
|
|
2313
|
-
*
|
|
2314
|
-
*
|
|
2315
|
-
*
|
|
3270
|
+
* Logs a message under a dot-separated area when that area is enabled.
|
|
3271
|
+
* The default compiler tracer uses the area as the log code and does not forward
|
|
3272
|
+
* the optional target to its logger.
|
|
2316
3273
|
*/
|
|
2317
3274
|
trace(area: string, message: string, target?: DiagnosticTarget): void;
|
|
2318
3275
|
/**
|
|
2319
|
-
*
|
|
3276
|
+
* Returns a child tracer that prefixes subsequent areas with this subarea,
|
|
3277
|
+
* separated by a dot. Child tracers share the parent's filtering and log destination.
|
|
2320
3278
|
*/
|
|
2321
3279
|
sub(subarea: string): Tracer;
|
|
2322
3280
|
}
|