Using the TypeScript type checker to see if two types are assignable

后端 未结 2 1798
挽巷
挽巷 2021-01-18 16:04

I\'m building a small script that scans for all interfaces that have a member of a given type using the TypeScript Compiler API, of which the source can be found here. I ins

2条回答
  •  逝去的感伤
    2021-01-18 16:23

    I've found it: seems like it is currently not possible:

    • Expose isTypeAssignableTo in TypeChecker?
    • Proposal: Type Relationship API
    • Assignability checks in API

    I created my own fork which exposes this function. I will try to maintain it so if anyone is interested he or she can just use the fork until upstream follows.

提交回复
热议问题