microsoft / microsoft/TypeScript
Generator prototype ignored
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.8.0-dev.20200107
Search Terms: generator, iterator, prototype, inherit
Code
function* gen() {
while (true) {
yield "something";
}
}
gen.prototype.test = () => {
console.log("OK");
};
gen().test();
Expected behavior: No errors
Actual behavior: Error TS2339: Property 'test' does not exist on type 'Generator<string, void, unknown>'
Playground Link: Provided
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided TypeScript Playground reproduction and compare the generator function's prototype type with the type returned by gen(). Trace how generator declarations and prototype members are represented by the type checker. Done means the example compiles without TS2339 while preserving correct generator and iterator typing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100