ds300 / react-native-typescript-transformer

Seamlessly use TypeScript with React Native
MIT License
657 stars 55 forks source link

Support for the experimental syntax 'decorators-legacy' isn't currently enabled #81

Open andrey-shostik opened 5 years ago

andrey-shostik commented 5 years ago

I recently created app with typescript by this article, and I have error when trying to apply decorator to a method error screenshots: https://prnt.sc/l4nors, http://prntscr.com/l4np8r tsconfig: https://pastebin.com/UsczCQ70

super918180 commented 5 years ago

I got the same problem

andrey-shostik commented 5 years ago

@super918180 I fixed this issue with following steps:

But I'm not sure that it is right way.

CepheiSigma commented 5 years ago

if you are using latest rn,the rn-cli.config.js should be like this module.exports = { transformer: { babelTransformerPath: require.resolve('react-native-typescript-transformer'), }, }; you can follow the metro-bundler document https://facebook.github.io/metro/docs/en/configuration

eavam commented 5 years ago

if you are using latest rn,the rn-cli.config.js should be like this module.exports = { transformer: { babelTransformerPath: require.resolve('react-native-typescript-transformer'), }, }; you can follow the metro-bundler document https://facebook.github.io/metro/docs/en/configuration

It's work for me!

noer180895 commented 5 years ago

still bug decorators-legacy' isn't currently enabled

br4in3x commented 5 years ago

@andrey-shostik thanks! Could you please explain how your solution works?

tomusiaka2 commented 5 years ago

Installing these two plugins and updating babel.config.js seems to be working for me:

  "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy": true }],
    ["@babel/plugin-proposal-class-properties", { "loose" : true }]
  ]
Aseer07 commented 1 year ago

Error: Support for the experimental syntax 'decorators' isn't currently enabled Issue: I'm currently experiencing an issue with Babel when trying to use decorators in my JavaScript code. I've followed the official Babel documentation and created a .babelrc.json file with the necessary configuration, but I'm still getting the error

hers is .babelrc.json { "presets": ["@babel/preset-env", "@babel/preset-react"], "plugins": [ "@babel/plugin-transform-runtime", ["@babel/plugin-proposal-decorators", { "legacy": true }], ["@babel/plugin-proposal-class-properties"] ] } How to resolve this