[I] Program
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
checker | public | Checker | DANGER 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/ |
compilerOptions | public | CompilerOptions | - |
currentStage | readonly | CompilationStage | The current stage of the compilation pipeline. Progresses through: “parsing” → “checking” → “validating” → “linting” → “emitting”. |
diagnostics | readonly | readonly Diagnostic[] | - |
emitters | public | EmitterRef[] | - |
host | public | CompilerHost | - |
jsSourceFiles | public | Map<string, JsSourceFileNode> | - |
projectRoot | readonly | string | Project root. If a tsconfig was found/specified this is the directory for the tsconfig.json. Otherwise directory where the entrypoint is located. |
sourceFiles | public | Map<string, TypeSpecScriptNode> | All source files in the program, keyed by their file path. |
tracer | public | Tracer | - |
Methods
Section titled “Methods”getGlobalNamespaceType()
Section titled “getGlobalNamespaceType()”getGlobalNamespaceType(): Namespace;Returns
Section titled “Returns”getSourceFileLocationContext()
Section titled “getSourceFileLocationContext()”getSourceFileLocationContext(sourceFile): LocationContext;Return location context of the given source file.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sourceFile | SourceFile |
Returns
Section titled “Returns”hasError()
Section titled “hasError()”hasError(): boolean;Returns
Section titled “Returns”boolean
reportDiagnostic()
Section titled “reportDiagnostic()”reportDiagnostic(diagnostic): void;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
diagnostic | Diagnostic |
Returns
Section titled “Returns”void
reportDiagnostics()
Section titled “reportDiagnostics()”reportDiagnostics(diagnostics): void;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
diagnostics | readonly Diagnostic[] |
Returns
Section titled “Returns”void
resolveTypeReference()
Section titled “resolveTypeReference()”resolveTypeReference(reference): [Type | undefined, readonly Diagnostic[]];Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
reference | string |
Returns
Section titled “Returns”[Type | undefined, readonly Diagnostic[]]
stateMap()
Section titled “stateMap()”stateMap(key): Map<Type, any>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key | symbol |
Returns
Section titled “Returns”Map<Type, any>
stateSet()
Section titled “stateSet()”stateSet(key): Set<Type>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key | symbol |
Returns
Section titled “Returns”Set<Type>
trace()
Section titled “trace()”trace(area, message): void;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
area | string |
message | string |
Returns
Section titled “Returns”void
useCache()
Section titled “useCache()”useCache<T>( key, type, compute): T;Get a cached value for the given key, computing it if not already cached. Caching is only active during the “validating” stage and later (not during “parsing” or “checking”) because decorators may mutate types during the checking stage, making cached values stale.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | symbol | A unique symbol identifying this cache entry. |
type | Type | The type to use as the cache key within this cache entry. |
compute | () => T | A function that computes the value if not cached. |
Returns
Section titled “Returns”T
The cached or freshly computed value.