-
Notifications
You must be signed in to change notification settings - Fork 16.3k
build: drop @types/webpack-env in favor of webpack/module types #47798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -150,7 +150,7 @@ if (cjsPreloads.length) { | |||
} | |||
} | |||
if (esmPreloads.length) { | |||
const { runEntryPointWithESMLoader } = __non_webpack_require__('internal/modules/run_main'); | |||
const { runEntryPointWithESMLoader } = __non_webpack_require__('internal/modules/run_main') as typeof import('@node/lib/internal/modules/run_main'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not map this magically somehow in TS, declaring the type of non_webpack_require better or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I'm aware of. If we could, it would also be a bit tricky because it would be mapping internal/modules/run_main
to ../third_party/electron_node/lib/internal/modules/run_main
implicitly, which would be coupling __non_webpack_require__
to just requiring modules from ../third_party/electron_node
which probably isn't something we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think defining it as internal/*
mapping to ../third_party/electron_node/lib/internal/$1
is fine if that's possible?
0554134
to
ad0d440
Compare
@@ -857,13 +857,13 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => { | |||
const { readdir } = fs; | |||
fs.readdir = function (pathArgument: string, options: ReaddirOptions, callback: ReaddirCallback) { | |||
callback = typeof options === 'function' ? options : callback; | |||
validateFunction(callback, 'callback'); | |||
validateFunction(callback, 'callback')!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are necessary because TS doesn't like the typings for these validate*
functions from Node because you can't use asserts x is type
syntax with arrow functions, see microsoft/TypeScript#34523. There's workarounds but the typings in Node are being done via JSDoc and not sure a workaround can be done in that particular case.
@@ -143,7 +143,9 @@ if ((globalThis.process || binding.process).argv.includes("--profile-electron-in | |||
transpileOnly: onlyPrintingGraph, | |||
ignoreDiagnostics: [ | |||
// File '{0}' is not under 'rootDir' '{1}'. | |||
6059 | |||
6059, | |||
// Private field '{0}' must be declared in an enclosing class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This trips on at least this line from Node - figured it was easier to dd an ignore than try to patch it or otherwise may tsc
happy.
Description of Change
This change was prompted by #47621 which is trying to bring in the latest
@types/webpack-env
and causing TS build errors due to conflicting types. Webpack addedmodule.d.ts
in v5.62.0, which serves the same purpose as@types/webpack-env
, so this PR switches to it and drops@types/webpack-env
.This PR also adds a path mapping in
tsconfig.json
to map@node/*
to../third_party/electron_node
and types the requires of Node.js modules so that we get accurate types for them, which required tweaking our existing types a bit.Checklist
Release Notes
Notes: none