vercel / style-guide

Vercel's engineering style guide
Mozilla Public License 2.0
1.25k stars 33 forks source link

Add multiple tsconfigs for different environments #60

Closed Ethan-Arrowood closed 10 months ago

Ethan-Arrowood commented 1 year ago

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

mrmckeb commented 1 year ago

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.

Ethan-Arrowood commented 1 year ago

Alright, take a look!

vercel-release-bot commented 10 months ago

:tada: This PR is included in version 5.2.0-canary.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

mwskwong commented 9 months ago

@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 commented 7 months ago

:tada: This PR is included in version 5.2.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: