InterviewSolution
| 1. |
Are compile-to-JS libraries like TypeScript or ClojureScript compatible with React Native? Why or why not? |
|
Answer» As javascript is evolving, people have started ADDING benefits of strictly typed languages like JAVA, C++. Typescript is one such framework which adds some very good FEATURES in javascript. But since those features are not SUPPORTED by standard javascript yet, we would be needing tooling to convert the new concept in current concepts. That is done via using Babel in the build process. Languages that compile to JavaScript are generally compatible with React Native. React Native uses Babel to TRANSFORM JavaScript into a form that is consumable by the native OS’s JavaScript runtime, using the react-native Babel plugin. As long as Babel can compile your JavaScript, and your code does not rely on the web- or Node.js-specific dependencies, it will run in React Native. So we can use compile-to-js libraries with React native but we need to add steps in the build process to convert typescript to React Native’s JS runtime consumable code. |
|