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

Fix ignoring react component arguments when aliasing props type #7194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mununki
Copy link
Member

@mununki mununki commented Dec 5, 2024

module C = {
  type myProps = {
    x: string
  }
  
  @react.component(:myProps)
  let make = (~x: int) => React.string(x)
}

<C x="x" /> // This compiles and treats x as string, despite being declared as int

In the current implementation, when there's a type mismatch between the myProps type definition and the actual parameter type in the make function, the compiler silently uses the type from myProps, ignoring the type annotation in the make function. This can lead to unexpected behavior and confusion for developers.

@cristianoc
Copy link
Collaborator

Can you hold on this until this is merged: #7192
That's a complex PR and I'd try to avoid introducing issues on merge.

@cristianoc
Copy link
Collaborator

Something to check about this PR is whether it affects type inference. Not sure it does, but any change can be delicate.

@mununki
Copy link
Member Author

mununki commented Dec 5, 2024

Can you hold on this until this is merged: #7192 That's a complex PR and I'd try to avoid introducing issues on merge.

Sure!

@mununki mununki force-pushed the fix-alias-props-type branch from dece53f to bca7852 Compare December 5, 2024 12:30
@mununki mununki force-pushed the fix-alias-props-type branch from bca7852 to 3330d57 Compare December 6, 2024 01:47
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

Successfully merging this pull request may close these issues.

2 participants