Skip to content

RI-7720 Lock TS errors per project with .tscheck.rec.json baselines#5926

Open
KrumTy wants to merge 8 commits into
mainfrom
feature/tscheck-baselines
Open

RI-7720 Lock TS errors per project with .tscheck.rec.json baselines#5926
KrumTy wants to merge 8 commits into
mainfrom
feature/tscheck-baselines

Conversation

@KrumTy
Copy link
Copy Markdown
Contributor

@KrumTy KrumTy commented May 15, 2026

What

Adopt the per-file/per-error-code baseline pattern from redislabsdev/cloud-ui#1930. Current TS error counts are recorded in .tscheck.rec.json files per project; CI fails if any (file × error-code) count increases. Counts can only go down.

Scope: redisinsight/ui, redisinsight/api, redisinsight/desktop, configs. E2E Playwright is unchanged (already gated by the existing tests-e2e-playwright-lint.yml workflow).

Initial baselines:

Project Errors locked
UI 1837
API 4114 (with strict enabled, see below)
Desktop 512
Configs 0 (must stay clean)

API strict mode

Strict settings for the API:

"strict": true,
"strictPropertyInitialization": false,
"useUnknownInCatchVariables": false

Live in a new redisinsight/api/tsconfig.check.json that extends the base config. The base redisinsight/api/tsconfig.json is unchanged, so nest build is unaffected (enabling strict in the base broke the build with 939 errors — verified). The check tsconfig is only used by yarn type-check:api.

Local setup (run once)

For local yarn type-check to match CI, you need three installs done in this order:

yarn install                                # root deps
yarn --cwd redisinsight/api install         # api deps (regenerates api-client)
yarn --cwd redisinsight/api build           # builds api/dist with .d.ts so desktop can resolve types
yarn build:statics                          # installs ui plugin deps and builds plugin bundles

If you skip build:statics, the ui check will report extra TS7016 ("Could not find a declaration file for ...") errors because the plugins under redisinsight/ui/src/packages/* have their own deps in nested node_modules.

If you skip the api dev build, the desktop check will report TS2749 errors because desktop imports compiled api modules from redisinsight/api/dist/src/**.

Daily flow

Scenario Command
Run all checks locally yarn type-check
Run one project yarn type-check:{ui,api,desktop,configs}
You fixed errors → refresh the baseline yarn tscheck:{ui,api,desktop} and commit the updated .tscheck.rec.json
You introduced new errors Fix them. Don't use tscheck:*:force to paper over them
Force-overwrite (first-time bootstrap or intentional regression with team sign-off only) yarn tscheck:{ui,api,desktop}:force

CI runs the same checks via a new reusable workflow .github/workflows/type-check.yml, invoked from tests.yml with path-filtered inputs (skips ui check if no ui files changed, etc.). frontend-tests, backend-tests, and integration-tests now needs: [type-check, ...].

CI returns a clear message in both failure modes:

  • More errors than baseline: lists each new error with file, line, error code, and message
  • Baseline is outdated (you fixed errors but didn't refresh): tells you exactly which command to run

Reviewer red flags: .tscheck.rec.json counts going up without a corresponding code fix, or :force used in any commit.

Testing

  • yarn type-check passes locally (~25s end-to-end after setup)
  • Negative test: introduced a const x: number = 'string'yarn type-check:desktop exits 1 with file/line/error-code printed
  • Outdated-baseline test: bumped one baseline count → yarn type-check:desktop exits 1 with hint
  • yarn --cwd redisinsight/api build and yarn --cwd redisinsight/api build:prod still complete cleanly (strict only applies via tsconfig.check.json, not the base)
  • CI green

Docs:

🤖 Generated with Claude Code


Note

Medium Risk
Medium risk because it changes CI gating and build pipelines (new reusable workflow, new scripts, and strict-mode type-checking for API), which can cause unexpected PR failures or longer CI if misconfigured.

Overview
Adds a TypeScript error baseline system that records per-file/per-error-code TS error counts in .tscheck.rec.json for ui, api, and desktop, and fails CI if any count increases.

Introduces a new scripts/ts-error-check.ts comparator/overwriter plus workspace type-check/tscheck scripts, including an API-only tsconfig.check.json that enables strict (with select relaxations) without impacting nest build.

Updates CI to run a dedicated reusable type-check.yml (with UI plugin deps + API build pre-step for desktop) and makes frontend/backend/integration test jobs depend on it; also updates docs and ignores *.tsbuildinfo.

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

Adopt the per-file/per-error-code baseline pattern from redislabsdev/cloud-ui#1930
so TS error counts can only decrease. Wires a new type-check job into tests.yml
that gates PRs on UI, API, Desktop, and configs.

- scripts/ts-error-check.ts: port of cloud-ui's script, takes the rec-file path
  as an arg so checks run from repo root
- redisinsight/api/tsconfig.check.json: extends base with strict (minus
  strictPropertyInitialization and useUnknownInCatchVariables); keeps base
  tsconfig.json untouched so nest build is unaffected
- Baselines: ui=1848, api=4114 (strict), desktop=512, configs=0
- E2E is already covered by tests-e2e-playwright-lint.yml
- New type-check-baselines skill documents the dev workflow

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@KrumTy KrumTy added the AI-Made label May 15, 2026
@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented May 15, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

KrumTy and others added 3 commits May 15, 2026 13:13
The package provides its own type definitions, and the stub @types entry
caused yarn --frozen-lockfile to fail in CI because the lockfile didn't
include it.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Desktop sources import compiled api modules from redisinsight/api/dist/**.
Without building first, the desktop check reports 7 TS2307s for missing
modules that don't exist in CI's clean checkout. Run build:api conditional
on run-desktop so we don't pay the cost when only ui/api changed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
build:api runs build:prod which sets declaration: false. Without
declarations, desktop fails type-checking with TS2749s for value-used-as-type
on CloudAuthService and AzureAuthService imports from api/dist. The plain
nest build (default tsconfig.json) emits declarations.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

Code Coverage - Backend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 92.65% 15617/16855
🟡 Branches 74.72% 4907/6567
🟢 Functions 86.77% 2433/2804
🟢 Lines 92.49% 14926/16138

Test suite run success

3429 tests passing in 307 suites.

Report generated by 🧪jest coverage report action from 6740414

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

Code Coverage - Integration Tests

Status Category Percentage Covered / Total
🟡 Statements 79.51% 17533/22051
🟡 Branches 61.98% 8030/12954
🟡 Functions 68.04% 2430/3571
🟡 Lines 79.07% 16488/20851

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

Code Coverage - Frontend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 82.81% 24614/29722
🟡 Branches 68% 10332/15195
🟡 Functions 77.97% 6648/8526
🟢 Lines 83.28% 24036/28863

Test suite run success

6934 tests passing in 799 suites.

Report generated by 🧪jest coverage report action from 6740414

Comment thread scripts/ts-error-check.ts
@@ -0,0 +1,337 @@
import { diff } from 'deep-object-diff'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

custom "battle-tested" script ported from cloud-ui

KrumTy and others added 2 commits May 15, 2026 14:26
UI plugins under redisinsight/ui/src/packages/* are sub-projects whose
sources get type-checked through the UI tsconfig. Without their deps
installed, module resolution shifts (TS2307 vs TS7016 etc.) so local
results diverge from CI. Running build:statics before yarn type-check:ui
makes the baseline hermetic.

Cache the plugin node_modules keyed on the plugin yarn.locks to keep
warm-cache cost low.

Regenerated redisinsight/ui/.tscheck.rec.json with plugin deps installed:
1848 -> 1837 errors.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
UI: plugin deps must be installed (yarn build:statics) before
yarn type-check:ui matches CI.

Desktop: api/dist must be populated via the dev nest build (declaration
files needed), not build:prod.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@KrumTy KrumTy marked this pull request as ready for review May 15, 2026 12:02
@KrumTy KrumTy requested a review from a team as a code owner May 15, 2026 12:02
@KrumTy KrumTy changed the title Lock TS errors per project with .tscheck.rec.json baselines RI-7720 Lock TS errors per project with .tscheck.rec.json baselines May 15, 2026
valkirilov
valkirilov previously approved these changes May 15, 2026
Comment thread package.json Outdated
"test:cov:unit": "jest ./redisinsight/ui --group=-component --coverage -w 1",
"test:cov:component": "jest ./redisinsight/ui --group=component --coverage -w 1",
"type-check:ui": "tsc --project redisinsight/ui --noEmit",
"type-check": "yarn type-check:ui && yarn type-check:api && yarn type-check:desktop && yarn type-check:configs",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Another possible approach would be to move these into their respective workspace's package.json e.g.:

// <workspace_name>/package.json

"scripts": {
    "type-check": "...", 
}

and then, in your type-check.yml you can call them like

yarn workspace <workspace_name> type-check

This way your root package.json will stay lean.

Copy link
Copy Markdown
Contributor Author

@KrumTy KrumTy May 15, 2026

Choose a reason for hiding this comment

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

good suggestion, done, but I kept a single type-check root script for convenience

Replaces 11 type-check / tscheck scripts at the repo root with one
aggregate "type-check" and three matching scripts per workspace
(ui, api, desktop). Each workspace owns its own type-check, tscheck,
and tscheck:force.

Root package.json shrinks from 11 to 1 entry. CI workflow and the
type-check-baselines skill updated to call workspaces directly
(yarn --cwd redisinsight/<workspace> <task>).

Baselines regenerated with workspace-relative paths (totals
unchanged: ui=1837, api=4114, desktop=512).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
yarn 1.x without workspaces does not surface root binaries (tsc,
tsc-output-parser, tsx) to nested yarn --cwd invocations. CI calls
workspace scripts directly with no outer yarn, so the pipeline shells
fail with "tsc-output-parser: not found" / "tsx: not found".

Add the root .bin to GITHUB_PATH once after install so subsequent
workspace steps inherit it.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants