@typespec/compiler 0.68.0-dev.1 → 0.68.0-dev.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/manifest.js +2 -2
- package/dist/src/config/config-schema.d.ts.map +1 -1
- package/dist/src/config/config-schema.js +2 -9
- package/dist/src/config/config-schema.js.map +1 -1
- package/dist/src/config/config-to-options.js +16 -15
- package/dist/src/config/config-to-options.js.map +1 -1
- package/dist/src/config/types.d.ts +0 -1
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/core/cli/actions/compile/args.d.ts.map +1 -1
- package/dist/src/core/cli/actions/compile/args.js +24 -16
- package/dist/src/core/cli/actions/compile/args.js.map +1 -1
- package/dist/src/core/cli/utils.d.ts +2 -2
- package/dist/src/core/cli/utils.d.ts.map +1 -1
- package/dist/src/core/cli/utils.js +13 -3
- package/dist/src/core/cli/utils.js.map +1 -1
- package/dist/src/core/diagnostics.d.ts +0 -5
- package/dist/src/core/diagnostics.d.ts.map +1 -1
- package/dist/src/core/diagnostics.js +2 -12
- package/dist/src/core/diagnostics.js.map +1 -1
- package/dist/src/core/logger/console-sink.browser.d.ts +2 -1
- package/dist/src/core/logger/console-sink.browser.d.ts.map +1 -1
- package/dist/src/core/logger/console-sink.browser.js +3 -0
- package/dist/src/core/logger/console-sink.browser.js.map +1 -1
- package/dist/src/core/logger/console-sink.d.ts +5 -10
- package/dist/src/core/logger/console-sink.d.ts.map +1 -1
- package/dist/src/core/logger/console-sink.js +14 -1
- package/dist/src/core/logger/console-sink.js.map +1 -1
- package/dist/src/core/messages.d.ts +20 -2
- package/dist/src/core/messages.d.ts.map +1 -1
- package/dist/src/core/messages.js +6 -0
- package/dist/src/core/messages.js.map +1 -1
- package/dist/src/core/parser.js +1 -1
- package/dist/src/core/parser.js.map +1 -1
- package/dist/src/core/scanner.d.ts +24 -22
- package/dist/src/core/scanner.d.ts.map +1 -1
- package/dist/src/core/scanner.js +33 -24
- package/dist/src/core/scanner.js.map +1 -1
- package/dist/src/experimental/mutators.js +1 -0
- package/dist/src/experimental/mutators.js.map +1 -1
- package/dist/src/formatter/print/printer.js +1 -1
- package/dist/src/formatter/print/printer.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/init.js +1 -1
- package/dist/src/init/init.js.map +1 -1
- package/dist/src/install/install.js +4 -1
- package/dist/src/install/install.js.map +1 -1
- package/dist/src/internals/prettier-formatter.d.ts +6 -0
- package/dist/src/internals/prettier-formatter.d.ts.map +1 -0
- package/dist/src/internals/prettier-formatter.js +6 -0
- package/dist/src/internals/prettier-formatter.js.map +1 -0
- package/dist/src/server/compile-service.d.ts.map +1 -1
- package/dist/src/server/compile-service.js +2 -1
- package/dist/src/server/compile-service.js.map +1 -1
- package/dist/src/server/type-signature.js +1 -1
- package/dist/src/server/type-signature.js.map +1 -1
- package/dist/src/testing/expect.d.ts.map +1 -1
- package/dist/src/testing/expect.js +2 -1
- package/dist/src/testing/expect.js.map +1 -1
- package/package.json +9 -10
- package/templates/__snapshots__/rest/main.tsp +1 -1
- package/templates/rest/main.tsp +1 -1
- package/templates/scaffolding.json +9 -7
- package/dist/src/emitter-framework/asset-emitter.d.ts +0 -6
- package/dist/src/emitter-framework/asset-emitter.d.ts.map +0 -1
- package/dist/src/emitter-framework/asset-emitter.js +0 -740
- package/dist/src/emitter-framework/asset-emitter.js.map +0 -1
- package/dist/src/emitter-framework/builders/array-builder.d.ts +0 -7
- package/dist/src/emitter-framework/builders/array-builder.d.ts.map +0 -1
- package/dist/src/emitter-framework/builders/array-builder.js +0 -35
- package/dist/src/emitter-framework/builders/array-builder.js.map +0 -1
- package/dist/src/emitter-framework/builders/object-builder.d.ts +0 -12
- package/dist/src/emitter-framework/builders/object-builder.d.ts.map +0 -1
- package/dist/src/emitter-framework/builders/object-builder.js +0 -52
- package/dist/src/emitter-framework/builders/object-builder.js.map +0 -1
- package/dist/src/emitter-framework/builders/string-builder.d.ts +0 -13
- package/dist/src/emitter-framework/builders/string-builder.d.ts.map +0 -1
- package/dist/src/emitter-framework/builders/string-builder.js +0 -90
- package/dist/src/emitter-framework/builders/string-builder.js.map +0 -1
- package/dist/src/emitter-framework/index.d.ts +0 -75
- package/dist/src/emitter-framework/index.d.ts.map +0 -1
- package/dist/src/emitter-framework/index.js +0 -33
- package/dist/src/emitter-framework/index.js.map +0 -1
- package/dist/src/emitter-framework/placeholder.d.ts +0 -12
- package/dist/src/emitter-framework/placeholder.d.ts.map +0 -1
- package/dist/src/emitter-framework/placeholder.js +0 -18
- package/dist/src/emitter-framework/placeholder.js.map +0 -1
- package/dist/src/emitter-framework/ref-scope.d.ts +0 -14
- package/dist/src/emitter-framework/ref-scope.d.ts.map +0 -1
- package/dist/src/emitter-framework/ref-scope.js +0 -30
- package/dist/src/emitter-framework/ref-scope.js.map +0 -1
- package/dist/src/emitter-framework/reference-cycle.d.ts +0 -23
- package/dist/src/emitter-framework/reference-cycle.d.ts.map +0 -1
- package/dist/src/emitter-framework/reference-cycle.js +0 -32
- package/dist/src/emitter-framework/reference-cycle.js.map +0 -1
- package/dist/src/emitter-framework/type-emitter.d.ts +0 -349
- package/dist/src/emitter-framework/type-emitter.d.ts.map +0 -1
- package/dist/src/emitter-framework/type-emitter.js +0 -721
- package/dist/src/emitter-framework/type-emitter.js.map +0 -1
- package/dist/src/emitter-framework/types.d.ts +0 -140
- package/dist/src/emitter-framework/types.d.ts.map +0 -1
- package/dist/src/emitter-framework/types.js +0 -42
- package/dist/src/emitter-framework/types.js.map +0 -1
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
import type { Program } from "../core/program.js";
|
|
2
|
-
import type { BooleanLiteral, Enum, EnumMember, Interface, IntrinsicType, Model, ModelProperty, Namespace, NumericLiteral, Operation, Scalar, StringLiteral, StringTemplate, Tuple, Type, Union, UnionVariant } from "../core/types.js";
|
|
3
|
-
import { Placeholder } from "./placeholder.js";
|
|
4
|
-
import { ReferenceCycle } from "./reference-cycle.js";
|
|
5
|
-
import { AssetEmitter, Context, Declaration, EmitEntity, EmittedSourceFile, Scope, SourceFile, TypeSpecDeclaration } from "./types.js";
|
|
6
|
-
export type EmitterOutput<T> = EmitEntity<T> | Placeholder<T> | T;
|
|
7
|
-
/**
|
|
8
|
-
* Implement emitter logic by extending this class and passing it to
|
|
9
|
-
* `emitContext.createAssetEmitter`. This class should not be constructed
|
|
10
|
-
* directly.
|
|
11
|
-
*
|
|
12
|
-
* TypeEmitters serve two primary purposes:
|
|
13
|
-
*
|
|
14
|
-
* 1. Handle emitting TypeSpec types into other languages
|
|
15
|
-
* 2. Set emitter context
|
|
16
|
-
*
|
|
17
|
-
* The generic type parameter `T` is the type you expect to produce for each TypeSpec type.
|
|
18
|
-
* In the case of generating source code for a programming language, this is probably `string`
|
|
19
|
-
* (in which case, consider using the `CodeTypeEmitter`) but might also be an AST node. If you
|
|
20
|
-
* are emitting JSON or similar, `T` would likely be `object`.
|
|
21
|
-
*
|
|
22
|
-
* ## Emitting types
|
|
23
|
-
*
|
|
24
|
-
* Emitting TypeSpec types into other languages is accomplished by implementing
|
|
25
|
-
* the AssetEmitter method that corresponds with the TypeSpec type you are
|
|
26
|
-
* emitting. For example, to emit a TypeSpec model declaration, implement the
|
|
27
|
-
* `modelDeclaration` method.
|
|
28
|
-
*
|
|
29
|
-
* TypeSpec types that have both declaration and literal forms like models or
|
|
30
|
-
* unions will have separate methods. For example, models have both
|
|
31
|
-
* `modelDeclaration` and `modelLiteral` methods that can be implemented
|
|
32
|
-
* separately.
|
|
33
|
-
*
|
|
34
|
-
* Also, types which can be instantiated like models or operations have a
|
|
35
|
-
* separate method for the instantiated type. For example, models have a
|
|
36
|
-
* `modelInstantiation` method that gets called with such types. Generally these
|
|
37
|
-
* will be treated either as if they were declarations or literals depending on
|
|
38
|
-
* preference, but may also be treated specially.
|
|
39
|
-
*
|
|
40
|
-
* ## Emitter results
|
|
41
|
-
* There are three kinds of results your methods might return - declarations,
|
|
42
|
-
* raw code, or nothing.
|
|
43
|
-
*
|
|
44
|
-
* ### Declarations
|
|
45
|
-
*
|
|
46
|
-
* Create declarations by calling `this.emitter.result.declaration` passing it a
|
|
47
|
-
* name and the emit output for the declaration. Note that you must have scope
|
|
48
|
-
* in your context or you will get an error. If you want all declarations to be
|
|
49
|
-
* emitted to the same source file, you can create a single scope in
|
|
50
|
-
* `programContext` via something like:
|
|
51
|
-
*
|
|
52
|
-
* ```typescript
|
|
53
|
-
* programContext(program: Program): Context {
|
|
54
|
-
* const sourceFile = this.emitter.createSourceFile("test.txt");
|
|
55
|
-
* return {
|
|
56
|
-
* scope: sourceFile.globalScope,
|
|
57
|
-
* };
|
|
58
|
-
* }
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* ### Raw Code
|
|
62
|
-
*
|
|
63
|
-
* Create raw code, or emitter output that doesn't contribute to a declaration,
|
|
64
|
-
* by calling `this.emitter.result.rawCode` passing it a value. Returning just a
|
|
65
|
-
* value is considered raw code and so you often don't need to call this
|
|
66
|
-
* directly.
|
|
67
|
-
*
|
|
68
|
-
* ### No Emit
|
|
69
|
-
*
|
|
70
|
-
* When a type doesn't contribute anything to the emitted output, return
|
|
71
|
-
* `this.emitter.result.none()`.
|
|
72
|
-
*
|
|
73
|
-
* ## Context
|
|
74
|
-
*
|
|
75
|
-
* The TypeEmitter will often want to keep track of what context a type is found
|
|
76
|
-
* in. There are two kinds of context - lexical context, and reference context.
|
|
77
|
-
*
|
|
78
|
-
* * Lexical context is context that applies to the type and every type
|
|
79
|
-
* contained inside of it. For example, lexical context for a model will apply
|
|
80
|
-
* to the model, its properties, and any nested model literals.
|
|
81
|
-
* * Reference context is context that applies to types contained inside of the
|
|
82
|
-
* type and referenced anywhere inside of it. For example, reference context
|
|
83
|
-
* set on a model will apply to the model, its properties, any nested model
|
|
84
|
-
* literals, and any type referenced inside anywhere inside the model and any
|
|
85
|
-
* of the referenced types' references.
|
|
86
|
-
*
|
|
87
|
-
* In both cases, context is an object. It's strongly recommended that the context
|
|
88
|
-
* object either contain only primitive types, or else only reference immutable
|
|
89
|
-
* objects.
|
|
90
|
-
*
|
|
91
|
-
* Set lexical by implementing the `*Context` methods of the TypeEmitter and
|
|
92
|
-
* returning the context, for example `modelDeclarationContext` sets the context
|
|
93
|
-
* for model declarations and the types contained inside of it.
|
|
94
|
-
*
|
|
95
|
-
* Set reference context by implementing the `*ReferenceContext` methods of the
|
|
96
|
-
* TypeEmitter and returning the context. Note that not all types have reference
|
|
97
|
-
* context methods, because not all types can actually reference anything.
|
|
98
|
-
*
|
|
99
|
-
* When a context method returns some context, it is merged with the current
|
|
100
|
-
* context. It is not possible to remove previous context, but it can be
|
|
101
|
-
* overridden with `undefined`.
|
|
102
|
-
*
|
|
103
|
-
* When emitting types with context, the same type might be emitted multiple
|
|
104
|
-
* times if we come across that type with different contexts. For example, if we
|
|
105
|
-
* have a TypeSpec program like
|
|
106
|
-
*
|
|
107
|
-
* ```typespec
|
|
108
|
-
* model Pet { }
|
|
109
|
-
* model Person {
|
|
110
|
-
* pet: Pet;
|
|
111
|
-
* }
|
|
112
|
-
* ```
|
|
113
|
-
*
|
|
114
|
-
* And we set reference context for the Person model, Pet will be emitted twice,
|
|
115
|
-
* once without context and once with the reference context.
|
|
116
|
-
*/
|
|
117
|
-
export declare class TypeEmitter<T, TOptions extends object = Record<string, never>> {
|
|
118
|
-
protected emitter: AssetEmitter<T, TOptions>;
|
|
119
|
-
/**
|
|
120
|
-
* @private
|
|
121
|
-
*
|
|
122
|
-
* Constructs a TypeEmitter. Do not use this constructor directly, instead
|
|
123
|
-
* call `createAssetEmitter` on the emitter context object.
|
|
124
|
-
* @param emitter The asset emitter
|
|
125
|
-
*/
|
|
126
|
-
constructor(emitter: AssetEmitter<T, TOptions>);
|
|
127
|
-
/**
|
|
128
|
-
* Context shared by the entire program. In cases where you are emitting to a
|
|
129
|
-
* single file, use this method to establish your main source file and set the
|
|
130
|
-
* `scope` property to that source file's `globalScope`.
|
|
131
|
-
* @param program
|
|
132
|
-
* @returns Context
|
|
133
|
-
*/
|
|
134
|
-
programContext(program: Program): Context;
|
|
135
|
-
/**
|
|
136
|
-
* Emit a namespace
|
|
137
|
-
*
|
|
138
|
-
* @param namespace
|
|
139
|
-
* @returns Emitter output
|
|
140
|
-
*/
|
|
141
|
-
namespace(namespace: Namespace): EmitterOutput<T>;
|
|
142
|
-
/**
|
|
143
|
-
* Set lexical context for a namespace
|
|
144
|
-
*
|
|
145
|
-
* @param namespace
|
|
146
|
-
*/
|
|
147
|
-
namespaceContext(namespace: Namespace): Context;
|
|
148
|
-
/**
|
|
149
|
-
* Set reference context for a namespace.
|
|
150
|
-
*
|
|
151
|
-
* @param namespace
|
|
152
|
-
*/
|
|
153
|
-
namespaceReferenceContext(namespace: Namespace): Context;
|
|
154
|
-
/**
|
|
155
|
-
* Emit a model literal (e.g. as created by `{}` syntax in TypeSpec).
|
|
156
|
-
*
|
|
157
|
-
* @param model
|
|
158
|
-
*/
|
|
159
|
-
modelLiteral(model: Model): EmitterOutput<T>;
|
|
160
|
-
/**
|
|
161
|
-
* Set lexical context for a model literal.
|
|
162
|
-
* @param model
|
|
163
|
-
*/
|
|
164
|
-
modelLiteralContext(model: Model): Context;
|
|
165
|
-
/**
|
|
166
|
-
* Set reference context for a model literal.
|
|
167
|
-
* @param model
|
|
168
|
-
*/
|
|
169
|
-
modelLiteralReferenceContext(model: Model): Context;
|
|
170
|
-
/**
|
|
171
|
-
* Emit a model declaration (e.g. as created by `model Foo { }` syntax in
|
|
172
|
-
* TypeSpec).
|
|
173
|
-
*
|
|
174
|
-
* @param model
|
|
175
|
-
*/
|
|
176
|
-
modelDeclaration(model: Model, name: string): EmitterOutput<T>;
|
|
177
|
-
/**
|
|
178
|
-
* Set lexical context for a model declaration.
|
|
179
|
-
*
|
|
180
|
-
* @param model
|
|
181
|
-
* @param name the model's declaration name as retrieved from the
|
|
182
|
-
* `declarationName` method.
|
|
183
|
-
*/
|
|
184
|
-
modelDeclarationContext(model: Model, name: string): Context;
|
|
185
|
-
/**
|
|
186
|
-
* Set reference context for a model declaration.
|
|
187
|
-
* @param model
|
|
188
|
-
*/
|
|
189
|
-
modelDeclarationReferenceContext(model: Model, name: string): Context;
|
|
190
|
-
/**
|
|
191
|
-
* Emit a model instantiation (e.g. as created by `Box<string>` syntax in
|
|
192
|
-
* TypeSpec). In some cases, `name` is undefined because a good name could
|
|
193
|
-
* not be found for the instantiation. This often occurs with for instantiations
|
|
194
|
-
* involving type expressions like `Box<string | int32>`.
|
|
195
|
-
*
|
|
196
|
-
* @param model
|
|
197
|
-
* @param name The name of the instantiation as retrieved from the
|
|
198
|
-
* `declarationName` method.
|
|
199
|
-
*/
|
|
200
|
-
modelInstantiation(model: Model, name: string | undefined): EmitterOutput<T>;
|
|
201
|
-
/**
|
|
202
|
-
* Set lexical context for a model instantiation.
|
|
203
|
-
* @param model
|
|
204
|
-
*/
|
|
205
|
-
modelInstantiationContext(model: Model, name: string | undefined): Context;
|
|
206
|
-
/**
|
|
207
|
-
* Set reference context for a model declaration.
|
|
208
|
-
* @param model
|
|
209
|
-
*/
|
|
210
|
-
modelInstantiationReferenceContext(model: Model, name: string | undefined): Context;
|
|
211
|
-
/**
|
|
212
|
-
* Emit a model's properties. Unless overridden, this method will emit each of
|
|
213
|
-
* the model's properties and return a no emit result.
|
|
214
|
-
*
|
|
215
|
-
* @param model
|
|
216
|
-
*/
|
|
217
|
-
modelProperties(model: Model): EmitterOutput<T>;
|
|
218
|
-
modelPropertiesContext(model: Model): Context;
|
|
219
|
-
modelPropertiesReferenceContext(model: Model): Context;
|
|
220
|
-
/**
|
|
221
|
-
* Emit a property of a model.
|
|
222
|
-
*
|
|
223
|
-
* @param property
|
|
224
|
-
*/
|
|
225
|
-
modelPropertyLiteral(property: ModelProperty): EmitterOutput<T>;
|
|
226
|
-
/**
|
|
227
|
-
* Set lexical context for a property of a model.
|
|
228
|
-
*
|
|
229
|
-
* @param property
|
|
230
|
-
*/
|
|
231
|
-
modelPropertyLiteralContext(property: ModelProperty): Context;
|
|
232
|
-
/**
|
|
233
|
-
* Set reference context for a property of a model.
|
|
234
|
-
*
|
|
235
|
-
* @param property
|
|
236
|
-
*/
|
|
237
|
-
modelPropertyLiteralReferenceContext(property: ModelProperty): Context;
|
|
238
|
-
/**
|
|
239
|
-
* Emit a model property reference (e.g. as created by the `SomeModel.prop`
|
|
240
|
-
* syntax in TypeSpec). By default, this will emit the type of the referenced
|
|
241
|
-
* property and return that result. In other words, the emit will look as if
|
|
242
|
-
* `SomeModel.prop` were replaced with the type of `prop`.
|
|
243
|
-
*
|
|
244
|
-
* @param property
|
|
245
|
-
*/
|
|
246
|
-
modelPropertyReference(property: ModelProperty): EmitterOutput<T>;
|
|
247
|
-
/**
|
|
248
|
-
* Emit an enum member reference (e.g. as created by the `SomeEnum.member` syntax
|
|
249
|
-
* in TypeSpec). By default, this will emit nothing.
|
|
250
|
-
*
|
|
251
|
-
* @param property the enum member
|
|
252
|
-
*/
|
|
253
|
-
enumMemberReference(member: EnumMember): EmitterOutput<T>;
|
|
254
|
-
arrayDeclaration(array: Model, name: string, elementType: Type): EmitterOutput<T>;
|
|
255
|
-
arrayDeclarationContext(array: Model, name: string, elementType: Type): Context;
|
|
256
|
-
arrayDeclarationReferenceContext(array: Model, name: string, elementType: Type): Context;
|
|
257
|
-
arrayLiteral(array: Model, elementType: Type): EmitterOutput<T>;
|
|
258
|
-
arrayLiteralContext(array: Model, elementType: Type): Context;
|
|
259
|
-
arrayLiteralReferenceContext(array: Model, elementType: Type): Context;
|
|
260
|
-
scalarDeclaration(scalar: Scalar, name: string): EmitterOutput<T>;
|
|
261
|
-
scalarDeclarationContext(scalar: Scalar, name: string): Context;
|
|
262
|
-
scalarDeclarationReferenceContext(scalar: Scalar, name: string): Context;
|
|
263
|
-
scalarInstantiation(scalar: Scalar, name: string | undefined): EmitterOutput<T>;
|
|
264
|
-
scalarInstantiationContext(scalar: Scalar, name: string | undefined): Context;
|
|
265
|
-
intrinsic(intrinsic: IntrinsicType, name: string): EmitterOutput<T>;
|
|
266
|
-
intrinsicContext(intrinsic: IntrinsicType, name: string): Context;
|
|
267
|
-
booleanLiteralContext(boolean: BooleanLiteral): Context;
|
|
268
|
-
booleanLiteral(boolean: BooleanLiteral): EmitterOutput<T>;
|
|
269
|
-
stringTemplateContext(string: StringTemplate): Context;
|
|
270
|
-
stringTemplate(stringTemplate: StringTemplate): EmitterOutput<T>;
|
|
271
|
-
stringLiteralContext(string: StringLiteral): Context;
|
|
272
|
-
stringLiteral(string: StringLiteral): EmitterOutput<T>;
|
|
273
|
-
numericLiteralContext(number: NumericLiteral): Context;
|
|
274
|
-
numericLiteral(number: NumericLiteral): EmitterOutput<T>;
|
|
275
|
-
operationDeclaration(operation: Operation, name: string): EmitterOutput<T>;
|
|
276
|
-
operationDeclarationContext(operation: Operation, name: string): Context;
|
|
277
|
-
operationDeclarationReferenceContext(operation: Operation, name: string): Context;
|
|
278
|
-
interfaceDeclarationOperationsContext(iface: Interface): Context;
|
|
279
|
-
interfaceDeclarationOperationsReferenceContext(iface: Interface): Context;
|
|
280
|
-
interfaceOperationDeclarationContext(operation: Operation, name: string): Context;
|
|
281
|
-
interfaceOperationDeclarationReferenceContext(operation: Operation, name: string): Context;
|
|
282
|
-
operationParameters(operation: Operation, parameters: Model): EmitterOutput<T>;
|
|
283
|
-
operationParametersContext(operation: Operation, parameters: Model): Context;
|
|
284
|
-
operationParametersReferenceContext(operation: Operation, parameters: Model): Context;
|
|
285
|
-
operationReturnType(operation: Operation, returnType: Type): EmitterOutput<T>;
|
|
286
|
-
operationReturnTypeContext(operation: Operation, returnType: Type): Context;
|
|
287
|
-
operationReturnTypeReferenceContext(operation: Operation, returnType: Type): Context;
|
|
288
|
-
interfaceDeclaration(iface: Interface, name: string): EmitterOutput<T>;
|
|
289
|
-
interfaceDeclarationContext(iface: Interface, name: string): Context;
|
|
290
|
-
interfaceDeclarationReferenceContext(iface: Interface, name: string): Context;
|
|
291
|
-
interfaceDeclarationOperations(iface: Interface): EmitterOutput<T>;
|
|
292
|
-
interfaceOperationDeclaration(operation: Operation, name: string): EmitterOutput<T>;
|
|
293
|
-
enumDeclaration(en: Enum, name: string): EmitterOutput<T>;
|
|
294
|
-
enumDeclarationContext(en: Enum, name: string): Context;
|
|
295
|
-
enumDeclarationReferenceContext(en: Enum, name: string): Context;
|
|
296
|
-
enumMembers(en: Enum): EmitterOutput<T>;
|
|
297
|
-
enumMembersContext(en: Enum): Context;
|
|
298
|
-
enumMember(member: EnumMember): EmitterOutput<T>;
|
|
299
|
-
enumMemberContext(member: EnumMember): {};
|
|
300
|
-
unionDeclaration(union: Union, name: string): EmitterOutput<T>;
|
|
301
|
-
unionDeclarationContext(union: Union): Context;
|
|
302
|
-
unionDeclarationReferenceContext(union: Union): Context;
|
|
303
|
-
unionInstantiation(union: Union, name: string): EmitterOutput<T>;
|
|
304
|
-
unionInstantiationContext(union: Union, name: string): Context;
|
|
305
|
-
unionInstantiationReferenceContext(union: Union, name: string): Context;
|
|
306
|
-
unionLiteral(union: Union): EmitterOutput<T>;
|
|
307
|
-
unionLiteralContext(union: Union): Context;
|
|
308
|
-
unionLiteralReferenceContext(union: Union): Context;
|
|
309
|
-
unionVariants(union: Union): EmitterOutput<T>;
|
|
310
|
-
unionVariantsContext(): Context;
|
|
311
|
-
unionVariantsReferenceContext(): Context;
|
|
312
|
-
unionVariant(variant: UnionVariant): EmitterOutput<T>;
|
|
313
|
-
unionVariantContext(union: Union): Context;
|
|
314
|
-
unionVariantReferenceContext(union: Union): Context;
|
|
315
|
-
tupleLiteral(tuple: Tuple): EmitterOutput<T>;
|
|
316
|
-
tupleLiteralContext(tuple: Tuple): Context;
|
|
317
|
-
tupleLiteralValues(tuple: Tuple): EmitterOutput<T>;
|
|
318
|
-
tupleLiteralValuesContext(tuple: Tuple): Context;
|
|
319
|
-
tupleLiteralValuesReferenceContext(tuple: Tuple): Context;
|
|
320
|
-
tupleLiteralReferenceContext(tuple: Tuple): Context;
|
|
321
|
-
sourceFile(sourceFile: SourceFile<T>): Promise<EmittedSourceFile> | EmittedSourceFile;
|
|
322
|
-
writeOutput(sourceFiles: SourceFile<T>[]): Promise<void>;
|
|
323
|
-
reference(targetDeclaration: Declaration<T>, pathUp: Scope<T>[], pathDown: Scope<T>[], commonScope: Scope<T> | null): EmitEntity<T> | T;
|
|
324
|
-
/**
|
|
325
|
-
* Handle circular references. When this method is called it means we are resolving a circular reference.
|
|
326
|
-
* By default if the target is a declaration it will call to {@link reference} otherwise it means we have an inline reference
|
|
327
|
-
* @param target Reference target.
|
|
328
|
-
* @param scope Current scope.
|
|
329
|
-
* @returns Resolved reference entity.
|
|
330
|
-
*/
|
|
331
|
-
circularReference(target: EmitEntity<T>, scope: Scope<T> | undefined, cycle: ReferenceCycle): EmitEntity<T> | T;
|
|
332
|
-
declarationName(declarationType: TypeSpecDeclaration): string | undefined;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* A subclass of `TypeEmitter<string>` that makes working with strings a bit easier.
|
|
336
|
-
* In particular, when emitting members of a type (`modelProperties`, `enumMembers`, etc.),
|
|
337
|
-
* instead of returning no result, it returns the value of each of the members concatenated
|
|
338
|
-
* by commas. It will also construct references by concatenating namespace elements together
|
|
339
|
-
* with `.` which should work nicely in many object oriented languages.
|
|
340
|
-
*/
|
|
341
|
-
export declare class CodeTypeEmitter<TOptions extends object = Record<string, never>> extends TypeEmitter<string, TOptions> {
|
|
342
|
-
modelProperties(model: Model): EmitterOutput<string>;
|
|
343
|
-
interfaceDeclarationOperations(iface: Interface): EmitterOutput<string>;
|
|
344
|
-
enumMembers(en: Enum): EmitterOutput<string>;
|
|
345
|
-
unionVariants(union: Union): EmitterOutput<string>;
|
|
346
|
-
tupleLiteralValues(tuple: Tuple): EmitterOutput<string>;
|
|
347
|
-
reference(targetDeclaration: Declaration<string>, pathUp: Scope<string>[], pathDown: Scope<string>[], commonScope: Scope<string> | null): string | EmitEntity<string>;
|
|
348
|
-
}
|
|
349
|
-
//# sourceMappingURL=type-emitter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-emitter.d.ts","sourceRoot":"","sources":["../../../src/emitter-framework/type-emitter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EACV,cAAc,EACd,IAAI,EACJ,UAAU,EACV,SAAS,EACT,aAAa,EACb,KAAK,EACL,aAAa,EACb,SAAS,EACT,cAAc,EACd,SAAS,EACT,MAAM,EACN,aAAa,EACb,cAAc,EACd,KAAK,EACL,IAAI,EACJ,KAAK,EACL,YAAY,EACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,YAAY,EACZ,OAAO,EACP,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,KAAK,EACL,UAAU,EACV,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6GG;AACH,qBAAa,WAAW,CAAC,CAAC,EAAE,QAAQ,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAQ7D,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC;IAPxD;;;;;;OAMG;gBACmB,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC;IAExD;;;;;;OAM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