CompileTsSourceResult
Interface in Authoring
The result of compiling a TypeShade TypeScript source string, including IR and optional WGSL.
import type { CompileTsSourceResult } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
interface CompileTsSourceResult { readonly hasDirective: boolean; readonly funcs: readonly FuncDecl[]; readonly diagnostics: readonly TsCompilerDiagnostic[]; readonly sourceFile: ts.SourceFile; readonly consts: readonly ConstDecl[]; readonly bindings: readonly BindingDecl[]; readonly structs: readonly CollectedStruct[]; readonly overrides: readonly OverrideDecl[]; readonly vars: readonly ModuleVarDecl[]; readonly enables: readonly DeclarableCapability[]; readonly directives: readonly DiagnosticDirective[]; readonly symbols: readonly DeclaredSymbol[]; readonly expressions: readonly LoweredExpression[]; readonly wgsl?: string;}Instance properties
hasDirectiveread onlybooleanfuncsread onlyreadonly FuncDecl[]diagnosticsread onlyreadonly TsCompilerDiagnostic[]sourceFileread onlyts.SourceFileconstsread onlyreadonly ConstDecl[]bindingsread onlyreadonly BindingDecl[]structsread onlyreadonly CollectedStruct[]overridesread onlyreadonly OverrideDecl[]Every
override<T>the module declares — WGSL specialization constants, which the pipeline sets and no pass folds. Empty for a module that declares none.varsread onlyreadonly ModuleVarDecl[]Every module variable (
let x: workgroup<T>,let y: T = init, §24) the module declares. Empty for a module that declares none.enablesread onlyreadonly DeclarableCapability[]The capabilities the file’s
"enable <extension>";directives turn on (§50), by neutral id. Empty for a file that enables nothing, which is most; the two extension-gated@builtin(...)ids do not need one, sincerequiredCapsderives their capability from the use.directivesread onlyreadonly DiagnosticDirective[]The
diagnostic(severity, rule);directives the file’s entries ask for (§54), in source order. Empty for a file that asks for none, which is most. Carried here rather than left at the emit, because the assembledModuleDeclan example registers is built from this result — and a module missing the directive it was written with is one Tint refuses. Nameddirectivesand notdiagnostics: that name is taken, by the compiler’s own error list, and one of the two would have read as the other at every call site.symbolsread onlyreadonly DeclaredSymbol[]Every name the front end declared while lowering
sourceFile, with theShaderTypeit gave it and the UTF-16 span of the declared name: the table an editor answers “what type is this symbol” from, since TypeScript infers plainnumberfor a numeric literal that the compiler typesf32. Empty when nothing was lowered (no directive, a parse error). A side output: nothing here feeds lowering, the IR or emitted text. SeeDeclaredSymbol.expressionsread onlyreadonly LoweredExpression[]Every expression the front end lowered in
sourceFile, with theShaderTypeit gave it and its UTF-16 span, in source order: the table an editor’s own type for an expression is held to (Rule 12.7, 0015). A span lowered to two types is left out, and a refused expression records nothing. Empty when nothing was lowered. A side output, likesymbols: nothing here feeds lowering, the IR or emitted text. SeeLoweredExpression.wgsloptionalread onlystring
Source
src/compiler/ts/source-file.ts, line 139, at commit 26de7be8