Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why the target is set to esnext and the lib to es6? #136

Closed
Hatko opened this issue May 26, 2020 · 4 comments
Closed

Why the target is set to esnext and the lib to es6? #136

Hatko opened this issue May 26, 2020 · 4 comments

Comments

@Hatko
Copy link

Hatko commented May 26, 2020

Question

In our team, we're trying to mimic the tsconfig you created. Did you have any reasoning behind setting these particular versions for target (esnext) and lib(es6)?

@radko93
Copy link
Collaborator

radko93 commented May 26, 2020

There is no much behind it, as this is only being used for type checking. Feel free to ask other questions if you have any.

@radko93 radko93 closed this as completed May 26, 2020
@Hatko
Copy link
Author

Hatko commented May 26, 2020

@radko93 I see 🙂

esnext provides more features, which are not necessarily available for es6 (flatMap on an array, for example). Moreover, as I understand, the compiler will make esnext version anyway, as it's specified for the target.
That's why I'm curious why they aren't both set to esnext.

If there is no difference, would it make sense to make it consistent?

@radko93
Copy link
Collaborator

radko93 commented May 26, 2020

I think it can be set to esnext, feel free to open a PR. It makes no difference because it's Metro bundler and babel that actually transpile the code.

@Hatko Hatko mentioned this issue May 26, 2020
@LinusU
Copy link
Member

LinusU commented May 26, 2020

The reason why target and lib is set to different is because Metro will use Babel to transpile the syntax, which is what target controls.

On the other hand, lib specifies which part of the standard library exists, which isn't handled by Babel.

e.g. "syntax": "esnext" will allow you to use async function and await, which Babel can transpile. On the other hand, "lib": "esnext" will allow you to use BigInt, which will then fail at runtime because BigInt isn't supported...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants