Skip to content

Commit de36bde

Browse files
author
easonLiangWorldedtech
committed
fix(diff-view): type the discard-test doubles the way tsc reads them
The compile leg runs pnpm run check-types, which is tsc --noEmit over src, and it fails at d030e04 on the two test doubles the previous two commits added: the position double is built through vi.fn so its return type is not the Position the document slot asks for, and the deferred-scroll handle is declared ReturnType<typeof setTimeout> on the provider while this file resolves the global timer call to the other declaration. Both sit in the spec; no production line moves. tsc --noEmit exits 0 after this and the spec still runs 135 green. This lane had run eslint, prettier and vitest on the touched files but never the project typecheck, and vitest transpiles without typechecking, so the leg stayed unexercised locally until CI reported it.
1 parent d030e04 commit de36bde

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎src/integrations/editor/__tests__/DiffViewProvider.spec.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2809,7 +2809,7 @@ describe("DiffViewProvider", () => {
28092809
const document = makeTextDocument({
28102810
uri: makeUri(mockTargetPath),
28112811
getText: vi.fn().mockReturnValue("a\nCHANGED\nc\nd\n"),
2812-
positionAt: vi.fn((offset: number) => ({ line: 0, character: offset })),
2812+
positionAt: vi.fn((offset: number) => makePosition(0, offset)),
28132813
})
28142814
Object.assign(document, { isDirty: true })
28152815
const editor = makeTextEditor({ document, visibleRanges: [makeRange()], revealRange })
@@ -2884,8 +2884,12 @@ describe("DiffViewProvider", () => {
28842884
activeEditorListener: makeDisposable({ dispose: disposeActive }),
28852885
diffEditorSelectionListener: makeDisposable({ dispose: disposeSelection }),
28862886
diffScrollListener: makeDisposable({ dispose: disposeScroll }),
2887+
// The pending reveal is seeded here, next to the listeners, because the field is declared
2888+
// ReturnType<typeof setTimeout> on the provider while this file resolves the global timer call
2889+
// to the other declaration; assigning the same handle through bracket notation would need an
2890+
// assertion. Same handle, same fake clock, same late-reveal guard.
2891+
deferredScrollTimer: setTimeout(lateReveal, 300),
28872892
})
2888-
diffViewProvider["deferredScrollTimer"] = setTimeout(lateReveal, 300)
28892893
vi.mocked(fs.unlink).mockResolvedValue(undefined)
28902894
await diffViewProvider.discardUnapprovedStream()
28912895
expect(disposeActive).toHaveBeenCalledOnce()

0 commit comments

Comments
 (0)