refactor: fix some types#20412
Conversation
🦋 Changeset detectedLatest commit: afcf057 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| has: <K extends string>(key: K) => boolean; | ||
| delete: <K extends string>(key: K) => boolean; | ||
| } | ||
| declare interface CodeGenValue<K extends string> {} |
There was a problem hiding this comment.
Looks like our types generator is broken here, WIP
|
This PR is packaged and the instant preview is available (1f0ab08). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@1f0ab08
yarn add -D webpack@https://pkg.pr.new/webpack@1f0ab08
pnpm add -D webpack@https://pkg.pr.new/webpack@1f0ab08 |
24b71cc to
6d9c1c3
Compare
| ? StatsError | ||
| : T extends ModuleProfile | ||
| ? StatsProfile | ||
| : F; |
There was a problem hiding this comment.
This type declaration looks kinda unusual. I'm not sure it's any kind of problem, but it did stand out when I was browsing through the diff.
There was a problem hiding this comment.
This is an example of using Conditional Types in TypeScript; the way I interpret it initially, it's a way to declare generic types that can be implemented for a variety of possibly-disjoint -- but always well-typed -- datastructures.
As far as I can tell, the top-level type being declared here (the one that has this multi-nested chain of conditional types associated with it) -- StatsObject -- is only used in a single file within the source code at the moment, in some comment-based API documentation:
webpack/lib/stats/StatsFactory.js
Lines 63 to 75 in 26e549a
There was a problem hiding this comment.
This is a valid type, we use hooks where unfold complex structure - compilation, unfortunately, this cannot be resolved otherwise and requires rewriting the hook logic, which in turn can lead to a loss of performance
Summary
improve types
What kind of change does this PR introduce?
refactor
Did you add tests for your changes?
Existing
Does this PR introduce a breaking change?
No
If relevant, what needs to be documented once your changes are merged or what have you already documented?
Nothing