General question with focus on bindings
LukasMachetanz opened this issue · 2 comments
Hey!
I have a really general question which I need to ask providing an example.
Let's assume we add some kind of function with the typescript transformer. - function whatever() {}
And then I would like to use this function somewhere else, like whatever()
.
Should this work or would I have to consider something regarding bindings?
E.g. what's the point of adding import statements if the stuff imported can't be used. Or am I missing something here?
Thanks in advance.
heya
i've had use cases where i import functions and then use those functions after the transformation, so imagine importing extra functions that consumers don't actually use - the transformer just utilizes them so they're used in the final transformed code
honestly it works ok but there are a bunch of edge cases where this doesn't work well in TS transformers. with Babel they work as expected.
if you're compiling down to commonjs your bindings will be renamed but your callsites where you use the function wont be, so be careful for that. you'll need to do the renaming manually.
when targetting esmodules it should just work because no renaming is done.
Thanks for the answer. I explained my problem(s) a little bit more detailed here: nonara/ts-patch#27 (comment). It also includes a practical example I would like to solve. If you could help me to succeed I would really really appreciate it. Currently I am a little bit stuck how to proceed.