-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript
Description
it would be nice to support that kind of construction :
function myFunction(arr: string | string[]) {
if (typeof arr === 'string') {
arr = [arr]
}
//arr is now string[]
}
It's a common pattern used by library that take options in parameter.
Generally you can pass an array of string or a string if you have a single value, and internally the library will create an array in any case.
decademoon and arosequist
Metadata
Metadata
Assignees
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript