template-lint icon indicating copy to clipboard operation
template-lint copied to clipboard

Support type assignment checking

Open MeirionHughes opened this issue 8 years ago • 4 comments

  • [ ] For known types, check that the access-chain target is assignable to the binding target.

Don't know how to do type assignment checking with the typescript library. ~~I don't really want to create a program object ( to get a type-checker object) unless absolutely necessary.~~ Creating a ts.Program is not so bad as you can make your own host (de facto file system) and do everything in memory

MeirionHughes avatar Oct 16 '16 18:10 MeirionHughes

This might help. http://blog.scottlogic.com/2015/01/20/typescript-compiler-api.html Looks like you can implement your own host then make a language service; that then might allow getting the Program and then onto the typechecker.

MeirionHughes avatar Oct 16 '16 18:10 MeirionHughes

I don't think TypeChecker will help. The "isTypeAssignableTo" stuff is all hidden away (checker.ts). Without making changes to typescript lib, I think workaround is to generate some source code that does the assignments and try to compile it to see if it complains.

MeirionHughes avatar Oct 18 '16 08:10 MeirionHughes

Have You asked help from TypeScript team/project? The need for the workaround seems very odd.

atsu85 avatar Oct 18 '16 13:10 atsu85

Not yet, got told off last time I asked a question on there. So far the question on SO on this doesn't have a (good) answer.

Update: I've asked on on the typescript project now https://github.com/Microsoft/TypeScript/issues/11728

Update: looking good to be added to typescript.

MeirionHughes avatar Oct 18 '16 13:10 MeirionHughes