-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Empty bundle prohibition is inconvenient for TypeScript users #11801
Comments
Yes, PR welcome |
andersk
added a commit
to andersk/webpack
that referenced
this issue
Oct 28, 2020
There may be no practical reason to use an empty array here, but it’s not harmful, and allowing it makes the TypeScript typings more convenient, e.g. string[] instead of [string, ...string[]]. The [string, ...string[]] type was annoying to work with because it’s incompatible with almost every nontrivial way you might compute the value other than writing it out literally. For example, using filter or map or importing from a .json file all give you a string[], which cannot be assigned to [string, ...string[]] without an unchecked cast, even if the programmer “knows” the result will be nonempty. Fixes webpack#11801. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
andersk
added a commit
to andersk/webpack
that referenced
this issue
Oct 28, 2020
There may be no practical reason to use an empty array here, but it’s not harmful, and allowing it makes the TypeScript typings more convenient, e.g. string[] instead of [string, ...string[]]. The [string, ...string[]] type was annoying to work with because it’s incompatible with almost every nontrivial way you might compute the value other than writing it out literally. For example, using filter or map or importing from a .json file all give you a string[], which cannot be assigned to [string, ...string[]] without an unchecked cast, even if the programmer “knows” the result will be nonempty. Fixes webpack#11801. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
andersk
added a commit
to andersk/webpack
that referenced
this issue
Oct 28, 2020
There may be no practical reason to use an empty array here, but it’s not harmful, and allowing it makes the TypeScript typings more convenient, e.g. string[] instead of [string, ...string[]]. The [string, ...string[]] type was annoying to work with because it’s incompatible with almost every nontrivial way you might compute the value other than writing it out literally. For example, using filter or map or importing from a .json file all give you a string[], which cannot be assigned to [string, ...string[]] without an unchecked cast, even if the programmer “knows” the result will be nonempty. Fixes webpack#11801. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature request
What is the expected behavior?
The
EntryItem
type should bestring[] | string
, not[string, ...string[]] | string
.What is motivation or use case for adding/changing the behavior?
The
[string, ...string[]]
type is annoying to work with in TypeScript, because it’s incompatible with almost every nontrivial way you might compute theentry
parameter other than writing it out literally. For example, usingfilter
ormap
or importing from a.json
file all give you astring[]
, which cannot be assigned to[string, ...string[]]
without an unchecked cast, even if the programmer “knows” the result will be nonempty.How should this be implemented in your opinion?
Either remove the relevant
"minItems": 1
fromschemas/WebpackOptions.json
, or configurejson-schema-to-typescript
withignoreMinAndMaxItems
.Are you willing to work on this yourself?
yes
The text was updated successfully, but these errors were encountered: