Open KSXGitHub opened 5 years ago
Generator function that yields T but never return should return Generator<T, never, unknown>
T
Generator<T, never, unknown>
function * generator<T> (x: T) { while (true) yield x } const iter = generator(3) // expect: Generator<number, never, unknown>
My suggestion meets these guidelines:
https://github.com/microsoft/TypeScript/issues/11296#issuecomment-267094790
https://github.com/microsoft/TypeScript/issues/16608
https://github.com/microsoft/TypeScript/pull/8767
Appreciate the links @AnyhowStep but I don't think the motivation for hiding never return types in function declarations necessarily applies to generator functions.
never
@rbuckton thoughts?
Search Terms
Suggestion
Generator function that yields
T
but never return should returnGenerator<T, never, unknown>
Use Cases
Examples
Checklist
My suggestion meets these guidelines: