Skip to content

test: fix the test type errors and typecheck tests in CI - #224

Merged
chhoumann merged 1 commit into
masterfrom
test/typecheck-tests
Oct 24, 2026
Merged

chhoumann merged 1 commit into
masterfrom
test/typecheck-tests

Conversation

@chhoumann

@chhoumann chhoumann commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

tsc --noEmit -p tsconfig.json reported 71 errors in the specs. Nothing checked them, because pnpm run typecheck only covered tsconfig.src.json, which excludes tests.

Root cause for 49 of them: tsc resolves obsidian to the real API, while Vitest aliases it to tests/obsidian-stub.ts. Specs called the stub-only new TFile(path) constructor (the real TFile has none) and read the stub-only Notice.messages.

  • tests/obsidian-stub.ts exports createTFile(path), typed as the real obsidian.TFile. Specs use it instead of new TFile(path).
  • kanbanHelper.test.ts imports Notice from the stub, where messages exists.
  • uniqueQueue.test.ts imports test/expect from vitest like every other spec (18 errors).
  • Three one-off casts and literals fixed in menuFilter.test.ts, settingsMigration.test.ts, and kanbanHelper.test.ts.

Keeping it fixed

  • New typecheck:tests script (tsc --noEmit -p tsconfig.json). typecheck runs it, so build and the CI Build + Lint job fail on a test type error. The CI step is renamed to say so.
  • tsconfig.json now also includes scripts/**/*.ts and vitest.e2e.config.mts. Both were clean.

Verification

  • pnpm run typecheck:tests: 0 errors (was 71).
  • A deliberately broken spec (const x: number = "a") makes pnpm run build exit 2.
  • pnpm run lint, pnpm run build, pnpm run test (359 passed).

No runtime or release impact. Test and config changes only.


Note

Low Risk
Test and build/CI configuration only; no production code paths changed.

Overview
Adds test typechecking to CI by introducing typecheck:tests (tsc -p tsconfig.json) and running it from typecheck / pnpm run build, with the CI step renamed to reflect that. tsconfig.json now also typechecks scripts/**/*.ts and vitest.e2e.config.mts.

Fixes ~71 spec errors from tsc resolving the real obsidian types (no public TFile constructor, no stub Notice.messages) while Vitest aliases the stub at runtime. tests/obsidian-stub.ts gains createTFile(); specs switch from new TFile(...) to that helper, pull Notice from the stub where needed, and use import type { TFile } from obsidian. Small test-only typing tweaks in menuFilter.test.ts, settingsMigration.test.ts, and uniqueQueue.test.ts (explicit vitest imports).

No plugin runtime or release behavior changes.

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

Note

Fix test type errors and run test typecheck in CI

  • Adds a typecheck:tests script (tsc --noEmit -p tsconfig.json) and chains it into the existing typecheck command. The CI build-lint step is relabeled to reflect this.
  • Includes test files and vitest.e2e.config.mts in the root TypeScript project via tsconfig.json.
  • Fixes type errors across tests: TFile becomes a type-only import, and a shared createTFile factory in obsidian-stub.ts replaces direct stub construction in kanbanHelper.test.ts, parser.test.ts, and other test suites.
  • Cleans up smaller issues: removes unused row fields in menuFilter.test.ts and replaces an empty module marker with explicit Vitest imports in uniqueQueue.test.ts.
  • Behavioral Change: pnpm run typecheck now also typechecks test files, so previously undetected type errors in tests will fail CI.

Macroscope summarized 871a582.

tsc resolves "obsidian" to the real API while Vitest aliases it to the
stub, so specs that called the stub-only TFile constructor or
Notice.messages did not typecheck. Build files through a typed
createTFile helper and read Notice.messages from the stub directly.
uniqueQueue.test.ts now imports its globals from vitest.

pnpm run typecheck (and so build and CI) now also runs tsc over
tsconfig.json, which covers specs, the stub, the E2E suite, and scripts.
@chhoumann
chhoumann merged commit b54c8a5 into master Oct 24, 2026
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant