import type { Enum, Interface, IntrinsicType, Model, ModelProperty, Operation, Program, Scalar, Tuple, Type, Union } from "@typespec/compiler"; import { Placeholder } from "./placeholder.js"; import type { TypeEmitter } from "./type-emitter.js"; type AssetEmitterOptions = { noEmit: boolean; emitterOutputDir: string; } & TOptions; export interface EmitTypeReferenceOptions { readonly referenceContext?: Record; } export interface AssetEmitter> { /** * Get the current emitter context as set by the TypeEmitter's various * context methods. * * @returns The current emitter context */ getContext(): Context; getOptions(): AssetEmitterOptions; getProgram(): Program; emitTypeReference(type: Type, context?: EmitTypeReferenceOptions): EmitEntity; emitDeclarationName(type: TypeSpecDeclaration): string | undefined; emitType(type: Type, context?: Partial): EmitEntity; emitProgram(options?: { emitGlobalNamespace?: boolean; emitTypeSpecNamespace?: boolean; }): void; emitModelProperties(model: Model): EmitEntity; emitModelProperty(prop: ModelProperty): EmitEntity; emitOperationParameters(operation: Operation): EmitEntity; emitOperationReturnType(operation: Operation): EmitEntity; emitInterfaceOperations(iface: Interface): EmitEntity; emitInterfaceOperation(operation: Operation): EmitEntity; emitEnumMembers(en: Enum): EmitEntity; emitUnionVariants(union: Union): EmitEntity; emitTupleLiteralValues(tuple: Tuple): EmitEntity; emitSourceFile(sourceFile: SourceFile): Promise; /** * Create a source file. * * @param name the path of the file, resolved relative to the emitter's output directory. */ createSourceFile(name: string): SourceFile; createScope(sourceFile: SourceFile, name: string): SourceFileScope; createScope(namespace: any, name: string, parentScope: Scope): NamespaceScope; createScope(block: any, name: string, parentScope?: Scope | null): Scope; result: { declaration(name: string, value: T | Placeholder): Declaration; rawCode(value: T | Placeholder): RawCode; none(): NoEmit; }; writeOutput(): Promise; /** Get source files that have been scoped. */ getSourceFiles(): SourceFile[]; } export interface ScopeBase { kind: string; name: string; parentScope: Scope | null; childScopes: Scope[]; declarations: Declaration[]; } export interface SourceFileScope extends ScopeBase { kind: "sourceFile"; sourceFile: SourceFile; } export interface NamespaceScope extends ScopeBase { kind: "namespace"; parentScope: Scope; namespace: any; } export type Scope = SourceFileScope | NamespaceScope; export interface TypeReference { expression: string; } export interface SourceFile { path: string; globalScope: Scope; imports: Map; meta: Record; } export interface EmittedSourceFile { contents: string; path: string; } export type EmitEntity = Declaration | RawCode | NoEmit | CircularEmit; export declare class EmitterResult { } export declare class Declaration extends EmitterResult { name: string; scope: Scope; value: T | Placeholder; kind: "declaration"; meta: Record; constructor(name: string, scope: Scope, value: T | Placeholder); } export declare class RawCode extends EmitterResult { value: T | Placeholder; kind: "code"; constructor(value: T | Placeholder); } export declare class NoEmit extends EmitterResult { kind: "none"; } export declare class CircularEmit extends EmitterResult { emitEntityKey: [string, Type, ContextState]; kind: "circular"; constructor(emitEntityKey: [string, Type, ContextState]); } export interface AssetTag { language: AssetTagFactory; create(key: string): AssetTagFactory; } export interface AssetTagInstance { } export type AssetTagFactory = { (value: string): AssetTagInstance; }; export type TypeSpecDeclaration = Model | Interface | Union | Operation | Enum | Scalar | IntrinsicType; export interface ContextState { lexicalContext: Record; referenceContext: Record; } export type Context = Record; export type ESRecord = Record & { _record: true; }; type EndingWith = Names extends `${infer _X}${Name}` ? Names : never; export type TypeEmitterMethod = keyof Omit, "sourceFile" | "declarationName" | "reference" | "circularReference" | "emitValue" | "writeOutput" | EndingWith, "Context">>; export interface LexicalTypeStackEntry { method: TypeEmitterMethod; args: any[]; } export interface EmitterState { lexicalTypeStack: LexicalTypeStackEntry[]; context: ContextState; } export {}; //# sourceMappingURL=types.d.ts.map