Skip to content

Commit

Permalink
Merge pull request #180 from cca-io/fix-int-enums
Browse files Browse the repository at this point in the history
Fix int enums
  • Loading branch information
fhammerschmidt authored Dec 9, 2021
2 parents c3b0bde + 22fc36b commit 583d4ba
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 78 deletions.
4 changes: 4 additions & 0 deletions documentation/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ title: Changelog
(_Tags are copied from
[babel](https://github.com/babel/babel/blob/master/CHANGELOG.md)_)

## 3.0.2

- :bug: Fixed the binding generator's handling of `int` enums.

## 3.0.1

- :house: Fixed outdated peer dependencies.
Expand Down
6 changes: 2 additions & 4 deletions documentation/docs/project-structure/union-values.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ type variant = [#elevation | #outlined]

## Numeric unions

A union consisting of only numbers will utilize the
[[@int]](https://rescript-lang.org/docs/manual/latest/bind-to-js-function#constrain-arguments-better)
directive. Therefore, numerical unions will accept a form of polymorphic variant
as well.
Numeric unions now work the same way as string only unions now and don't utilize
the `@int` directive anymore.

These don't happen often - currently the only place where this applies is in the
`Mui.Grid.res` component.
Expand Down
28 changes: 1 addition & 27 deletions examples/src/examples/ExampleSlider.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/src/examples/ExampleStylingTailwind.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 1 addition & 27 deletions examples/src/labExamples/ExampleToggleButton.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/rescript-material-ui-lab/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rescript-material-ui-lab",
"version": "3.0.1",
"version": "3.0.2",
"description": "This library provides ReScript bindings for material-ui-lab.",
"keywords": [
"rescript",
Expand Down
2 changes: 1 addition & 1 deletion public/rescript-material-ui-ppx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rescript-material-ui-ppx",
"version": "3.0.1",
"version": "3.0.2",
"repository": "https://github.com/cca-io/rescript-material-ui",
"private": false,
"homepage": "https://rescript-material-ui.cca.io/",
Expand Down
2 changes: 1 addition & 1 deletion public/rescript-material-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rescript-material-ui",
"version": "3.0.1",
"version": "3.0.2",
"description": "This library provides ReScript bindings for material-ui.",
"keywords": [
"rescript",
Expand Down
15 changes: 1 addition & 14 deletions public/rescript-material-ui/src/Grid.res
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,7 @@ external make: (
~lg: Lg.t=?,
~md: Md.t=?,
~sm: Sm.t=?,
~spacing: @int
[
| @as(0) #0
| @as(1) #1
| @as(2) #2
| @as(3) #3
| @as(4) #4
| @as(5) #5
| @as(6) #6
| @as(7) #7
| @as(8) #8
| @as(9) #9
| @as(10) #10
]=?,
~spacing: [#0 | #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 | #10]=?,
~wrap: wrap=?,
~xl: Xl.t=?,
~xs: Xs.t=?,
Expand Down
4 changes: 2 additions & 2 deletions tools/binding-generator/src/classes/property-parser/_enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ const factory = (propertyType: PropType$Enum) => {
.map((name, i) => `#${name}`)
.join(' | ')}];
`;
this._reasonType = `@int [${enumValuesReason
.map((name, i) => `@as(${this._enumValues[i]}) #${name}`)
this._reasonType = `[${enumValuesReason
.map((name) => `#${name}`)
.join(' | ')}]`;
break;
}
Expand Down

0 comments on commit 583d4ba

Please sign in to comment.