CompileTsSourceResult
On this page

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 only boolean
funcsread only readonly FuncDecl[]
diagnosticsread only readonly TsCompilerDiagnostic[]
sourceFileread only ts.SourceFile
constsread only readonly ConstDecl[]
bindingsread only readonly BindingDecl[]
structsread only readonly CollectedStruct[]
overridesread only readonly 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 only readonly ModuleVarDecl[]

Every module variable (let x: workgroup<T>, let y: T = init, §24) the module declares. Empty for a module that declares none.

enablesread only readonly 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, since requiredCaps derives their capability from the use.

directivesread only readonly 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 assembled ModuleDecl an example registers is built from this result — and a module missing the directive it was written with is one Tint refuses. Named directives and not diagnostics: 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 only readonly DeclaredSymbol[]

Every name the front end declared while lowering sourceFile, with the ShaderType it 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 plain number for a numeric literal that the compiler types f32. Empty when nothing was lowered (no directive, a parse error). A side output: nothing here feeds lowering, the IR or emitted text. See DeclaredSymbol.

expressionsread only readonly LoweredExpression[]

Every expression the front end lowered in sourceFile, with the ShaderType it 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, like symbols: nothing here feeds lowering, the IR or emitted text. See LoweredExpression.

wgsloptionalread only string

Source

src/compiler/ts/source-file.ts, line 139, at commit 26de7be8

Edit this page Report a problem