WordPress/gutenberg

Typescript - introduce new @wordpress/ts-config package for outside usage

Open

#48.954 aberto em 9 de mar. de 2023

Ver no GitHub
 (4 comments) (23 reactions) (0 assignees)JavaScript (3.893 forks)batch import
Developer ExperienceGood First IssueNeeds Dev[Type] Enhancementnpm Packages

Métricas do repositório

Stars
 (9.607 stars)
Métricas de merge de PR
 (Mesclagem média 12d 18h) (509 fundiu PRs em 30d)

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",
}

See also: https://github.com/search?q=repo%3AWordPress%2Fgutenberg+tsconfig.base.json+language%3A%22JSON+with+Comments%22&type=code&l=JSON+with+Comments

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:

  1. 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
  2. Allow external packages/plugins/themes to load this config via package.json and extend it locally to share the same rules as Gutenberg.
  3. Similar to the @wordpress/eslint-plugin we could also introduce later on recommended and strict variations.

tsconfig.json:

{
	"extends": "@wordpress/ts-config/tsconfig.base.json",
}

Links/Resources

Guia do colaborador