chore(typescript): scope typechecking to src and add it to CI - #4688
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue URL: internal
What is the current behavior?
tsconfig.jsonis three lines:{ "extends": "@docusaurus/tsconfig", "exclude": ["static/code/stackblitz/"] }Specifying
excludereplaces TypeScript's defaults, andnode_modulesis one of them. So TypeScript walksnode_modulesandbuild/, pulling in 995 project files and 2,039 in total. Nothing runstsc, so none of the 126 errors it reports have ever surfaced.97 of those 126 are inside
build/, which means the error count depends on whether you happen to have run a build. That scan is also load-bearing by accident: the real@theme/*types arrive only becausenode_modulesis being walked, not because anything asks for them.What is the new behavior?
npm run typecheckrunstsc --noEmitover 61 files at zero errors, and CI runs it.Config:
includescopes tosrcplusindex.d.ts, the only declaration for*.module.scss. This also restores the default excludes, which is the actual fix for the above.typesnames@docusaurus/module-type-aliasesand@docusaurus/theme-classicdeliberately. Without it the catch-alldeclare module '@theme/*'inindex.d.tswins and every swizzled component becomesany.baseUrlis redeclared. Docusaurus sets it, butextendsresolves it relative to the declaring file, so@site/*pointed insidenode_modules/@docusaurus/tsconfig.allowArbitraryExtensionsletsrelease-notes.d.json.tstype the generatedrelease-notes.json, so typechecking needs neither a build nor a GitHub token.Code:
ion-icon,docs-cardanddocs-cardsinsrc/declarations.d.tsDocsFrontMatterfor ourdemoUrlanddemoSourceUrlfront matter, intersected with Docusaurus'sDocFrontMatter@stencil/coreimport left over from a Stencil to React port@docusaurus/types, which@docusaurus/module-type-aliasesimports from in 12 places and which resolved only because npm hoists it out of@docusaurus/coreDoes this introduce a breaking change?
Other information
strictis not enabled. It surfaces 144 errors concentrated in four files, withPlayground/index.tsxalone at 60. That belongs in its own PR, and it is worth doing before Docusaurus v4, which requires TypeScript 6, wherestrictdefaults to on.TypeScript stays at 5.9.3, the newest 5.x. 6 and 7 are blocked by
@docusaurus/tsconfigsettingbaseUrl, which 6 deprecates and 7 removes outright. Docusaurus drops it in v4 (facebook/docusaurus#11915). TheignoreDeprecations: "6.0"escape hatch works, but it silences the whole deprecation class permanently, so it is not worth taking.Ejected theme components are checked rather than skipped. The three errors in
DocItem/Layoutcame from our own front matter fields, so the type lives beside it infrontMatter.interface.tsinstead of being invented inline. The change to the upstream copy is 3 lines, all inside existing// CUSTOM CODEmarkers. The other 8 ejected files needed nothing oncetypeswas set.