You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While using the API & TypeChecker I have noticed strange behavior for boolean type in AST tree (see bellow). Is it correct? If so, is there a simple way how to reconstruct the original TypeScript code form AST with the boolean type instead of union type?
The actual behavior you're seeing is intended. There is no difference between boolean, false | true, and true | false, they're just different ways of referencing the exact same type. In fact, boolean is effectively just a predefined type alias for false | true.
Thanks for answer. A was afraid of it :) Actually, there is one way, but not ideal - it is .getText() of symbol which returns the text from the source file (parsed token).
TypeScript Version: 2.2.1
While using the API & TypeChecker I have noticed strange behavior for boolean type in AST tree (see bellow). Is it correct? If so, is there a simple way how to reconstruct the original TypeScript code form AST with the boolean type instead of union type?
Code
Code used in test file:
Code using API:
Expected behavior:
for boolean:
for: true | false
for: string | boolean
Actual behavior:
for: boolean (Incorrect)
for: true | false (Correct)
for: string | boolean (Incorrect)
The text was updated successfully, but these errors were encountered: