CompileTsSourceOptions
이 페이지에서

CompileTsSourceOptions

인터페이스, 작성 분류

Options controlling compilation of a TypeShade TypeScript source string.

import type { CompileTsSourceOptions } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

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;
}

인스턴스 속성

fileName선택 사항읽기 전용 string
requireDirective선택 사항읽기 전용 boolean

When true (the default), a file without the "use typeshade" directive gets one MISSING_DIRECTIVE error diagnostic and an otherwise empty result, so a caller cannot mistake a file that never opted in for a program that compiled to nothing. Pass false for a probe that only wants hasDirective (the language service’s navigation and semantic tokens do): the same empty result comes back with no diagnostic.

emit선택 사항읽기 전용 boolean

When false, skips packModule/WGSL emission entirely: the front end still parses, analyzes and lowers to IR, but CompileTsSourceResult.wgsl is always undefined. The language service’s diagnostics analysis uses this so getDiagnostics never produces shader text (design doc §8). Defaults to true, the pre-existing behavior.

sourceFile선택 사항읽기 전용 ts.SourceFile

A pre-parsed source file to analyze instead of parsing source again — the language service passes its own TypeScript program’s SourceFile here so getDiagnostics runs on the exact node identities the program already built, never a second parse (design doc §5, §8). source must still be given (some callers, and every existing one, use it as the text and never set this); when set, source is not re-parsed and options.fileName is ignored in favor of sourceFile.fileName.

deprecations선택 사항읽기 전용 boolean

When true, report the deprecation warnings for spellings whose meaning is scheduled to change. One today: an integer-written literal in a declaration with no annotation or declared integer use still types as f32 and will type as i32 (§13). 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.

checkReservedNames선택 사항읽기 전용 boolean

Whether the declared names are held to the targets’ reserved words. Defaults to true, which is what an author’s file wants — in the editor too, where emit is false and the diagnostic is the whole point. A caller that lowers a synthetic source whose names it generated itself, and never emits it, passes false: the debug watch builds __typeshade_watch__ around the author’s expression precisely because no name the author could write starts with two underscores, and runs the result on the CPU oracle, where WGSL’s identifier rules do not apply.

readDocument선택 사항읽기 전용 (fileName: string) => string | undefined

Reads a file this source imports (Rule 3.9, surface §68): its text, or undefined when there is none, and a package’s package.json, which the default resolveImport reads. 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 is TS8072.

resolveImport선택 사항읽기 전용 (fromFile: string, specifier: string) => string | undefined

The file a specifier written in fromFile names, or undefined when it names none. The default is the rule the language service resolves an import by: relative to the importing file, .js and .mjs read as .ts, and .ts appended to any other path; any other specifier a package, found in node_modules through readDocument (surface §68).

소스

src/compiler/ts/source-file.ts, 62행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고