Closed
Description
Bug Report
π Search Terms
generator function union contextual typing yield
π Version & Regression Information
4.1.5, 4.4.2
- This changed between versions 4.0.5 and 4.1.5
β― Playground Link
Playground link with relevant code
π» Code
type FuncOrGeneratorFunc = () => (number | Generator<(arg: number) => void, any, void>)
const f: FuncOrGeneratorFunc = function*() {
// Error: Parameter 'num' implicitly has an 'any' type.
yield (num) => console.log(num);
}
π Actual behavior
A noImplicitAny error is reported.
Note: the same happens for async generator functions too.
π Expected behavior
Type of num
is inferred as number
. This is the behavior of TS 4.0.