Skip to content

Get rid of @string/@int for polyvars #770

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

Merged
merged 1 commit into from
Oct 5, 2022
Merged

Get rid of @string/@int for polyvars #770

merged 1 commit into from
Oct 5, 2022

Conversation

cknitt
Copy link
Member

@cknitt cknitt commented Aug 18, 2022

Resurrected #767.
Merge for ReScript 10 release.

@cknitt cknitt added this to the 0.70 / rescript 10 milestone Aug 18, 2022
Copy link
Member

@MoOx MoOx left a comment

Choose a reason for hiding this comment

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

Awesome work !

Do you think we could do something in PlatformColor for Android ? (I can handle it, I just want your opinion on this inglorious code xD

@cknitt
Copy link
Member Author

cknitt commented Oct 5, 2022

I have never used the PlatformColor API myself. The current implementation looks a bit like "overkill". 🙂

Compare to TypeScript which just has this: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/16db88356a79c458dbe5d88d9706aadec1d20db5/types/react-native/index.d.ts#L6041

I don't quite understand why one can pass an array of color names, what is that used for?

@MoOx
Copy link
Member

MoOx commented Oct 5, 2022

Yeah that's clearly some copy paste here...
The idea is not to have string, but "known" strings that correspond to "registered" color names ( by the OS) or "unsafe" (created by the developer).

And why an array ? Because if you pass more than one string value to the PlatformColor function, it will treat the first value as the default and the rest as fallback depending on their availability (make more sense for "user" values, with system fallbacks).

I will update PlatformColor later then.

@MoOx MoOx merged commit 6495093 into main Oct 5, 2022
@MoOx MoOx deleted the simplify-polyvars branch October 5, 2022 13:25
@cknitt
Copy link
Member Author

cknitt commented Oct 5, 2022

@MoOx Ah, but if you can define a type now with #"@android:color/background_dark" etc. and no @as(...) anymore, then you can use @variadic, right? That should drastically simplify things.

MoOx added a commit that referenced this pull request Oct 5, 2022
* main:
  Use polymorphic variant for Platform.os (#771)
  Get rid of @string/@int for polyvars (#770)
@MoOx
Copy link
Member

MoOx commented Oct 6, 2022

Exactly.

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