Incorrect type inference when passing union type to a method or indexer #7274
Labels
Bug
A bug in TypeScript
Domain: Literal Types
Unit types including string literal types, numeric literal types, Boolean literals, null, undefined
Duplicate
An existing issue was already created
Not sure if this is a bug or just a feature that has not been implemented (yet), but given the following:
I would expect the return type of
Foo
to benumber | boolean
instead ofany
. I see the same issue with function overloads:Note that his behavior is not limited to string literals; it also happens when overloading on type:
This is with typescript 1.8.2
The text was updated successfully, but these errors were encountered: