Skip to content

[I] CompilerHost

  • SystemHost
PropertyTypeDescription
logSinkLogSink-
parseCache?WeakMap<SourceFile, TypeSpecScriptNode>Optional cache to reuse the results of parsing and binding across programs.
fileURLToPath(url): string;
ParameterType
urlstring

string


getExecutionRoot(): string;

string


getJsImport(path): Promise<Record<string, any>>;
ParameterType
pathstring

Promise<Record<string, any>>


getLibDirs(): string[];

string[]


getSourceFileKind(path): undefined | SourceFileKind;
ParameterType
pathstring

undefined | SourceFileKind


mkdirp(path): Promise<undefined | string>;

create directory recursively.

ParameterTypeDescription
pathstringPath to the directory.

Promise<undefined | string>

SystemHost.mkdirp

pathToFileURL(path): string;
ParameterType
pathstring

string


readDir(path): Promise<string[]>;

Read directory.

ParameterTypeDescription
pathstringPath to the directory.

Promise<string[]>

list of file/directory in the given directory. Returns the name not the full path.

SystemHost.readDir

readFile(path): Promise<SourceFile>;

read a utf-8 or utf-8 with bom encoded file

ParameterType
pathstring

Promise<SourceFile>

SystemHost.readFile

readUrl(url): Promise<SourceFile>;

read a file at the given url.

ParameterType
urlstring

Promise<SourceFile>

SystemHost.readUrl

realpath(path): Promise<string>;
ParameterType
pathstring

Promise<string>

SystemHost.realpath

rm(path, options?): Promise<void>;

Deletes a directory or file.

ParameterTypeDescription
pathstringPath to the directory or file.
options?RmOptions-

Promise<void>

SystemHost.rm

stat(path): Promise<{
isDirectory: boolean;
isFile: boolean;
}>;
ParameterType
pathstring

Promise<{ isDirectory: boolean; isFile: boolean; }>

SystemHost.stat

writeFile(path, content): Promise<void>;

Write the file.

ParameterTypeDescription
pathstringPath to the file.
contentstringContent of the file.

Promise<void>

SystemHost.writeFile