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

Gentype support #138

Merged
merged 7 commits into from
Oct 23, 2024
Merged

Gentype support #138

merged 7 commits into from
Oct 23, 2024

Conversation

Bushuo
Copy link
Contributor

@Bushuo Bushuo commented Oct 21, 2024

This PR adds support for gentype to rewatch.
With the upcoming v11 compiler version it will then generate the appropriate .tsx files.

Fixes #102

@fhammerschmidt
Copy link
Member

Looks good! Would you just add a test for check_if_rescript11_or_higher since it got more complex?

Copy link
Member

@rolandpeelen rolandpeelen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing @Bushuo - Left a small suggestion regarding the unwraps and representation 🙌

@@ -157,6 +161,8 @@ pub struct Config {
pub namespace: Option<NamespaceConfig>,
pub jsx: Option<JsxSpecs>,
pub uncurried: Option<bool>,
#[serde(rename = "gentypeconfig")]
pub gentype_config: Option<GenTypeConfig>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably not have this as an empty struct, but rather just serde::Value - such that it represents some random piece of JSON which we don't care about. Right now it implies it's empty, rather than something we don't care about.

src/bsconfig.rs Outdated
Comment on lines 255 to 258
.unwrap()
.parse::<usize>()
.unwrap()
>= 11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this cuts it - I think you can do wildcards like: rescript: *, which I think would fail to parse, and that would throw in this case. To really check this, we should probably parse the output of the rescript -v. But, I'm ok to use this for the time being, albeit with some small changes:

  • Return Result<bool> here (probably my preference)
  • Default to false
  • Or write some heavy tests around this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we also hacked this in at some point. But perhaps, while we're touching it, maybe we just fix it up nicely 👌 - If I have some time today, I'll try and conjure up a version as a suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will go with the Result, then we can log an error at the call site and decide how to proceed.
In this case without uncurried mode.

@Bushuo
Copy link
Contributor Author

Bushuo commented Oct 22, 2024

Thanks for the reviews y'all. I will make adjustments later today.

Copy link
Member

@rolandpeelen rolandpeelen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, thanks for the update - left one small nit to be a bit more informative in the error, as I can imagine this would result into some weird behaviour if there is someone on < 11 with * - though I feel that's a very weird edge case

src/bsconfig.rs Outdated Show resolved Hide resolved
@rolandpeelen rolandpeelen merged commit 89a36b0 into rescript-lang:master Oct 23, 2024
1 check failed
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.

genType support
3 participants