Skip to content

Exported variable ... has or is using name ... from external module ... but cannot be named #41934

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
ikibalnyi opened this issue Dec 11, 2020 · 2 comments
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.

Comments

@ikibalnyi
Copy link

ikibalnyi commented Dec 11, 2020

TypeScript Version: 4.1.2
Search Terms:
typescript declaration exported variable
typescript exported variable cannot be named
typescript error exported variable

Code:

// types.ts
export enum Enum {
  LOGIN = "login",
  REGISTER = "register"
}

export type MappWrapped = Partial<{
  [Enum.LOGIN]: null;
  [Enum.REGISTER]: null;
}>;
// foo.ts
import { Enum, MappWrapped } from "./routes";

// error happens, says:
// Exported variable 'Broken2' has or is using name 'Enum' from external module "types.ts" but cannot be named.
export const Broken2 = <R extends Enum>(props: Required<MappWrapped[R]>) => props;

Expected behavior:
Code should not fail with Exported variable ... has or is using name ... from external module ... but cannot be named

Actual behavior:
You use declaration: true or "composite": true.
If you make a file that's exporting a map wrapped in any helper function like Record, Partial etc. which is using enum values as keys.
And then use this type inside another file and wrap it in another similar helper (e.g. Record).
Code fails with Exported variable ... has or is using name ... from external module ... but cannot be named.

Playground Link: https://codesandbox.io/s/serene-andras-gsjqx?file=/src/index.ts

@ikibalnyi ikibalnyi changed the title False negative "Exported variable ... has or is using name ... from external module ... but cannot be named" Exported variable ... has or is using name ... from external module ... but cannot be named Dec 11, 2020
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Dec 11, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.2.1 milestone Dec 11, 2020
@weswigham
Copy link
Member

Dupe #40718 ?

@ikibalnyi
Copy link
Author

Yeah, looks same, the error code is different tho

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

3 participants