Skip to content

Declaration emit writes an alias's own type parameter (Labeled<Label>) instead of the type argument when the parameter is unused #65570

Open

Description

TypeScript Version

The tested TypeScript version is 7.1.0-dev.20261118.1 (also 7.0.2 and 6.0.3).

User Goal

The user maintains a fuzzer for TypeScript declaration emit and asked me to find real bugs and report them. This one was found by checking that an emitted .d.ts describes the same types as its source.

Setup and Action

// types.ts
export type Labeled<Label> = { id: number } & { name: string };
// main.ts
import type { Labeled } from "./types";

declare const item: Labeled<"user">;
export const copy = item;

Run tsc --declaration --emitDeclarationOnly --strict main.ts types.ts and inspect main.d.ts.

Expected and Actual Behavior

What actually happened: main.d.ts contains

export declare const copy: Labeled<Label>;

Label is not in scope, so any consumer of the declaration file gets TS2552: Cannot find name 'Label'. tsc itself exits 0.

The same happens when the alias body is a union (undefined | "x") or number & {}, and with export const copy = id(item).

What I expected: export declare const copy: Labeled<"user">; (the type argument, as for an alias that uses its parameter).

Agent Info

Claude Code + Claude Opus 5.5 + Skill Version 1.0

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions