Created
October 2, 2018 14:19
-
-
Save DimitryDushkin/bcf5a7f5df71113c67dbe2e890008308 to your computer and use it in GitHub Desktop.
React Native 0.57 + Babel 7 + Typescript + Jest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// babel.config.js | |
module.exports = { | |
"presets": [ | |
"module:metro-react-native-babel-preset", | |
], | |
"plugins": [ | |
["module-resolver", { | |
"root": ["./src"], | |
"extensions": [".js", ".ts", ".tsx", ".ios.js", ".android.js"] | |
}], | |
"@babel/plugin-transform-runtime", | |
], | |
"env": { | |
"production": { | |
"plugins": ["transform-remove-console"] | |
}, | |
} | |
} | |
// jest.config.js | |
module.exports = { | |
"preset": "react-native", | |
"moduleFileExtensions": [ | |
"ts", | |
"tsx", | |
"js", | |
"jsx", | |
"json" | |
], | |
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)x?$", | |
"transform": { | |
"^.+\\.(js|tsx?)$": "<rootDir>/node_modules/react-native/jest/preprocessor.js", | |
}, | |
"testPathIgnorePatterns": [ | |
"\\.snap$", | |
"<rootDir>/node_modules/" | |
], | |
"cacheDirectory": ".jest/cache", | |
"transformIgnorePatterns": [ | |
"node_modules/(?!(react-native|react-navigation|react-navigation-tabs|react-navigation-redux-helpers|react-native-safari-view|react-native-linear-gradient|react-native-blur|react-native-animatable|react-native-wkwebview-reborn|react-native-safe-area-view|react-native-popup-menu|redux-persist)/)" | |
], | |
"setupFiles": [ | |
"./__mocks__/react-native.js" | |
], | |
}; | |
// package.json | |
{ | |
"name": "rn-app", | |
"version": "0.0.1", | |
"private": true, | |
"dependencies": { | |
"react": "16.5.1", | |
"react-native": "^0.57.1" | |
}, | |
"devDependencies": { | |
"jest": "^23.6.0", | |
"metro-react-native-babel-preset": "^0.47.0", | |
"@babel/plugin-transform-runtime": "^7.1.0", | |
"babel-plugin-module-resolver": "^3.1.1", | |
"babel-plugin-transform-remove-console": "^6.9.4", | |
"react-native-mock-render": "^0.1.2", | |
"typescript": "^3.0.1" | |
} | |
} | |
FDiskas
commented
Jul 1, 2019
is this still up to date? I don't quite understand how to add typescript to my project, I don't have jest, do I need it? It isn't compiling after I add typescript...
Just Google it. https://reactnative.dev/docs/typescript
Just Google it. https://reactnative.dev/docs/typescript
I was following that guide and got stuck here, running into errors ... That's why I was checking if this is still up to date. Also do I need everything in this file? Jest?
Don't waste my and yours time. Use https://github.com/infinitered/ignite
Can anyone explain how this sits into Metro? I want to see my type / lint errors inside the metro terminal, just like how expo does it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment