Skip to content

chore(types): tighten types and replace TFile/TFolder casts (W1/9)#2403

Merged
logancyang merged 2 commits into
masterfrom
zeroliu/scorecard-types
May 12, 2026
Merged

chore(types): tighten types and replace TFile/TFolder casts (W1/9)#2403
logancyang merged 2 commits into
masterfrom
zeroliu/scorecard-types

Conversation

@zeroliu
Copy link
Copy Markdown
Collaborator

@zeroliu zeroliu commented May 12, 2026

Summary

Second of nine workspaces splitting #2397 (the 906-warning Obsidian scorecard fix). This PR is the TypeScript-only foundation: no runtime behavior changes.

  • Replace ~395 any annotations with specific types across LLM providers, chain runners, components, settings
  • Replace as TFile / as TFolder casts with instanceof narrowing in source files; tests use new mockTFile / mockTFolder helpers from src/__tests__/mockObsidian.ts
  • Remove ~44 unnecessary type assertions
  • Fix ~48 non-shared enum comparisons (cast provider to ChatModelProviders before comparing)
  • Remove any overrides in union types
  • __mocks__/obsidian.js re-exports real moment so test code stays type-safe

Builds on top of #2398 (W0 - deps bump). The remaining workspaces (W2-W9) will land progressively:

  • W2: floating promises + void-return mismatches
  • W3: window.setTimeout, globalThiswindow, atob/btoaBuffer.from
  • W4: documentactiveDocument/ownerDocument + popout listener fixes
  • W5: element.style.* → Tailwind classes
  • W6: LLM provider type tightening (Bedrock _getTypegetType)
  • W7: vault.deleteFileManager.trashFile + Projects App refactor
  • W8: Brevilabs multipart rewrite + scorecard docs
  • W9: Adopt eslint-plugin-obsidianmd

Test plan

  • npm run lint
  • npm run build (tsc + esbuild)
  • npm test (107 suites, 1962 tests pass)
  • No runtime behavior changes (TypeScript-only)

🤖 Generated with Claude Code

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f425da2121

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/utils/base64.ts
@zeroliu zeroliu force-pushed the zeroliu/scorecard-types branch from f425da2 to 5b61d52 Compare May 12, 2026 23:00
Second of nine workspaces splitting #2397. This PR is the
TypeScript-only foundation: no runtime behavior changes.

- Replace ~395 `any` annotations with specific types across
  LLM providers, chain runners, components, settings
- Replace `as TFile` / `as TFolder` casts with `instanceof` narrowing
  in source files; tests use new `mockTFile` / `mockTFolder` helpers
- Remove ~44 unnecessary type assertions
- Fix ~48 non-shared enum comparisons
- Remove `any` overrides in union types
- Add `src/__tests__/mockObsidian.ts` test helper
- `__mocks__/obsidian.js` re-exports real `moment`

No source-level runtime changes. `npm run lint`, `npm run build`,
and `npm test` (107 suites, 1962 tests) all pass.

Builds on top of #2398 (W0 - deps bump).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@zeroliu zeroliu force-pushed the zeroliu/scorecard-types branch from 5b61d52 to 5b066f5 Compare May 12, 2026 23:10
W1 should be types-only; this swap from `activeLeaf` to
`getMostRecentLeaf()` was a runtime behavior change snuck in.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants