Can't get `getType<T>()` to work
See original GitHub issueHello! Awesome project. Thank you!
I have a question, not sure if I am hitting a setup bug, but I am using tst-reflect through webpack and ttypescipt. I have this snippet:
interface IFoo {}
class Foo implements IFoo {}
const foo = new Foo();
getType<Foo>();
getType<typeof foo>();
getType<IFoo>();
I can see my source is instrumented with reflection data correctly, but these calls are all compiling to empty getType()
calls. Am I doing something wrong?
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
No TypeTag Available Exception when using case class to try ...
I finally found out what the issue was. The case classes must be defined top level - they cannot be nested. Something like...
Read more >Problem calling string parse + eval from C++ - Julia Discourse
when called from C++ using jl_call, I cannot get the output of “println(a)", the problem came from eval in previous line.
Read more >[Solved]-Get actual type of T in a generic List<T>-C#
I have an object which contains a List<T> for some type T . How do I retrieve the type T via reflection? Short...
Read more >Visitors' Frequently Asked Questions | Getty Center
Admission · Is it free to visit? · How do I make reservations? · I didn't get/can't find the confirmation email about my...
Read more >INF4140 - Models of concurrency - UiO
even on a single processor: use many processes, in order to get a natural partitioning ... Atomic operations on a variable cannot happen...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks so much for the detailed response. I also found https://ts-morph.com/ in the meantime that has worked with
tst-reflect
and doing in-memory compilation. Usingts-morph
is admittedly less confusing than the original compiler API.@3p3r
I played with it a little…
The issue is in transpileModule inside typescript itself. It does not load declarations of modules etc. It only transpile given module.
getType<>()
calls were not recognized as our getType calls so we ignored them. Recognition is based on declaration.I did some changes, so every
getType<T>()
without declaration (typechecker returns error for such function), called exactly with one type argument, will be considered as our. Here is new demo.Included in
tst-reflect-transformer@0.12.5
.