Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is typescript-transformer and custom rn-cli config needed for react-native ts?

I am following react native blog post about working with typescript: http://facebook.github.io/react-native/blog/2018/05/07/using-typescript-with-react-native

One thing I can't grasp is why we need https://github.com/ds300/react-native-typescript-transformer alongside custom rn-cli config?

To my understanding we can transpile ts to a folder like dist and include main App from there in our root level index.js file.

For this to work a simple script that launches typescript compiler alongside react native one will do the trick or am I missing something.

like image 264
Ilja Avatar asked Aug 03 '18 09:08

Ilja


1 Answers

React Native uses a module bundler called Metro, and the react-native-typescript-transformer plugin allows it to build your project's TypeScript files as part of the bundling process much like how you can use the Webpack plugin to transform TypeScript files as a part of its bundling process.

With both Metro and Webpack you pre-build your TypeScript files with tsc instead of using a bundler plugin if that's what you'd prefer - this is just an alternative to doing that.

like image 138
empyrical Avatar answered Oct 05 '22 12:10

empyrical