-
Notifications
You must be signed in to change notification settings - Fork 49
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
Compiler error using @key decorator #98
Comments
In theory, once the typescript outputs the javascript that babel will be processing, the decorators should be completely gone. Are you trying to use the decorators straight inside javascript? |
No, I use it in my typescript code. As I wrote, it is odd, since all decorators other than the @key create no problem at all. |
It appears that using decorators straight in babel has different support than Typescript, and reading the comments, they're actually a little mad that Typescript went ahead and implemented function parameter decorators: So I think you have to use Typescript to process the decorators, not babel, at this time. |
I see, thanks for info. You mean, I should remove the Babel decorator plugin in babel.config.js? Do I need a Typescript plugin then? Any additional info you can point me to? |
I'm not even sure what the right terminology is, but in most of our apps, we only use babel later in the build pipeline. Typescript compiles the decorators down into non-decorated ES5 or ES6 (depending on the project), and then babel runs some other cleanup on it from there. If you look at this TodoList sample app from the ReactXP repo, it shows using resub with a typescript app and a simplified version of the build pipeline that we use in our private projects: https://github.com/Microsoft/reactxp/tree/master/samples/TodoList |
Any update on this or on the best way to resolve the issue? None of the examples seem to use the @key function parameter decorator |
Several of the unit tests use @key. You can start with one of those build systems. |
UPDATE: I don't know your actual code, but I have the same problem.
should work. |
Very strange. We have @key working lots of places in our codebase:
|
Yeah I wasn't able to get |
@a-tarasyuk Have you tried using @key in any of your samples? I've never actually tried building with the create-rx-app since I always just copy an older project of mine and keep evolving my private stash of garbage. :) |
@deregtd no, I have not tried. I suppose that the problem with the |
I just ran into this problem with a personal project - using React Native with babel transpiling typescript. As @a-tarasyuk mentioned above, you need an additional plugin to add babel support. I had success with My plugin list looks like this:
|
I just put out a PR to add a note about babel to our README, this should help unblock consumers using babel. @thegalah, can you try this out? |
I tried adding
|
Opened a bug on babel-plugin-parameter-decorator |
Hi all, Nice to hear this plugin |
Thanks @WarnerHooh - this solves my issues. @thegalah - can you bump package version to 1.0.8 and try again? |
@berickson1 I've bumped the package version to 1.0.8 and I now get:
|
Hi @thegalah, Thanks for the feedback, I had a quick fix in |
This worked for me! Thanks for the great work! |
I have tested the simpler subscription examples successfully, and now I am trying autosubscriptions using the @key decorator, such as in your example:
Unfortunately, I get a compiler error:
It seems like Babel has a problem with the @key decorator being used within a function, and not with other decorators like @autosubscribe and @AutoSubscribeStore.
I've checked my babel.config.js and everything seems OK, using:
Did someone else come across this problem? Any recommendation on how to solve this?
The text was updated successfully, but these errors were encountered: