Skip to content

Add lint:tsc package script#9652

Open
mcmire wants to merge 1 commit into
mainfrom
add-lint-tsc-2
Open

Add lint:tsc package script#9652
mcmire wants to merge 1 commit into
mainfrom
add-lint-tsc-2

Conversation

@mcmire

@mcmire mcmire commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Explanation

Currently, the monorepo is not being fully typechecked in CI. This is a problem because type errors have sneaked into test files, and the only way to see them is in an editor context (they are not always caught by Jest).

To fix this, this commit adds another category of tsconfig files (tsconfig.lint.json) which are like the development-only versions, except they emit type declarations to a temporary directory. This allows packages which have dependencies on other packages to resolve types correctly. These tsconfigs are linted by the lint:tsconfigs scripts. This commit also adds a lint:tsc package script which makes use of tsconfig.lint.json.

Note that if we were to run this across the monorepo we would have to address many type errors. To allow us to address these incrementally, this commit only enables linting for a subset of packages. We will increase this set in future PRs.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Changes are limited to tooling, CI, and TypeScript config; no runtime product code.

Overview
Adds repository-wide TypeScript typechecking in CI via a new lint:tsc script (tsc --build tsconfig.lint.json), wired into the root lint command and the lint workflow matrix.

Introduces a tsconfig.lint.json layer (root + shared tsconfig.packages.lint.json) that mirrors dev configs but emits declarations into .tsc-lint-cache/ so project references resolve across workspace packages. Only four packages are enabled initially (base-controller, messenger, messenger-cli, platform-api-docs) so the rest of the monorepo can opt in later.

Extends lint:tsconfigs to validate and fix references on tsconfig.lint.json separately from tsconfig.json / tsconfig.build.json, using workspaces that actually have a lint config. lint:dependencies now points knip at knip.config.mts explicitly; root tsconfig.json includes that file instead of knip.config.ts.

Reviewed by Cursor Bugbot for commit a50e40f. Bugbot is set up for automated code reviews on this repo. Configure here.

@@ -0,0 +1,12 @@
{
"extends": ["./tsconfig.json", "../../tsconfig.packages.lint.json"],

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These per-package config files work a bit differently than the per-package tsconfig.build.json files, because they extend two files rather than one. I chose to do this because these files are very similar to tsconfig.json in concept but they just need to be tweaked a little bit (whereas tsconfig.build.json is almost entirely different from tsconfig.json, so it only makes sense to extend tsconfig.packages.build.json).

@@ -44,7 +44,7 @@ describe('create-package/cli', () => {
beforeEach(() => {
// yargs calls process.exit() with 1 on failure and sometimes 0 on success.
// We have to intercept it.
jest.spyOn(process, 'exit').mockImplementation((code?: number) => {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing existing type error in this file, which only showed up in my editor.

Comment thread knip.config.mts

@mcmire mcmire Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In typechecking this file tsc told me that it interpreted knip as an ESM-only module but it interpreted this file as CommonJS. Renaming this file cleared the type error (although it did mean I had to update how we call knip in package.json, because knip won't look for knip.config.mts by default).

Comment thread tsconfig.lint.json
*/
"extends": "./tsconfig.json",
"compilerOptions": {
"skipLibCheck": true,

@mcmire mcmire Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't enable this setting in tsconfig.json or tsconfig.packages.json, however, I found it to be necessary in this case. We are getting a large number of errors from @types/node and I wasn't quite sure how to resolve them. I figured we could investigate that problem in a different PR.

Adding skipLibCheck isn't entirely without precedent: we enable this in tsconfig.build.json.

Currently, the monorepo is not being fully typechecked in CI. This is a
problem because type errors have sneaked into test files, and the only
way to see them is in an editor context.

To fix this, this commit adds another category of tsconfig files
(`tsconfig.lint.json`) which are like the development-only versions,
except they emit type declarations to a temporary directory. This allows
packages which have dependencies on other packages to resolve types
correctly. These tsconfigs are linted by the `lint:tsconfigs` scripts.
This commit also adds a `lint:tsc` package script which makes use of
`tsconfig.lint.json`.

Note that if we were to run this across the monorepo we would have to
address many type errors. To allow us to address these incrementally,
this commit only enables linting for a subset of packages.
@mcmire
mcmire marked this pull request as ready for review July 24, 2026 14:49
@mcmire
mcmire requested a review from a team as a code owner July 24, 2026 14:49
@mcmire
mcmire temporarily deployed to default-branch July 24, 2026 14:49 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant