Have you ever read official guide of using Typescript in React Native. Did you mention something strange in
"lib": ["es2017"] lib option looks weird, 5 year old standard recommended as default, isn't it?
If you wants to use some modern methods:
Typescript will politely throw an error:
Object.fromEntries(...) // ^^^^^^^^^^ TS2550: Property 'fromEntries' does not exist on type 'ObjectConstructor'. // Do you need to change your target library? // Try changing the 'lib' compiler option to 'es2019' or later.
But, wait when I run this code on simulator iOS & Android I didn't get any runtime errors.
So, is it mean that documentation is outdated?
By default React Native use:
Note: Also, include some polyfills for many standard functions
P.S. For me, that was a surprised that
Promiseis polyfilled too :(
For example, if you try to use
Array.prototype.flat() your app will crash for users who using
iOS 11. Yes this one reason why
And iOS 11 is a minimal supported version by React Native (till
but starting from React Native
12.4is minimal supported version (thanks Meta!)
Now it is easier to compare Typescript lib options \ JS features and JS Engines
react-native-v8 has the greatest support for all modern JS features.
Useful links links: