Skip to content

Commit a923063

Browse files
josefsCopilot
andcommitted
Bump TypeScript to 7.0.2
TypeScript 7 is the native (Go) compiler and does not ship a JS API. Following the upstream recommendation, `typescript` is aliased to `@typescript/typescript6` so tools that use the compiler API (typescript-eslint, ts-jest, ts-node, ts-json-schema-generator, Storybook) keep working, while `@typescript/native` provides the TypeScript 7 `tsc` used for type-checking. - Replace gulp-typescript with the TypeScript 7 `tsc` CLI in gulp tasks - Replace the removed `moduleResolution: node` with `bundler` in src/view - Declare `*.css` modules for side-effect CSS imports - Fix webview event handler types surfaced by the stricter resolution - Update the VS Code build task problem matcher Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2c54892-58d8-42e7-940b-8a0e22f9fa6d
1 parent 4007728 commit a923063

10 files changed

Lines changed: 481 additions & 738 deletions

File tree

‎.vscode/tasks.json‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,11 @@
2424
},
2525
"problemMatcher": [
2626
{
27-
"owner": "typescript",
28-
"fileLocation": "absolute",
29-
"pattern": {
30-
"regexp": "^\\[gulp-typescript\\] ([^(]+)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\): error TS\\d+: (.*)$",
31-
"file": 1,
32-
"location": 2,
33-
"message": 3
34-
}
27+
"base": "$tsc",
28+
"fileLocation": [
29+
"relative",
30+
"${workspaceFolder}/extensions/ql-vscode"
31+
]
3532
},
3633
"$ts-webpack"
3734
]

‎extensions/ql-vscode/gulpfile.ts/typescript.ts‎

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,46 @@
1-
import { gray, red } from "ansi-colors";
21
import { dest, parallel, src, watch } from "gulp";
32
import esbuild from "gulp-esbuild";
4-
import type { reporter } from "gulp-typescript";
5-
import { createProject } from "gulp-typescript";
63
import del from "del";
74
import { pipeline } from "stream/promises";
85
import { mkdir } from "fs/promises";
6+
import { resolve } from "path";
7+
import { spawn } from "cross-spawn";
98

10-
export function goodReporter(): reporter.Reporter {
11-
return {
12-
error: (error, typescript) => {
13-
if (error.tsFile) {
14-
console.log(
15-
`[${gray("gulp-typescript")}] ${red(
16-
`${error.fullFilename}(${error.startPosition!.line + 1},${
17-
error.startPosition!.character
18-
}): `,
19-
)}error TS${
20-
error.diagnostic.code
21-
}: ${typescript.flattenDiagnosticMessageText(
22-
error.diagnostic.messageText,
23-
"\n",
24-
)}`,
25-
);
9+
/**
10+
* Type-checks the given TypeScript project using the `tsc` executable from
11+
* TypeScript 7 (installed as `@typescript/native`).
12+
*/
13+
export async function runTypeScriptCheck(project: string): Promise<void> {
14+
const proc = spawn(
15+
resolve(__dirname, "../node_modules/.bin/tsc"),
16+
["--noEmit", "--pretty", "false", "--project", project],
17+
{
18+
cwd: resolve(__dirname, ".."),
19+
stdio: ["ignore", "inherit", "inherit"],
20+
},
21+
);
22+
23+
await new Promise((resolve, reject) => {
24+
proc.on("error", reject);
25+
26+
proc.on("close", (code) => {
27+
if (code === 0) {
28+
resolve(undefined);
2629
} else {
27-
console.log(error.message);
30+
// gulp-cli only prints the message (without a stack trace) for errors with `showStack: false`.
31+
reject(
32+
Object.assign(
33+
new Error(`TypeScript type-checking of ${project} failed`),
34+
{ showStack: false },
35+
),
36+
);
2837
}
29-
},
30-
};
38+
});
39+
});
3140
}
3241

33-
const tsProject = createProject("tsconfig.json");
34-
3542
export function cleanOutput() {
36-
return tsProject.projectDirectory
37-
? del(`${tsProject.projectDirectory}/out/*`)
38-
: Promise.resolve();
43+
return del("out/*");
3944
}
4045

4146
export function compileEsbuild() {
@@ -63,9 +68,7 @@ export function watchEsbuild() {
6368
}
6469

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

7174
export function watchCheckTypeScript() {

‎extensions/ql-vscode/gulpfile.ts/view.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import { dest, src, watch } from "gulp";
22
import esbuild from "gulp-esbuild";
3-
import { createProject } from "gulp-typescript";
4-
import { goodReporter } from "./typescript";
3+
import { runTypeScriptCheck } from "./typescript";
54

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

9-
const tsProject = createProject("src/view/tsconfig.json");
10-
118
export function compileViewEsbuild() {
129
return pipeline(
1310
src("./src/view/webview.tsx"),
@@ -33,9 +30,7 @@ export function watchViewEsbuild() {
3330
}
3431

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

4136
export function watchViewCheckTypeScript() {

0 commit comments

Comments
 (0)