Skip to content

Importing a type with same name as an export #31031

Closed
@mildsunrise

Description

@mildsunrise

TypeScript Version: 3.5.0-dev.20190419

Search Terms: import export conflict priority

Code

/// foo.ts
export interface Foo { a: number; }

/// test.ts
import { Foo } from './foo'
export interface Foo { b: number; }
let foo: Foo = { a: 2 }

Expected behavior: Declaration conflict on test.ts (imported Foo vs exported Foo).

Actual behavior: No error. Instead, (see last line) Foo refers to the imported Foo, and the exported Foo becomes unaccessible. Is this expected?

If export interface is changed to export class, then a declaration conflict appears.
If export is removed in initial case, a declaration conflict also appears.

Playground Link: I don't know how to reproduce this with one file.

Related Issues: I searched issues, stackoverflow and docs (declaration merging, imports and exports, namespaces) but couldn't find any references to this behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeBugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions