-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Open
Description
π Search Terms
generator tnext yield type
π Version & Regression Information
- This is the behavior in every version I tried between 5.0.4 ~ 6.0.2
β― Playground Link
π» Code
abstract class A {}
abstract class B {}
export function *f<a extends A, b extends B>(raw: Generator<a | b, never, number>): Generator<a | b, never, number> {
const x = raw.next().value;
if (x instanceof A) {} else throw new Error();
let output: a | b = x;
for (;;) {
const i = yield output;
output = raw.next(i).value;
}
}π Actual behavior
The type of i should be infered as number because the function signature is explicitly declared.
π Expected behavior
'i' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
Additional information about the issue
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels