Skip to content

Make gentype tests uncurried. #6866

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 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
- Remove old `.ml` tests. https://github.com/rescript-lang/rescript-compiler/pull/6847
- Make compiler libs ready for uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6861
- Make tests ready for uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6862

- Make gentype tests uncurried. https://github.com/rescript-lang/rescript-compiler/pull/6866
#### :nail_care: Polish

- Make the `--help` arg be prioritized in the CLI, so correctly prints help message and skip other commands. https://github.com/rescript-lang/rescript-compiler/pull/6667
Expand Down
2 changes: 1 addition & 1 deletion jscomp/gentype/TranslateTypeExprFromTypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env =
{param_translation with type_ = Array (param_translation.type_, Mutable)}
| ["ImmutableArray"; "t"], [param_translation] ->
{param_translation with type_ = Array (param_translation.type_, Immutable)}
| ["Pervasives"; "ref"], [param_translation] ->
| [("Pervasives" | "PervasivesU"); "ref"], [param_translation] ->
{
dependencies = param_translation.dependencies;
type_ =
Expand Down

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

2 changes: 1 addition & 1 deletion jscomp/gentype_tests/typescript-react-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "biome check src"
},
"dependencies": {
"@rescript/react": "^0.12.0",
"@rescript/react": "^0.12.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"subdirs": true
}
],
"uncurried": false,
"uncurried": true,
"package-specs": {
"module": "esmodule",
"in-source": true
Expand Down

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

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

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

10 changes: 4 additions & 6 deletions jscomp/gentype_tests/typescript-react-example/src/Hooks.gen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,13 @@ export const WithRename_componentWithRenamedArgs: React.ComponentType<{
readonly cb: cb
}> = HooksJS.WithRename.componentWithRenamedArgs as any;

export const WithRef_makeWithRef: (_1:{ readonly vehicle: vehicle }, _2:(null | undefined | any)) => JSX.Element = HooksJS.WithRef.makeWithRef as any;
export const WithRef_makeWithRef: (_1:{ readonly vehicle: vehicle }) => (_1:(null | undefined | any)) => JSX.Element = HooksJS.WithRef.makeWithRef as any;

export type testForwardRef_Props = { readonly vehicle: vehicle };

export const testForwardRef: React.ComponentType<{ readonly vehicle: vehicle }> = HooksJS.testForwardRef as any;

export type ForwardRef_input_Props = { readonly r: r };

export const ForwardRef_input: React.ComponentType<{ readonly r: r }> = HooksJS.ForwardRef.input as any;
export const ForwardRef_input: (_1:r) => JSX.Element = HooksJS.ForwardRef.input as any;

export type Poly_polymorphicComponent_Props<T1> = { readonly p: [vehicle, T1] };

Expand Down Expand Up @@ -130,11 +128,11 @@ export const WithRename: { componentWithRenamedArgs: React.ComponentType<{
readonly cb: cb
}> } = HooksJS.WithRename as any;

export const ForwardRef: { input: React.ComponentType<{ readonly r: r }> } = HooksJS.ForwardRef as any;
export const ForwardRef: { input: (_1:r) => JSX.Element } = HooksJS.ForwardRef as any;

export const Fun: { functionReturningReactElement: React.ComponentType<{ readonly name: string }> } = HooksJS.Fun as any;

export const WithRef: { makeWithRef: (_1:{ readonly vehicle: vehicle }, _2:(null | undefined | any)) => JSX.Element } = HooksJS.WithRef as any;
export const WithRef: { makeWithRef: (_1:{ readonly vehicle: vehicle }) => (_1:(null | undefined | any)) => JSX.Element } = HooksJS.WithRef as any;

export const WithChildren: { aComponentWithChildren: React.ComponentType<{ readonly children: React.ReactNode; readonly vehicle: vehicle }> } = HooksJS.WithChildren as any;

Expand Down
6 changes: 3 additions & 3 deletions jscomp/gentype_tests/typescript-react-example/src/Hooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ module WithRef = {
}
}

@genType let testForwardRef = React.forwardRef(WithRef.makeWithRef)
@genType let testForwardRef = React.forwardRef( (x,y) => WithRef.makeWithRef(x)(y))

type r = {x: string}

