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

Add multiple tsconfigs for different environments #60

Merged
merged 8 commits into from Nov 22, 2023
Merged

Conversation

Ethan-Arrowood
Copy link
Contributor

@Ethan-Arrowood Ethan-Arrowood commented Apr 20, 2023

Adds more tsconfigs.

Why do node20 and node20-esm use the same lib and target as node18?

The lib and target fields are the same because Node.js v18 implemented support for some ES2023 methods. And since TypeScript does not allow us to specify types for individual features (and rather sets of features such as ESNext.AsyncIterable) we must use ES2023 in the lib array for Node.js v18. Furthermore, once TypeScript releases a "target": "ES2023", then the Node.js v20 configuration will be updated to that (assuming Node.js v20 fully supports ES2023).

Closes #59

package.json Show resolved Hide resolved
Copy link
Contributor

@mrmckeb mrmckeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Ethan-Arrowood! We'll need to update the root README too.

I'll ask a few people to review these and compare to what we have in our internal repos.

typescript/tsconfig.web.json Outdated Show resolved Hide resolved
@mrmckeb
Copy link
Contributor

mrmckeb commented Sep 4, 2023

Hey @Ethan-Arrowood, I've run this by a few people and the feedback is that we should focus on the lib/target versions for TypeScript and Node.js. The other settings make assumptions about the build system, which can vary greatly between projects (even our own). Instead can make use of shared monorepo configs, as you pointed out that vercel/vercel does with @vercel-internals/tsconfig.

How would you feel about updating this PR to focus on Node versions instead? As an example:

Probably 16/18/20 would be enough for us, as we probably don't want to support anything older nor anything non-LTS.

Copy link

@orca-security-us orca-security-us bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca

@Ethan-Arrowood
Copy link
Contributor Author

Alright, take a look!

styfle
styfle previously approved these changes Sep 8, 2023
Copy link
Contributor

@mrmckeb mrmckeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, almost ready to go.

One question - is this a breaking change? I think it might be, as there's no longer a config at @vercel/style-guide/typescript if you're using tooling that doesn't support "exports" - CC @styfle for thoughts too.

typescript/tsconfig.node20.json Show resolved Hide resolved
typescript/tsconfig.node20.json Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@mrmckeb mrmckeb merged commit 3991e02 into canary Nov 22, 2023
6 checks passed
@mrmckeb mrmckeb deleted the tsconfigs branch November 22, 2023 02:43
@vercel-release-bot
Copy link
Collaborator

🎉 This PR is included in version 5.2.0-canary.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@mwskwong
Copy link
Contributor

mwskwong commented Dec 20, 2023

@Ethan-Arrowood @mrmckeb In https://github.com/vercel/style-guide/blob/canary/typescript/tsconfig.node20.json, according to the doc: https://www.typescriptlang.org/tsconfig#lib

es2023 is not a valid value for lib and target, and TS does complain about that when using this TS config. Maybe it should be changed to esnext for now? However, I imagine we need to keep monitoring the status and change it to es2023 once it is available, since esnext will target es2024 by that time.

@vercel-release-bot
Copy link
Collaborator

🎉 This PR is included in version 5.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Can we get a node.js specific typescript config?
5 participants