Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General question with focus on bindings #21

Open
LukasMachetanz opened this issue Jan 22, 2021 · 2 comments
Open

General question with focus on bindings #21

LukasMachetanz opened this issue Jan 22, 2021 · 2 comments

Comments

@LukasMachetanz
Copy link

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.

@itsdouges
Copy link
Owner

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.

@LukasMachetanz
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants