chore(types): improve type safety#20755
Conversation
|
|
This PR is packaged and the instant preview is available (315f8a2). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@315f8a2
yarn add -D webpack@https://pkg.pr.new/webpack@315f8a2
pnpm add -D webpack@https://pkg.pr.new/webpack@315f8a2 |
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your changes status has failed because you have indirect coverage changes. Learn more about Unexpected Coverage Changes and reasons for indirect coverage changes. Additional details and impacted files@@ Coverage Diff @@
## main #20755 +/- ##
==========================================
- Coverage 91.42% 91.42% -0.01%
==========================================
Files 559 559
Lines 55103 55103
Branches 14529 14529
==========================================
- Hits 50379 50376 -3
- Misses 4724 4727 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@avivkeller let's fix lint |
Merging this PR will improve performance by 27.53%
Performance Changes
Comparing |
There was a problem hiding this comment.
Pull request overview
Improves TypeScript type robustness in preparation for generating declarations via tsc, by avoiding direct references to types.d.ts and by generalizing unique symbol-typed internals to symbol where declaration emission would otherwise be problematic.
Changes:
- Replace JSDoc type imports that pointed directly at
types.d.tswith imports targeting the package root. - Generalize several internal
unique symboltypings tosymbolin both runtime JSDoc and the shippedtypes.d.ts. - Update the benchmark TS config to use bundler-style resolution suitable for these package-root type imports.
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
types.d.ts |
Replaces several typeof <unique symbol>-based typings with symbol and simplifies Meta symbol-key typing to avoid referencing internal symbol declarations. |
tsconfig.types.benchmark.json |
Switches benchmark typechecking to module: es2022 + moduleResolution: bundler to support package-root type imports. |
test/BenchmarkTestCases.benchmark.mjs |
Updates JSDoc typedef imports to reference the package root (..) instead of types.d.ts. |
test/benchmarkCases/wasm-modules-sync/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/wasm-modules-async/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/typescript-long-on-schedule/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/three-long/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/side-effects-reexport/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/react/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/many-modules-esm/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/many-modules-commonjs/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/many-chunks-esm/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/many-chunks-commonjs/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/lodash/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/json-modules/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/future-defaults/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/devtool-source-map/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/devtool-eval/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/devtool-eval-source-map/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/css-modules/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/context-esm/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/context-commonjs/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/concatenate-modules/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/cache-filesystem/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/asset-modules-source/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/asset-modules-resource/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/asset-modules-inline/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
test/benchmarkCases/asset-modules-bytes/webpack.config.mjs |
Updates config JSDoc type import to use package root (../../..). |
lib/Dependency.js |
Casts TRANSITIVE symbol to symbol (vs inferred unique symbol) for declaration emission compatibility. |
lib/dependencies/HarmonyImportSpecifierDependency.js |
Casts internal idsSymbol to symbol to avoid emitting unique symbol declarations. |
lib/dependencies/HarmonyExportImportedSpecifierDependency.js |
Casts internal idsSymbol to symbol to avoid emitting unique symbol declarations. |
lib/dependencies/CommonJsExportRequireDependency.js |
Casts internal idsSymbol to symbol to avoid emitting unique symbol declarations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Pre-requisite of #20754.
This PR fixes the following types to be more robust:
types.d.tshave been replaced with references to the package itself. That way, should this file be changed, types will be resolved through the types exported bypackage.json