-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Refactor TypeScript Build Configuration #37369
Comments
While working on this it became pretty clear that using a base config comes with some caveats. First I investigated creating a new Any relative paths are relative to the source TSConfig file. This means that a reference like My solution to this was to have a
The end result would be that we could have really robust base configuration featuring all of the relevant paths without worrying about maintenance burdens. The script could be ran on |
I also developed the following base {
"compilerOptions": {
/* Standardize ES2019 and ESM Usage */
"target": "es2019",
"module": "esnext",
"moduleResolution": "node",
/* Configured Type Checks */
"strict": true,
"skipLibCheck": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
/* Support JavaScript Transpilation */
"allowJs": true,
/* @wordpress/element Provides Our JSX Runtime */
"jsx": "react",
"jsxFactory": "createElement",
"jsxFragmentFactory": "Fragment",
/* Generate Types */
"declaration": true,
"declarationMap": true,
/* Support Single File Transpilation */
"isolatedModules": true,
/* Support JSON File Imports */
"resolveJsonModule": true,
/* Require Isolated Package Roots */
"typeRoots": []
},
"include": [
"**/src/**/*"
],
"exclude": [
"**/test/*",
"**/*.spec.*",
"**/*.test.*"
]
} The |
For my own reference just linking the issue discussing tsconfig behaviour here because I found it very surprising 😂 microsoft/TypeScript#29172 |
@ObliviousHarmony took your idea and added my own spin, keen to hear your thoughts: #37875 |
I don't agree with the approach suggested here:
|
Thanks for your feedback @samueljseay! This issue mostly came about when I started poking at removing CJS and ESM builds where they aren't necessary. Our TypeScript configuration ended up being a bit of an inconsistent mess, and as a result, it wasn't as easy to make those changes as it felt like it should be. The primary goal of this issue was to settle on a single consistent base configuration for all TypeScript projects. Right now we have Regardless of whether or not we do anything with the duplication caused by the |
@ObliviousHarmony yes fair points!
Is it possible you could you elaborate on this one? I just wasn't aware there were situations where it was broken 😃 |
Yes @samueljseay, this instance ended up causing some trouble during the contributor day. The While most (not all, actually!) of the packages inherit from To be honest, I don't particularly care about solving the relative path problem, but, we should come up with a single base
Honestly, you might be right about the value of a With that said, going that far might still be unnecessary. |
Thanks @ObliviousHarmony Maybe internal-build would be worth introducing at some point, but I think I agree that at least for now it's too far.
Yeah maybe, for the relative path problem we could just add the paths in each package that extends the base config for now? We can leave all path related options out of the shared config and just set them in the project's consuming the package? Its a bit repetitive, but, things I like:
|
Yep @samueljseay, I'm only talking about the shared configuration. The empty |
@ObliviousHarmony sounds great, thanks for the discussion to come to a solution there 🎉 |
Prerequisites (mark completed items with an [x]):
Issue Description:
In order to make our TypeScript configuration a bit easier to maintain, we should clean up and centralize our configuration. While this will ultimately have an impact on the
"target"
for various projects, they should still all remain compatible given our supported Node version. The goal of this task is to make appropriate use of"extends"
and centralize common configuration where possible.The text was updated successfully, but these errors were encountered: