Repository navigation
test: fix the test type errors and typecheck tests in CI - #224
Merged
Merged
Conversation
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.
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.
Summary
tsc --noEmit -p tsconfig.jsonreported 71 errors in the specs. Nothing checked them, becausepnpm run typecheckonly coveredtsconfig.src.json, which excludes tests.Root cause for 49 of them:
tscresolvesobsidianto the real API, while Vitest aliases it totests/obsidian-stub.ts. Specs called the stub-onlynew TFile(path)constructor (the realTFilehas none) and read the stub-onlyNotice.messages.tests/obsidian-stub.tsexportscreateTFile(path), typed as the realobsidian.TFile. Specs use it instead ofnew TFile(path).kanbanHelper.test.tsimportsNoticefrom the stub, wheremessagesexists.uniqueQueue.test.tsimportstest/expectfromvitestlike every other spec (18 errors).menuFilter.test.ts,settingsMigration.test.ts, andkanbanHelper.test.ts.Keeping it fixed
typecheck:testsscript (tsc --noEmit -p tsconfig.json).typecheckruns it, sobuildand the CI Build + Lint job fail on a test type error. The CI step is renamed to say so.tsconfig.jsonnow also includesscripts/**/*.tsandvitest.e2e.config.mts. Both were clean.Verification
pnpm run typecheck:tests: 0 errors (was 71).const x: number = "a") makespnpm run buildexit 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 fromtypecheck/pnpm run build, with the CI step renamed to reflect that.tsconfig.jsonnow also typechecksscripts/**/*.tsandvitest.e2e.config.mts.Fixes ~71 spec errors from
tscresolving the realobsidiantypes (no publicTFileconstructor, no stubNotice.messages) while Vitest aliases the stub at runtime.tests/obsidian-stub.tsgainscreateTFile(); specs switch fromnew TFile(...)to that helper, pullNoticefrom the stub where needed, and useimport type { TFile }from obsidian. Small test-only typing tweaks inmenuFilter.test.ts,settingsMigration.test.ts, anduniqueQueue.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
typecheck:testsscript (tsc --noEmit -p tsconfig.json) and chains it into the existingtypecheckcommand. The CI build-lint step is relabeled to reflect this.vitest.e2e.config.mtsin the root TypeScript project via tsconfig.json.TFilebecomes a type-only import, and a sharedcreateTFilefactory in obsidian-stub.ts replaces direct stub construction in kanbanHelper.test.ts, parser.test.ts, and other test suites.pnpm run typechecknow also typechecks test files, so previously undetected type errors in tests will fail CI.Macroscope summarized 871a582.