refactor: createScanAction.ts の api signature を ScanApi 型として export (#255)#256
Merged
Conversation
…t> 型として export (#255) `CreateScanActionOptions.api` field の inline thunked signature `() => (...args: TArgs) => Promise<TResult>` を named type alias `ScanApi<TArgs extends unknown[], TResult>` として切り出し export。 - 型の意図 (thunk 経由で実 API 関数を返す理由) を docstring 付きで明示 - 将来 scan 系 helper を増やした際の参照点を確保 - caller (`src/stores/backlink.ts` / `src/stores/wikilink.ts`) と test (`createScanAction.test.ts`) は generic 推論で互換、変更不要 Option A (最小変更、createScanAction.ts のみ) を採用。Option B (caller サイトでも `ScanApi` 注釈を強制) は `createScanAction<...>` の generic で既に型推論が機能するため冗長で skip。 PR #251 (createScanAction.test.ts の vi.fn() typing 統一) の /simplify pass 2 副産物として発見。 Refs #255
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.
概要
src/stores/createScanAction.tsのCreateScanActionOptions.apifield の inline thunked signature() => (...args: TArgs) => Promise<TResult>を named type aliasScanApi<TArgs extends unknown[], TResult>として切り出し export。型の意図 (thunk 経由で実 API 関数を返す理由) を docstring 付きで明示し、将来 scan 系 helper を増やした際の参照点を確保する。関連 Issue
Closes #255
移行 Stage
該当なし (Electron 移行完了後の internal refactor)
変更内容
src/stores/createScanAction.ts:ScanApi<TArgs extends unknown[], TResult>型 alias を追加 + export、CreateScanActionOptions.apifield の型を inline 形式からScanApi<TArgs, TResult>に置換ScanApi型 alias 側に移動 (型自身の意味を説明する役割が適切)src/stores/backlink.ts/src/stores/wikilink.ts) と test (src/stores/createScanAction.test.ts) はcreateScanAction<TState, TArgs, TResult>(...)の generic 推論で互換、変更なしOption B (caller サイトでも
ScanApi注釈を強制) は generic 型推論で既に defect-detection が機能するため冗長と判断、Option A (最小変更) を採用。PR #251 (createScanAction.test.ts の vi.fn() typing 統一) の
/simplifypass 2 副産物として発見。動作確認
node_modules/.bin/biome check src/stores/createScanAction.tscleannode_modules/.bin/tsc --noEmit -p tsconfig.web.jsoncleannode_modules/.bin/tsc --noEmit -p tsconfig.node.jsoncleannode_modules/.bin/tsc --noEmit -p tsconfig.e2e.jsoncleannode_modules/.bin/vitest run— 98 files / 2230 pass / 2 skipped/code-review low: (none) — type-level pure change、runtime correctness bug 該当なし/simplifypass 1 (4 reviewer 並列): 全 (none) — Reuse / Simp / Eff / Alt 全て採用なしスクリーンショット
UI 変更なし