dsherret / ts-type-info

TypeScript AST and code generator [Deprecated]
MIT License
94 stars 8 forks source link

Type assignment checking? #201

Open MeirionHughes opened 8 years ago

MeirionHughes commented 8 years ago

Does this library have support for checking if one Type is assignable to another (via reflection)?

I've been looking through the main typescript code, and it seems all the checking code is hidden from the main library (checker.ts is marked internal). :/

dsherret commented 8 years ago

Sorry, it's not possible at the moment. There is an option to expose the nodes from the compiler (see Include tsNodes). Using that and the type checker you should be able to get the types and then check if one type is assignable to another... I'm not sure how to check if one type is assignable to another though because I've never looked into it.

Also, I've opened #202 to add a flag to include the compiler types... that way the types this library returns will have a property with the corresponding internal typescript compiler type on it so you don't manually have to get it from the nodes.