TypeScript Version: 1.8, 2.0, and nightly
Code
The following code compiles even though it would appear that result should have type string:
function* myGenerator() {
yield "hello"
}
function* myOtherGenerator() {
const result = yield myGenerator()
result.methodNotAvailableOnString()
}
Expected behavior:
When a generator is yielded I expected that the type of the subsequent variable to be whatever T is in myGenerator's return type IterableIterator<T>
Actual behavior:
This is however not the case. result has type any. Should the TypeScript compiler be able to infer that that type of result should be string?
TypeScript Version: 1.8, 2.0, and nightly
Code
The following code compiles even though it would appear that
resultshould have typestring:Expected behavior:
When a generator is yielded I expected that the type of the subsequent variable to be whatever
Tis inmyGenerator's return typeIterableIterator<T>Actual behavior:
This is however not the case.
resulthas typeany. Should the TypeScript compiler be able to infer that that type ofresultshould bestring?