Different behavior between inline type and type alias #29677
Labels
Bug
A bug in TypeScript
Domain: Conditional Types
The issue relates to conditional types
Fixed
A PR has been merged for this issue
Milestone
TypeScript Version: 3.4.0-dev.20190131
I'm trying to find base types of some class properties. For example, for a given
X[]
, trying to findX
.I use same definition inline and as a type alias. Type alias has error whereas inline type works.
Search Terms: Type alias, different behavior, conditional
Code
Below is simplified version of the actual code. Generics
A1
andA2
in class methodwhereRelated
are equal, exceptA1
uses inline type andA2
uses a type alias.Expected behavior:
Either both
A1
andA2
work or both have errors.Actual behavior:
A1
works, butA2
has an error:... Type 'RelationFields[N][0]' is not assignable to type 'A'.
Playground Link: See here
Related Issues: #15973 seems similar, but I can not be sure. If this is an expected behavior, an advise how to use a type alias is appreciated.
Thanks,
The text was updated successfully, but these errors were encountered: