Skip to content

optional argument that don't need to be specified #50657

@jimmywarting

Description

@jimmywarting

Suggestion

Some stuff have become to strict... that it's becoming too annoying!

await new Promise(rs => {
  setTimeout(() => rs(), 1000)
})
Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce
a 'resolve' that can be called without arguments

it's not only that. new ArrayBuffer() and new Uint8Array() is also something that requires an argument but it's perfectly fine to omit it to represent a 0 length buffer in the cases where you need a empty placeholder

🔍 Search Terms

promise resolve

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

📃 Motivating Example

💻 Use Cases

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions