Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Multiple definition of type name props when migriting to JSXv4 #654

Closed
Minnozz opened this issue Sep 24, 2022 · 10 comments · Fixed by #655
Closed

Multiple definition of type name props when migriting to JSXv4 #654

Minnozz opened this issue Sep 24, 2022 · 10 comments · Fixed by #655

Comments

@Minnozz
Copy link
Contributor

Minnozz commented Sep 24, 2022

I had my own type props = ... (unrelated to React props, just using that name). Migrating to JSXv4 caused the following error:

rescript: [30/31] src/SchemaEditor-LumiStoreEditor.cmj
FAILED: src/SchemaEditor-LumiStoreEditor.cmj

  We've found a bug for you!
  SchemaEditor

  Multiple definition of the type name props.
  Names must be unique in a given structure or signature.

FAILED: cannot make progress due to previous errors.

The error seems valid (I should rename my own type), but:

  • We may have to add this to the migration guide (JSXv4 claims the type name props)
  • The error has no source location, which also makes clicking it in VSCode display an error
@mununki
Copy link
Member

mununki commented Sep 24, 2022

Thank you for reporting. How about this error msg? What do you think?

image

@mununki
Copy link
Member

mununki commented Sep 24, 2022

Worth adding it into the spec doc.

@Minnozz
Copy link
Contributor Author

Minnozz commented Sep 24, 2022

Thank you for reporting. How about this error msg? What do you think?

Looks good. What happens when the user's type props is defined below make? Which one gets the error location? Pointing at make would be clearer than pointing at the user's definition.

@mununki
Copy link
Member

mununki commented Sep 24, 2022

Thank you for reporting. How about this error msg? What do you think?

Looks good. What happens when the user's type props is defined below make? Which one gets the error location? Pointing at make would be clearer than pointing at the user's definition.

I don’t have a good solution for that, literally it is correct that the duplicated following one should
be pointed.

@mununki
Copy link
Member

mununki commented Sep 24, 2022

Is it helpful semething like “… If it is inside of component, the type props could be defined already.”? What do you think?

@Minnozz
Copy link
Contributor Author

Minnozz commented Sep 24, 2022

Are multiple locations, or hints, supported? Other languages often say "Previous definition was here:"

@cristianoc
Copy link
Contributor

It's technically possible to annotate the props type definition so that error messages can special case it.
(And help the editor extension too).

As for multiple locations, that's a separate question. How about create another issue.

@mununki
Copy link
Member

mununki commented Sep 24, 2022

The comment deleted and relocated to rescript-lang/rescript#5695

@mununki
Copy link
Member

mununki commented Sep 24, 2022

rescript-lang/rescript#5695 for multiple locations issue

@cristianoc
Copy link
Contributor

The current PR seems a clear improvement, we can merge it.
Can be improved further separately.

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

Successfully merging a pull request may close this issue.

3 participants