Skip to content
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

Parsing error: Identifier 'xyz' has already been declared #123

Open
FezVrasta opened this issue Nov 13, 2020 · 3 comments
Open

Parsing error: Identifier 'xyz' has already been declared #123

FezVrasta opened this issue Nov 13, 2020 · 3 comments

Comments

@FezVrasta
Copy link

FezVrasta commented Nov 13, 2020

Hi, I was wondering how should I handle this kind of TypeScript annotations:

https://github.com/ianstormtaylor/slate/blob/main/packages/slate-react/src/plugin/react-editor.ts#L29-L34

export interface ReactEditor extends Editor {
  insertData: (data: DataTransfer) => void
  setFragmentData: (data: DataTransfer) => void
}

export const ReactEditor = {
  // etc...

Flowgen converts it to:

declare export type ReactEditor = {
    insertData: (data: DataTransfer) => void,
    setFragmentData: (data: DataTransfer) => void,
    ...
  } & Editor;

declare export var ReactEditor: {
  // etc...

but then Flow errors because:

Parsing error: Identifier 'ReactEditor' has already been declared

Any help would be appreciated.

@orta
Copy link
Collaborator

orta commented Nov 13, 2020

If flow doesn't support a type and a value having the same name, I don't think anything could be done here in a way that won't break the importing code realistically.

@FezVrasta
Copy link
Author

Could flowgen allow to prefix types to prevent these issues?

@orta
Copy link
Collaborator

orta commented Dec 7, 2020

Maybe as an option? Could work for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants