CompileTsSourceOptions
Interface in Authoring
Options controlling compilation of a TypeShade TypeScript source string.
import type { CompileTsSourceOptions } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit af54ddad5.
Syntax
interface CompileTsSourceOptions { readonly fileName?: string; readonly requireDirective?: boolean; readonly emit?: boolean; readonly sourceFile?: ts.SourceFile; readonly deprecations?: boolean; readonly checkReservedNames?: boolean; readonly readDocument?: (fileName: string) => string | undefined; readonly resolveImport?: (fromFile: string, specifier: string) => string | undefined;}Instance properties
fileNameoptionalread onlystringrequireDirectiveoptionalread onlybooleanWhen
true(the default), a file without the"use typeshade"directive gets oneMISSING_DIRECTIVEerror diagnostic and an otherwise empty result, so a caller cannot mistake a file that never opted in for a program that compiled to nothing. Passfalsefor a probe that only wantshasDirective(the language service’s navigation and semantic tokens do): the same empty result comes back with no diagnostic.emitoptionalread onlybooleanWhen
false, skipspackModule/WGSL emission entirely: the front end still parses, analyzes and lowers to IR, butCompileTsSourceResult.wgslis alwaysundefined. The language service’s diagnostics analysis uses this sogetDiagnosticsnever produces shader text (design doc §8). Defaults totrue, the pre-existing behavior.sourceFileoptionalread onlyts.SourceFileA pre-parsed source file to analyze instead of parsing
sourceagain — the language service passes its own TypeScript program’sSourceFilehere sogetDiagnosticsruns on the exact node identities the program already built, never a second parse (design doc §5, §8).sourcemust still be given (some callers, and every existing one, use it as the text and never set this); when set,sourceis not re-parsed andoptions.fileNameis ignored in favor ofsourceFile.fileName.deprecationsoptionalread onlybooleanWhen
true, report the deprecation warnings for spellings whose meaning is scheduled to change (Rule 13.10). No window is open today, so the flag reports nothing: change 0134 retired the one warning it had. Off by default, and off is the whole of the compiler’s behaviour: the flag adds warnings and moves no emitted byte, so a build that turns it on and a build that does not produce the same shader.checkReservedNamesoptionalread onlybooleanNo effect since change 0070, which spells a name a target reserves afresh instead of refusing it. Kept so that a caller that passes it still compiles.
readDocumentoptionalread only(fileName: string) => string | undefinedReads a file this source imports (Rule 3.9, surface §68): its text, or
undefinedwhen there is none, and a package’spackage.json, which the defaultresolveImportreads. The source and every shader file it imports, directly or through another, are compiled as one program into one module. Without it nothing is read, a source with no import compiles as it always has, and an import isTS8072.resolveImportoptionalread only(fromFile: string, specifier: string) => string | undefinedThe file a specifier written in
fromFilenames, orundefinedwhen it names none. The default is the rule the language service resolves an import by: relative to the importing file,.jsand.mjsread as.ts, and.tsappended to any other path; any other specifier a package, found innode_modulesthroughreadDocument(surface §68).
Source
src/compiler/ts/source-file.ts, line 100, at commit af54ddad5