Skip to content

Importing a type with same name as an export #31031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mildsunrise opened this issue Apr 19, 2019 · 2 comments · Fixed by #31231
Closed

Importing a type with same name as an export #31031

mildsunrise opened this issue Apr 19, 2019 · 2 comments · Fixed by #31231
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript

Comments

@mildsunrise
Copy link

mildsunrise commented Apr 19, 2019

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.

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Apr 19, 2019
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Apr 19, 2019
@collin5
Copy link
Contributor

collin5 commented Apr 30, 2019

Hmm, I see. Will be taking a crack at this by end of the week.

@collin5
Copy link
Contributor

collin5 commented May 3, 2019

Raised a PR to attempt resolving this (#31231). One thing to note is that this was introduced by #7591 because of possible breakage from #7583. Not sure if this still holds though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants