mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Adds a GN typescript_check template that runs tsgo --noEmit over a
tsconfig and writes a stamp file on success, wired into BUILD.gn as
electron_lib_typecheck. electron_js2c depends on it so a broken type
in lib/ fails 'e build'.
tsgo (@typescript/native-preview, the Go-based TypeScript compiler
preview) runs the full lib/ typecheck in ~400ms, about 6x faster than
tsc 6.0.2 (~2.3s). ts-loader previously typechecked implicitly inside
webpack and was removed in the esbuild migration, so this restores
typecheck coverage that was briefly absent on the bundle build path.
Because tsgo has no 'ignoreDiagnostics' option like ts-loader's, the
previously-silenced TS6059 and TS1111 errors needed to be fixed
properly:
- tsconfig.electron.json drops 'rootDir: "lib"'. It was only
meaningful for emit, and the TS 6 implicit rootDir inference plus
the @node/* path alias was pulling Node's internal .js files
(specifically internal/url.js with its #searchParams brand check)
into the program.
- tsconfig.json drops the @node/* path alias entirely. Every call
site that used 'as typeof import("@node/lib/...")' is replaced
with narrow structural types declared once in an ambient
NodeInternalModules interface in typings/internal-ambient.d.ts.
__non_webpack_require__ becomes an overloaded function that picks
the right return type from a string-literal id argument, so call
sites no longer need 'as' casts.
- tsconfig.default_app.json: moduleResolution 'node' -> 'bundler'
(TS 6 deprecates 'node').
- typings/internal-ambient.d.ts: 'declare module NodeJS { }' ->
'declare namespace NodeJS { }' (TS 6 rejects the module keyword
for non-external declarations).
spec/ts-smoke/runner.js now invokes tsgo's bin instead of resolving
the 'typescript' package. The 'tsc' npm script is repointed from
'tsc' to 'tsgo' so the existing CI step
'node script/yarn.js tsc -p tsconfig.script.json' continues to run.
A small script/typecheck.js wrapper runs tsgo and writes the stamp
file for GN; the typescript_check template invokes it via a new
'tsc-check' npm script.
25 lines
482 B
JSON
25 lines
482 B
JSON
{
|
|
"compilerOptions": {
|
|
"module": "commonjs",
|
|
"target": "es2020",
|
|
"lib": [
|
|
"es2022",
|
|
"dom",
|
|
"dom.iterable"
|
|
],
|
|
"sourceMap": true,
|
|
"experimentalDecorators": true,
|
|
"strict": true,
|
|
"allowJs": true,
|
|
"noUnusedLocals": true,
|
|
"outDir": "ts-gen",
|
|
"typeRoots" : ["./node_modules/@types", "./spec/node_modules/@types"],
|
|
"paths": {
|
|
"@electron/internal/*": ["./lib/*"]
|
|
}
|
|
},
|
|
"exclude": [
|
|
"electron.d.ts"
|
|
],
|
|
}
|