Skip to content

Duplicate types are allowed (and ignored) if the first type is exported #36196

Closed

Description

TypeScript Version: 3.7.2

Search Terms: duplicate type identifier export ignored allowed

Code

export type A = 1;
type A = 2;
const x1: A = 1;

Expected behavior: I think this should not be allowed: I'm defining a duplicate type, the first of which is exported. Still, it's a duplicate.

Actual behavior: This is actually allowed, and the second definition is completely ignored. (Note that any other arrangement of export keywords cannot make the program correct, only this works.)

Playground Link: http://www.typescriptlang.org/play/#code/KYDwDg9gTgLgBDAnmYcCCcC8cCMBuAKCRXSzgCZCBjCAOwGd4QcAuU7fAoA

Related Issues: I did not find any.

(Sorry if this is a duplicate. It feels too simple to not be one, but I didn't find it.)

Activity

  1. andrewbranch commented on Jan 16, 2020

    @andrewbranch
    Member

    Notable that if you reverse the order of the exported one and the local one, you get an error 😳

  2. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions