Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@
},
"problemMatcher": [
{
"owner": "typescript",
"fileLocation": "absolute",
"pattern": {
"regexp": "^\\[gulp-typescript\\] ([^(]+)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\): error TS\\d+: (.*)$",
"file": 1,
"location": 2,
"message": 3
}
"base": "$tsc",
"fileLocation": [
"relative",
"${workspaceFolder}/extensions/ql-vscode"
]
},
"$ts-webpack"
]
Expand Down
63 changes: 33 additions & 30 deletions extensions/ql-vscode/gulpfile.ts/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,46 @@
import { gray, red } from "ansi-colors";
import { dest, parallel, src, watch } from "gulp";
import esbuild from "gulp-esbuild";
import type { reporter } from "gulp-typescript";
import { createProject } from "gulp-typescript";
import del from "del";
import { pipeline } from "stream/promises";
import { mkdir } from "fs/promises";
import { resolve } from "path";
import { spawn } from "cross-spawn";

export function goodReporter(): reporter.Reporter {
return {
error: (error, typescript) => {
if (error.tsFile) {
console.log(
`[${gray("gulp-typescript")}] ${red(
`${error.fullFilename}(${error.startPosition!.line + 1},${
error.startPosition!.character
}): `,
)}error TS${
error.diagnostic.code
}: ${typescript.flattenDiagnosticMessageText(
error.diagnostic.messageText,
"\n",
)}`,
);
/**
* Type-checks the given TypeScript project using the `tsc` executable from
* TypeScript 7 (installed as `@typescript/native`).
*/
export async function runTypeScriptCheck(project: string): Promise<void> {
const proc = spawn(
resolve(__dirname, "../node_modules/.bin/tsc"),
["--noEmit", "--pretty", "false", "--project", project],
{
cwd: resolve(__dirname, ".."),
stdio: ["ignore", "inherit", "inherit"],
},
);

await new Promise((resolve, reject) => {
proc.on("error", reject);

proc.on("close", (code) => {
if (code === 0) {
resolve(undefined);
} else {
console.log(error.message);
// gulp-cli only prints the message (without a stack trace) for errors with `showStack: false`.
reject(
Object.assign(
new Error(`TypeScript type-checking of ${project} failed`),
{ showStack: false },
),
);
}
},
};
});
});
}

const tsProject = createProject("tsconfig.json");

export function cleanOutput() {
return tsProject.projectDirectory
? del(`${tsProject.projectDirectory}/out/*`)
: Promise.resolve();
return del("out/*");
}

export function compileEsbuild() {
Expand Down Expand Up @@ -63,9 +68,7 @@ export function watchEsbuild() {
}

export function checkTypeScript() {
// This doesn't actually output the TypeScript files, it just
// runs the TypeScript compiler and reports any errors.
return tsProject.src().pipe(tsProject(goodReporter()));
return runTypeScriptCheck("tsconfig.json");
}

export function watchCheckTypeScript() {
Expand Down
9 changes: 2 additions & 7 deletions extensions/ql-vscode/gulpfile.ts/view.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { dest, src, watch } from "gulp";
import esbuild from "gulp-esbuild";
import { createProject } from "gulp-typescript";
import { goodReporter } from "./typescript";
import { runTypeScriptCheck } from "./typescript";

import { pipeline } from "stream/promises";
import chromiumVersion from "./chromium-version.json";

const tsProject = createProject("src/view/tsconfig.json");

export function compileViewEsbuild() {
return pipeline(
src("./src/view/webview.tsx"),
Expand All @@ -33,9 +30,7 @@ export function watchViewEsbuild() {
}

export function checkViewTypeScript() {
// This doesn't actually output the TypeScript files, it just
// runs the TypeScript compiler and reports any errors.
return tsProject.src().pipe(tsProject(goodReporter()));
return runTypeScriptCheck("src/view/tsconfig.json");
}

export function watchViewCheckTypeScript() {
Expand Down
Loading
Loading