-
Notifications
You must be signed in to change notification settings - Fork 29
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
Usage question: Adding new import declarations #13
Comments
heya! currently there are issues (either a bug, oversight, or deliberate thing by the TypeScript team) when compiling down to common js and applying custom transformers - basically the imports don't get "bound" in the binding step and thus their usage areas don't get renamed... i got around this in Compiled by... hacks... I'm not sure if this is in the handbook TBH https://github.com/atlassian-labs/compiled-css-in-js/blob/master/packages/ts-transform/src/constants.tsx#L48 |
Hey. Thank you for the immediate answer. Do I understand it correctly that the provided link is already the solution to the described problem? If this is the case I definitely have to try it. I am curious if it will work. And btw why do you know such stuff? Unbelievable. :) |
It's a work around not really a solution 😅 - I found this by trial and error. There really isn't much information about this which is why I made the handbook in the first place. If you get this working want to contribute back and mention this workaround in the handbook? |
Ah; I see. ;) I will try it. Hopefully I get it to work without the need to consult you again. :) |
Sorry but I have to clarify the solution again. I think I understand the code snippet. But I do not understand in which "context" they are applying it.
Is this right? So in short: They are doing what I had in mind: it is necessary to add the "binding" manually, right? Just some questions if I got it correctly:
This is the part from the transformer:
Here I would have to add the So I would guess something like this:
I just wanted to clarify and check if I understood it correctly. In the best case you just have to give me a thumb up. Thanks. ;) |
I've gotten this reply from the TS team as to how we could work around the problem microsoft/TypeScript#38077 |
Hey!
Once again I would like first of all to say that I really appreciate this repository and the provided examples. E.g. the example regarding
Adding new import declarations
.Although I have a question regarding this topic. Let's assume I have the following class:
The builded file with my custom TypeScript Transformer in place looks like this:
I would like to add an import statement to provide the
Ttransformer
class. Therefore I adjusted my transformer to do so. The output looks now like this:I am really wondering if the resulting source code is correct. If I already import the class in the first place, like in this example...
...the ouptut looks like this:
The actual difference is shown here:
Ttransformer.isInTransformContext()
vs.
ttransformer_1.Ttransformer.isInTransformContext();
Do I have to make sure in my custom transformer that
ttransformer_1
get's added? I would have imagined that this happens automatically. As I said; I really like the provided example; but I am wondering how it would look like if you would try to use the actual import. Do you know what I mean?I appreciate any thoughts, ideas and explanation. Thanks in advance.
Greets, Lukas
The text was updated successfully, but these errors were encountered: