Use tsgo to run type checks on client in watch mode

This reduces the time to get `src` transpiled and fully type checked to around 15seconds on my machine
This commit is contained in:
Matt Bierner
2026-02-18 23:12:58 -08:00
parent cc23c3af8e
commit 86da9175eb
4 changed files with 23 additions and 6 deletions

View File

@@ -37,7 +37,7 @@ const compileClientTask = task.define('compile-client', task.series(util.rimraf(
gulp.task(compileClientTask);
const watchClientTask = useEsbuildTranspile
? task.define('watch-client', task.parallel(compilation.watchTask('out', false, 'src', { noEmit: true }), compilation.watchApiProposalNamesTask, compilation.watchExtensionPointNamesTask, compilation.watchCodiconsTask))
? task.define('watch-client', task.parallel(compilation.watchTypeCheckTask('src'), compilation.watchApiProposalNamesTask, compilation.watchExtensionPointNamesTask, compilation.watchCodiconsTask))
: task.define('watch-client', task.series(util.rimraf('out'), task.parallel(compilation.watchTask('out', false), compilation.watchApiProposalNamesTask, compilation.watchExtensionPointNamesTask, compilation.watchCodiconsTask)));
gulp.task(watchClientTask);

View File

@@ -23,6 +23,7 @@ import watch from './watch/index.ts';
import bom from 'gulp-bom';
import * as tsb from './tsb/index.ts';
import sourcemaps from 'gulp-sourcemaps';
import { createTsgoStream } from './tsgo.ts';
import { extractExtensionPointNamesFromFile } from './extractExtensionPoints.ts';
@@ -190,6 +191,23 @@ export function watchTask(out: string, build: boolean, srcPath: string = 'src',
return task;
}
export function watchTypeCheckTask(src: string): task.StreamTask {
const theTask = () => {
const projectPath = path.join(import.meta.dirname, '../../', src, 'tsconfig.json');
const watchInput = watch(`${src}/**`, { base: src, readDelay: 200 });
const tsgoStream = watchInput.pipe(util.debounce(() => {
const stream = createTsgoStream(projectPath, { taskName: 'watch-client-noEmit', noEmit: true });
const result = es.through();
stream.on('end', () => result.emit('end'));
stream.on('error', () => result.emit('end'));
return result;
}));
return tsgoStream;
};
theTask.taskName = `watch-typecheck-${path.basename(src)}`;
return theTask;
}
const REPO_SRC_FOLDER = path.join(import.meta.dirname, '../../src');
class MonacoGenerator {

View File

@@ -18,11 +18,9 @@ export function spawnTsgo(projectPath: string, config: { taskName: string; noEmi
function runReporter(output: string) {
const lines = (output || '').split('\n');
const errorLines = lines.filter(line => /error \w+:/.test(line));
if (errorLines.length > 0) {
fancyLog(`Finished ${ansiColors.green(config.taskName)} ${projectPath} with ${errorLines.length} errors.`);
for (const line of errorLines) {
fancyLog(line);
}
fancyLog(`Finished ${ansiColors.green(config.taskName)} ${projectPath} with ${errorLines.length} errors.`);
for (const line of errorLines) {
fancyLog(line);
}
}

View File

@@ -8,6 +8,7 @@
"allowJs": true,
"resolveJsonModule": true,
"isolatedModules": false,
"skipLibCheck": true,
"outDir": "../out/vs",
"types": [
"@webgpu/types",