microsoft / microsoft/TypeScript

GeneratorFunction should not be newable

Open
#56,645 0 comments 1 reaction 1 assignee View on GitHub

@rbuckton is already working on this.

Since Dec 4, 2023.

Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

⚙ Compilation target

ES2015 ES2018

⚙ Library

generator asyncgenerator

Missing / Incorrect Definition

GeneratorFunction and AsyncGeneratorFunction (async function * () {}) should not be newable.

GeneratorFunction means function * () {} which is only callable, while GeneratorFunctionConstructor means function * () {}.constructor which is both callable and newable.

Sample Code
declare const gen: GeneratorFunction;
new gen;// there should cause a type error, but not
Documentation Link

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.