WordPress/gutenberg
View on GitHubTypescript - introduce new @wordpress/ts-config package for outside usage
Open
#48954 opened on Mar 9, 2023
Developer ExperienceGood First IssueNeeds Dev[Type] Enhancementnpm Packages
Description
What problem does this address?
Right now Gutenberg has ~30 @wordpress/*-packages which make use of the tsconfig.base.json by loading it via relative path:
{
"extends": "../../tsconfig.base.json",
}
While all other technologies used in wordpress/scripts are having it's own package, Typescript in Gutenberg is still not at a stage where it can be even re-used from other Plugin/Theme/Package-Developers.
For example we have own packages for:
@wordpress/babel-preset-default@wordpress/browserslist-config@wordpress/eslint-plugin@wordpress/jest-preset-default@wordpress/npm-package-json-lint-config@wordpress/postcss-plugins-preset@wordpress/prettier-config@wordpress/stylelint-config
What is your proposed solution?
I would suggest to introduce a new @wordpress/ts-config (or @wordpress/typescript-preset - naming is not consistent currently, it's either config, preset, default or plugin?!), which in first step contains the tsconfig.base.json.
This way we could achieve following:
- Update all Gutenberg packages to replace relative path packages: https://github.com/search?q=repo%3AWordPress%2Fgutenberg+tsconfig.base.json+language%3A%22JSON+with+Comments%22&type=code&l=JSON+with+Comments
- Allow external packages/plugins/themes to load this config via
package.jsonand extend it locally to share the same rules as Gutenberg. - Similar to the
@wordpress/eslint-pluginwe could also introduce later onrecommendedandstrictvariations.
tsconfig.json:
{
"extends": "@wordpress/ts-config/tsconfig.base.json",
}