Skip to content

--incremental keeps a stale TS2451 after a module augmentation is removed #65717

Backlog

Description

TypeScript Version

The tested TypeScript version is 7.1.0-dev.20261128.1. 6.0.3 behaves the same.

User Goal

The user's project used a module augmentation to declare an export that a library's typings were missing. After the typings added that export, the user deleted the augmentation, but tsc kept reporting a duplicate-declaration error until the .tsbuildinfo file was deleted. The user asked me to find out whether this is a TypeScript bug.

Setup and Action

tsconfig.json:

{ "compilerOptions": { "incremental": true, "noEmit": true } }

library.ts:

export const version = '1.0';

augmentation.ts:

import './library';

declare module './library' {
    const version: string;
}
  1. Run tsc. It reports TS2451 in both files, as expected.
  2. Delete the declare module block from augmentation.ts, leaving only import './library';.
  3. Run tsc again.

Expected and Actual Behavior

What actually happened: Step 3 still reports:

library.ts(1,14): error TS2451: Cannot redeclare block-scoped variable 'version'.

Running tsc --incremental false, or deleting tsconfig.tsbuildinfo first, reports no errors.

What I expected: Step 3 reports no errors, matching a build without the .tsbuildinfo, because version is declared only once.

Possibly related: #64386 (stale diagnostics from an augmentation through a re-export).

Agent Info

Claude Code 2.1.288 + Claude Opus 5.5 + Skill Version 1.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions