Skip to content

Instantly share code, notes, and snippets.

@ShaMan123
Created March 5, 2019 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShaMan123/868601d3570444954586117db7ea336c to your computer and use it in GitHub Desktop.
Save ShaMan123/868601d3570444954586117db7ea336c to your computer and use it in GitHub Desktop.
config files for RN>0.57.4, including typescript (rn-cli.config.js, tsconfig.json)
module.exports = function (api) {
api.cache(true)
return {
//decoratorsBeforeExport
"presets": ["module:metro-react-native-babel-preset"],
"plugins": [
["module-resolver", {
"root": ["./src"],
"extensions": [".js", ".ts", ".tsx", ".ios.js", ".android.js"]
}],
"@babel/plugin-transform-runtime",
"@babel/plugin-transform-flow-strip-types",
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
//"@babel/plugin-transform-regenerator",
//"@babel/plugin-transform-async-to-generator",
//"@babel/plugin-transform-runtime"
],
//"sourceMaps": true,
"env": {
"production": {
"plugins": ["transform-remove-console"]
}
}
};
}
// https://github.com/facebook/react-native/issues/21475#issuecomment-432509636
module.exports = {
transformer: {
babelTransformerPath: require.resolve('react-native-typescript-transformer')
},
getSourceExts() {
return ["ts", "tsx"];
}
}
{
"compilerOptions": {
"outDir": "./transpiled",
"baseUrl": ".",
//"noEmitOnError": false,
"allowJs": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react-native",
"lib": [ "es6" ],
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"target": "esnext",
"types": [
"jest",
"lodash",
"react",
"react-native",
"react-test-renderer"
],
"paths": {}
},
"exclude": [ "node_modules", "**/deprecated/*", "**/deprecated/**/*" ]
}
@ShaMan123
Copy link
Author

you need to install dependencies:

"devDependencies": {
    "@babel/core": "^7.2.2",
    "@babel/plugin-proposal-class-properties": "^7.2.3",
    "@babel/plugin-proposal-decorators": "^7.2.3",
    "@babel/plugin-transform-runtime": "^7.2.0",
    "babel-plugin-module-resolver": "^3.1.3",
    "babel-plugin-transform-decorators-legacy": "^1.3.5",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "react-native-typescript-transformer": "^1.2.11",
    "typescript": "^3.3.3"
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment