react-native-typescript-transformer icon indicating copy to clipboard operation
react-native-typescript-transformer copied to clipboard

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

Open andrey-shostik opened this issue 5 years ago • 8 comments

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

andrey-shostik avatar Oct 11 '18 01:10 andrey-shostik

I got the same problem

super918180 avatar Oct 18 '18 02:10 super918180

@super918180 I fixed this issue with following steps:

  • Install @babel/plugin-proposal-decorators
  • Change .babelrc https://pastebin.com/QdddctRN

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

andrey-shostik avatar Oct 19 '18 01:10 andrey-shostik

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

CepheiSigma avatar Nov 26 '18 05:11 CepheiSigma

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!

eavam avatar Dec 23 '18 12:12 eavam

still bug decorators-legacy' isn't currently enabled

noer180895 avatar Jan 05 '19 03:01 noer180895

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

br4in3x avatar Feb 18 '19 22:02 br4in3x

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 }]
  ]

tomusiaka2 avatar Jun 03 '19 04:06 tomusiaka2