-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
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?
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug