LensStudio:TypeScript.ITypeScriptCompilationApi
ClassPlugin component interface for invoking TypeScript compilation on the current project or an isolated tsconfig.
Index
Properties
Methods
Example
const FileSystem = await import('LensStudio:FileSystem');
const { ITypeScriptCompilationApi } = await import('LensStudio:TypeScript');
const compiler = this.pluginSystem.findInterface(ITypeScriptCompilationApi) as ITypeScriptCompilationApi;
if (Editor.isNull(compiler)) {
console.log('Compilation API not available');
return;
}
const projectResult = await compiler.refreshProjectCompilation();
console.log(`Project compile: succeeded=${projectResult.succeeded} errors=${projectResult.errors.length}`);
const tmp = FileSystem.TempDir.create();
FileSystem.writeFile(
tmp.path.appended(new Editor.Path('a.ts')),
'const x: number = 1; export {};',
);
FileSystem.writeFile(
tmp.path.appended(new Editor.Path('tsconfig.json')),
JSON.stringify({
compilerOptions: { module: 'esnext', target: 'es2021', isolatedModules: true, outDir: 'out' },
include: ['a.ts'],
}),
);
const isolated = await compiler.runIsolatedCompilation(
tmp.path.appended(new Editor.Path('tsconfig.json')).toString(),
);
console.log(`Isolated compile: succeeded=${isolated.succeeded} errors=${isolated.errors.length}`);
Extends
Properties
interfaceId
staticinterfaceId:InterfaceId
Interface identifier for resolving the TypeScript compilation API via the plugin system.
Methods
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
refreshProjectCompilation()
refreshProjectCompilation():
Promise<TypeScriptCompilationResult>
Recompiles the current project TypeScript and resolves with the resulting compilation result.
Returns
Promise<TypeScriptCompilationResult>
runIsolatedCompilation()
runIsolatedCompilation(
tsconfigPath):Promise<TypeScriptCompilationResult>
Compiles the project at the given tsconfig path in isolation and resolves with the resulting compilation result.
Parameters
| Parameter | Type |
|---|---|
tsconfigPath | string |
Returns
Promise<TypeScriptCompilationResult>