Skip to content

[I] Program

PropertyModifierTypeDescription
checkerpublicCheckerDANGER Using the checker is reserved for advanced usage and should be used with caution. API are not subject to the same stability guarantees see See https://typespec.io/docs/handbook/breaking-change-policy/
compilerOptionspublicCompilerOptions-
diagnosticsreadonlyreadonly Diagnostic[]-
emitterspublicEmitterRef[]-
hostpublicCompilerHost-
jsSourceFilespublicMap<string, JsSourceFileNode>-
projectRootreadonlystringProject root. If a tsconfig was found/specified this is the directory for the tsconfig.json. Otherwise directory where the entrypoint is located.
sourceFilespublicMap<string, TypeSpecScriptNode>All source files in the program, keyed by their file path.
tracerpublicTracer-
getGlobalNamespaceType(): Namespace;

Namespace


getSourceFileLocationContext(sourceFile): LocationContext;

Return location context of the given source file.

ParameterType
sourceFileSourceFile

LocationContext


getTypeInfo(target): TypeInfo | undefined;

Query the registered $onInfo providers for extra information about the given type. Returns the merged information contributed by every library, or undefined when none contributed. Providers are run lazily and never mutate the type graph. Used by the language server for hover docs and by tooling.

Requires the experimental type-info-hook compiler feature to be enabled; returns undefined otherwise.

ParameterType
targetType

TypeInfo | undefined


hasError(): boolean;

boolean


reportDiagnostic(diagnostic): void;
ParameterType
diagnosticDiagnostic

void


reportDiagnostics(diagnostics): void;
ParameterType
diagnosticsreadonly Diagnostic[]

void


resolveTypeReference(reference): [Type | undefined, readonly Diagnostic[]];
ParameterType
referencestring

[Type | undefined, readonly Diagnostic[]]


stateMap(key): Map<Type, any>;
ParameterType
keysymbol

Map<Type, any>


stateSet(key): Set<Type>;
ParameterType
keysymbol

Set<Type>


trace(area, message): void;
ParameterType
areastring
messagestring

void