Why React Native TypeScript config recommends to use a five years old standard (lib: es2017)?
Tags: reactnative, typescript, hermes, ios
Published: 2022-07-03 14:04:06

---
title: Why React Native TypeScript config recommends to use a five years old standard (lib: es2017)?
published: true
description: React Native JavaScript Engines everything that you need to know
tags: reactnative, typescript, hermes, ios
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/opajtj58ww10iwmlftuf.png

---


 

Have you ever read official guide of [using Typescript in React Native](https://reactnative.dev/docs/typescript). Did you mention something strange in `tsconfig.json` ?

`"lib": ["es2017"]` lib option looks weird, 5 year old standard recommended as default, isn't it?

If you wants to use some modern methods:

- `[].flat(...)`
- `[].flatMap(...)`
- `Object.fromEntries({  })`
- `'str'.trimEnd()`
...


Typescript will politely throw an error:

```tsx
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?

Actually no, everything depends on JavaScript engine that will run your code

By default React Native use:
- JSC ([JavaScriptCore](https://developer.apple.com/documentation/javascriptcore)) that build in iOS
- [`jsc-android`](https://github.com/react-native-community/jsc-android-buildscripts)

> Note: Also, include some [polyfills](https://reactnative.dev/docs/javascript-environment#polyfills) for many standard functions

> P.S. For me, that was a surprised that `Promise` is polyfilled too :(

For example, if you try to use [`Array.prototype.flat()`](https://developer.mozilla.org/pl/docs/Web/JavaScript/Reference/Global_Objects/Array/flat) your app will crash for users who using `iOS 11`. Yes this one reason why `es2017`

And iOS 11 is a minimal supported version by React Native (till `0.68.x`) 

> but starting from React Native `0.69.0` iOS `12.4` is minimal supported version (thanks Meta!)

---

Great thing that you haven't ever need to looking for information about JavaScript modern features and Engines that support them. 

Now it is easier to compare Typescript lib options \  JS features and JS Engines

[![react native compat table](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/opajtj58ww10iwmlftuf.png)](https://retyui.github.io/react-native-compat-table/)
 



---

![](https://ubunlog.com/wp-content/uploads/2019/07/Hermes.png)

Anyway, Meta also developing their own [Javascript Engine Hermes](https://hermesengine.dev/) that tried to align all new EcmaScript specifications

---

Even more, you can use V8 JavaScript Engine  

![](https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/V8_JavaScript_engine_logo_2.svg/128px-V8_JavaScript_engine_logo_2.svg.png)


[`react-native-v8`](https://github.com/Kudo/react-native-v8) has the greatest support for all modern JS features.

You can comprate all JavaScript Engines [compatibility table](https://retyui.github.io/react-native-compat-table/) and verify you tsconfig, if if it use a right lib option!

---

Useful links links:
- React Native [Typescript Config](https://www.npmjs.com/package/@tsconfig/react-native)
- ECMAScript 6 [compatibility table](https://retyui.github.io/react-native-compat-table/) for React Native engines
- [`react-native-v8`](https://github.com/Kudo/react-native-v8)
- [Hermes engine](https://hermesengine.dev/)
- [`jsc-android`](https://github.com/react-native-community/jsc-android-buildscripts)
- [Commit](https://github.com/facebook/react-native/commit/982ca30de079d7e80bd0b50365d58b9048fb628f) where minimal iOS version was bumped