microsoft / microsoft/TypeScript
Return statement in iterator is not type checked
Open
@rbuckton is already working on this.
Since Mar 4, 2019.
Needs Investigation
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 5.3.2.
Search Terms: yield, return, iterator.
Code:
interface Result {
foo: number;
}
function* gen(): IterableIterator<Result> {
yield { foo: 1 };
return { garbage: true }; // not checked
}
(function go(iterator) {
const { value, done } = iterator.next();
console.log(value);
if (!done) {
go(iterator);
}
})(gen());
Expected behavior: type error on return statement.
Actual behavior: no type errors.
Related Issues: https://github.com/Microsoft/TypeScript/issues/26959.
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.
Assessment
This issue has not been assessed yet.