module ForwardRef = {
@genType @react.component
let input = React.forwardRef((~r, (), ref) =>
@genType
let input = React.forwardRef((r, ref) =>
<div ref={Obj.magic(ref)}> {React.string(r.x)} </div>
)
}
Expand Down
26 changes: 12 additions & 14 deletions jscomp/gentype_tests/typescript-react-example/src/Hooks.res.js

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

Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ module Array = {
let rangeBy = (x, y, ~step) => Array.rangeBy(x, y, ~step)->toT

let makeByU = (c, f) => Array.makeByU(c, f)->toT
let makeBy = (c, f) => Array.makeBy(c, f)->toT
let makeBy = (c, f) => Array.makeBy(c, x => f(x))->toT

let makeByAndShuffleU = (c, f) => Array.makeByAndShuffleU(c, f)->toT
let makeByAndShuffle = (c, f) => Array.makeByAndShuffle(c, f)->toT
let makeByAndShuffle = (c, f) => Array.makeByAndShuffle(c, x => f(x))->toT

let zip = (a1, a2) => Array.zip(fromT(a1), fromT(a2))->toTp

let zipByU = (a1, a2, f) => Array.zipByU(fromT(a1), fromT(a2), f)->toT
let zipBy = (a1, a2, f) => Array.zipBy(fromT(a1), fromT(a2), f)->toT
let zipBy = (a1, a2, f) => Array.zipBy(fromT(a1), fromT(a2), (x,y) => f(x, y))->toT

let unzip = a => Array.unzip(a->fromTp)->toT2

Expand All @@ -67,52 +67,52 @@ module Array = {
let copy = a => Array.copy(a->fromT)->toT

let forEachU = (a, f) => Array.forEachU(a->fromT, f)
let forEach = (a, f) => Array.forEach(a->fromT, f)
let forEach = (a, f) => Array.forEach(a->fromT, x => f(x))

let mapU = (a, f) => Array.mapU(a->fromT, f)->toT
let map = (a, f) => Array.map(a->fromT, f)->toT
let map = (a, f) => Array.map(a->fromT, x => f(x))->toT

let keepWithIndexU = (a, f) => Array.keepWithIndexU(a->fromT, f)->toT
let keepWithIndex = (a, f) => Array.keepWithIndex(a->fromT, f)->toT
let keepWithIndex = (a, f) => Array.keepWithIndex(a->fromT, (x,y) =>f(x,y))->toT

let keepMapU = (a, f) => Array.keepMapU(a->fromT, f)->toT
let keepMap = (a, f) => Array.keepMap(a->fromT, f)->toT
let keepMap = (a, f) => Array.keepMap(a->fromT, x => f(x))->toT

let forEachWithIndexU = (a, f) => Array.forEachWithIndexU(a->fromT, f)
let forEachWithIndex = (a, f) => Array.forEachWithIndex(a->fromT, f)
let forEachWithIndex = (a, f) => Array.forEachWithIndex(a->fromT, (x,y) => f(x,y))

let mapWithIndexU = (a, f) => Array.mapWithIndexU(a->fromT, f)->toT
let mapWithIndex = (a, f) => Array.mapWithIndex(a->fromT, f)->toT
let mapWithIndex = (a, f) => Array.mapWithIndex(a->fromT, (x,y) => f(x,y))->toT

let partitionU = (a, f) => Array.partitionU(a->fromT, f)->toT2
let partition = (a, f) => Array.partition(a->fromT, f)->toT2
let partition = (a, f) => Array.partition(a->fromT, x => f(x))->toT2

let reduceU = (a, b, f) => Array.reduceU(a->fromT, b, f)
let reduce = (a, b, f) => Array.reduce(a->fromT, b, f)
let reduce = (a, b, f) => Array.reduce(a->fromT, b, (x,y) => f(x,y))

let reduceReverseU = (a, b, f) => Array.reduceReverseU(a->fromT, b, f)
let reduceReverse = (a, b, f) => Array.reduceReverse(a->fromT, b, f)
let reduceReverse = (a, b, f) => Array.reduceReverse(a->fromT, b, (x,y) => f(x,y))

let reduceReverse2U = (a1, a2, c, f) => Array.reduceReverse2U(fromT(a1), fromT(a2), c, f)
let reduceReverse2 = (a1, a2, c, f) => Array.reduceReverse2(fromT(a1), fromT(a2), c, f)
let reduceReverse2 = (a1, a2, c, f) => Array.reduceReverse2(fromT(a1), fromT(a2), c, (x,y,z) => f(x,y,z))

let someU = (a, f) => Array.someU(a->fromT, f)
let some = (a, f) => Array.some(a->fromT, f)
let some = (a, f) => Array.some(a->fromT, x => f(x))

let everyU = (a, f) => Array.everyU(a->fromT, f)
let every = (a, f) => Array.every(a->fromT, f)
let every = (a, f) => Array.every(a->fromT, x => f(x))

let every2U = (a1, a2, f) => Array.every2U(fromT(a1), fromT(a2), f)
let every2 = (a1, a2, f) => Array.every2(fromT(a1), fromT(a2), f)
let every2 = (a1, a2, f) => Array.every2(fromT(a1), fromT(a2), (x,y) => f(x,y))

let some2U = (a1, a2, f) => Array.some2U(fromT(a1), fromT(a2), f)
let some2 = (a1, a2, f) => Array.some2(fromT(a1), fromT(a2), f)
let some2 = (a1, a2, f) => Array.some2(fromT(a1), fromT(a2), (x,y) => f(x,y))

let cmpU = (a1, a2, f) => Array.cmpU(fromT(a1), fromT(a2), f)
let cmp = (a1, a2, f) => Array.cmp(fromT(a1), fromT(a2), f)
let cmp = (a1, a2, f) => Array.cmp(fromT(a1), fromT(a2), (x,y) => f(x,y))

let eqU = (a1, a2, f) => Array.eqU(fromT(a1), fromT(a2), f)
let eq = (a1, a2, f) => Array.eq(fromT(a1), fromT(a2), f)
let eq = (a1, a2, f) => Array.eq(fromT(a1), fromT(a2), (x,y) => f(x,y))
}

include Array
Loading