diff --git a/CHANGELOG.md b/CHANGELOG.md index 19762b6f83..46e12ba06d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/jscomp/gentype/TranslateTypeExprFromTypes.ml b/jscomp/gentype/TranslateTypeExprFromTypes.ml index 5e526708ab..a8793542b9 100644 --- a/jscomp/gentype/TranslateTypeExprFromTypes.ml +++ b/jscomp/gentype/TranslateTypeExprFromTypes.ml @@ -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_ = diff --git a/jscomp/gentype_tests/typescript-react-example/package-lock.json b/jscomp/gentype_tests/typescript-react-example/package-lock.json index 479c7a4e0b..a276c375bf 100644 --- a/jscomp/gentype_tests/typescript-react-example/package-lock.json +++ b/jscomp/gentype_tests/typescript-react-example/package-lock.json @@ -8,7 +8,7 @@ "name": "typescript-react-example", "version": "0.1.0", "dependencies": { - "@rescript/react": "^0.12.0", + "@rescript/react": "^0.12.2", "react": "^18.2.0", "react-dom": "^18.2.0" }, @@ -206,9 +206,9 @@ } }, "node_modules/@rescript/react": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/@rescript/react/-/react-0.12.0.tgz", - "integrity": "sha512-EBLsf5rD7sJOjgfLLGwuLw/hONszc3UtYnIVgv7OdTyUNR41/m4deVm62PI0agvr3kWakXz4KchKRSd+19/bRA==", + "version": "0.12.2", + "resolved": "https://registry.npmjs.org/@rescript/react/-/react-0.12.2.tgz", + "integrity": "sha512-EOF19dLTG4Y9K59JqMjG5yfvIsrMZqfxGC2J/oe9gGgrMiUrzZh3KH9khTcR1Z3Ih0lRViSh0/iYnJz20gGoag==", "peerDependencies": { "react": ">=18.0.0", "react-dom": ">=18.0.0" diff --git a/jscomp/gentype_tests/typescript-react-example/package.json b/jscomp/gentype_tests/typescript-react-example/package.json index 1004c4a557..2e24046cf4 100644 --- a/jscomp/gentype_tests/typescript-react-example/package.json +++ b/jscomp/gentype_tests/typescript-react-example/package.json @@ -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" }, diff --git a/jscomp/gentype_tests/typescript-react-example/rescript.json b/jscomp/gentype_tests/typescript-react-example/rescript.json index 1fbab8ac5a..bc4baeebd3 100644 --- a/jscomp/gentype_tests/typescript-react-example/rescript.json +++ b/jscomp/gentype_tests/typescript-react-example/rescript.json @@ -24,7 +24,7 @@ "subdirs": true } ], - "uncurried": false, + "uncurried": true, "package-specs": { "module": "esmodule", "in-source": true diff --git a/jscomp/gentype_tests/typescript-react-example/src/CreateErrorHandler1.res.js b/jscomp/gentype_tests/typescript-react-example/src/CreateErrorHandler1.res.js index 3ab09d2586..3650a8a9b3 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/CreateErrorHandler1.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/CreateErrorHandler1.res.js @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Curry from "rescript/lib/es6/curry.js"; import * as ErrorHandler from "./ErrorHandler.res.js"; function notification(s) { @@ -16,7 +15,7 @@ let Error1 = { let MyErrorHandler = ErrorHandler.Make(Error1); -Curry._1(MyErrorHandler.notify, "abc"); +MyErrorHandler.notify("abc"); export { Error1, diff --git a/jscomp/gentype_tests/typescript-react-example/src/Docstrings.res.js b/jscomp/gentype_tests/typescript-react-example/src/Docstrings.res.js index b8306b2910..0aa8d157e7 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Docstrings.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Docstrings.res.js @@ -57,7 +57,7 @@ function grouped(x, y, a, b, c, z) { return ((((x + y | 0) + a | 0) + b | 0) + c | 0) + z | 0; } -function unitArgWithoutConversion(param) { +function unitArgWithoutConversion() { return "abc"; } @@ -65,7 +65,7 @@ function unitArgWithoutConversionU() { return "abc"; } -function unitArgWithConversion(param) { +function unitArgWithConversion() { return "A"; } diff --git a/jscomp/gentype_tests/typescript-react-example/src/ErrorHandler.res.js b/jscomp/gentype_tests/typescript-react-example/src/ErrorHandler.res.js index 78be0122f9..447f327d1d 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ErrorHandler.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/ErrorHandler.res.js @@ -1,10 +1,9 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Curry from "rescript/lib/es6/curry.js"; function Make($$Error) { let notify = function (x) { - return Curry._1($$Error.notification, x); + return $$Error.notification(x); }; return { notify: notify diff --git a/jscomp/gentype_tests/typescript-react-example/src/Hooks.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Hooks.gen.tsx index 39f83f9fdc..fbcc6f2105 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Hooks.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Hooks.gen.tsx @@ -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 = { readonly p: [vehicle, T1] }; @@ -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; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Hooks.res b/jscomp/gentype_tests/typescript-react-example/src/Hooks.res index bce9f6c9fc..ee7569adf3 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Hooks.res +++ b/jscomp/gentype_tests/typescript-react-example/src/Hooks.res @@ -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) =>
{React.string(r.x)}
) } diff --git a/jscomp/gentype_tests/typescript-react-example/src/Hooks.res.js b/jscomp/gentype_tests/typescript-react-example/src/Hooks.res.js index 15fa6d069c..48388edd95 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Hooks.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Hooks.res.js @@ -1,22 +1,21 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Curry from "rescript/lib/es6/curry.js"; import * as React from "react"; import * as ImportHooks from "./ImportHooks.res.js"; import * as ImportHookDefault from "./ImportHookDefault.res.js"; function Hooks(Props) { let vehicle = Props.vehicle; - let match = React.useState(function (param) { + let match = React.useState(function () { return 0; }); let setCount = match[1]; let count = match[0]; return React.createElement("div", undefined, React.createElement("p", undefined, "Hooks example " + (vehicle.name + (" clicked " + (String(count) + " times")))), React.createElement("button", { onClick: (function (param) { - Curry._1(setCount, (function (param) { + setCount(function (param) { return count + 1 | 0; - })); + }); }) }, "Click me"), React.createElement(ImportHooks.make, { person: { @@ -42,7 +41,7 @@ function Hooks(Props) { function Hooks$Another$anotherComponent(Props) { let vehicle = Props.vehicle; let callback = Props.callback; - Curry._1(callback, undefined); + callback(); return React.createElement("div", undefined, "Another Hook " + vehicle.name); } @@ -98,7 +97,7 @@ let NoProps = { }; function functionWithRenamedArgs(_to, _Type, cb) { - Curry._1(cb, _to); + cb(_to); return _to.name + _Type.name; } @@ -106,7 +105,7 @@ function Hooks$WithRename$componentWithRenamedArgs(Props) { let _to = Props._to; let _Type = Props._Type; let cb = Props.cb; - Curry._1(cb, _to); + cb(_to); return _to.name + _Type.name; } @@ -134,15 +133,14 @@ let WithRef = { makeWithRef: Hooks$WithRef$makeWithRef }; -let testForwardRef = React.forwardRef(function (param, param$1) { - return makeWithRef(param.vehicle)(param$1); +let testForwardRef = React.forwardRef(function (x, y) { + return makeWithRef(x.vehicle)(y); }); -let input = React.forwardRef(function (Props, param) { - let partial_arg = Props.r; +let input = React.forwardRef(function (r, ref) { return React.createElement("div", { - ref: param - }, partial_arg.x); + ref: ref + }, r.x); }); let ForwardRef = { @@ -168,7 +166,7 @@ let Fun = { function Hooks$RenderPropRequiresConversion(Props) { let renderVehicle = Props.renderVehicle; - return Curry._1(renderVehicle, { + return renderVehicle({ vehicle: { name: "Car" }, diff --git a/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res b/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res index a7f0432bba..21072a9ba1 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res +++ b/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res @@ -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 @@ -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 diff --git a/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res.js b/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res.js index 561b6f8896..8f0f909427 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res.js @@ -50,17 +50,29 @@ let rangeBy = Belt_Array.rangeBy; let makeByU = Belt_Array.makeByU; -let makeBy = Belt_Array.makeBy; +function makeBy(c, f) { + return Belt_Array.makeBy(c, (function (x) { + return f(x); + })); +} let makeByAndShuffleU = Belt_Array.makeByAndShuffleU; -let makeByAndShuffle = Belt_Array.makeByAndShuffle; +function makeByAndShuffle(c, f) { + return Belt_Array.makeByAndShuffle(c, (function (x) { + return f(x); + })); +} let zip = Belt_Array.zip; let zipByU = Belt_Array.zipByU; -let zipBy = Belt_Array.zipBy; +function zipBy(a1, a2, f) { + return Belt_Array.zipBy(a1, a2, (function (x, y) { + return f(x, y); + })); +} let unzip = Belt_Array.unzip; @@ -78,67 +90,131 @@ function copy(a) { let forEachU = Belt_Array.forEachU; -let forEach = Belt_Array.forEach; +function forEach(a, f) { + Belt_Array.forEach(a, (function (x) { + f(x); + })); +} let mapU = Belt_Array.mapU; -let map = Belt_Array.map; +function map(a, f) { + return Belt_Array.map(a, (function (x) { + return f(x); + })); +} let keepWithIndexU = Belt_Array.keepWithIndexU; -let keepWithIndex = Belt_Array.keepWithIndex; +function keepWithIndex(a, f) { + return Belt_Array.keepWithIndex(a, (function (x, y) { + return f(x, y); + })); +} let keepMapU = Belt_Array.keepMapU; -let keepMap = Belt_Array.keepMap; +function keepMap(a, f) { + return Belt_Array.keepMap(a, (function (x) { + return f(x); + })); +} let forEachWithIndexU = Belt_Array.forEachWithIndexU; -let forEachWithIndex = Belt_Array.forEachWithIndex; +function forEachWithIndex(a, f) { + Belt_Array.forEachWithIndex(a, (function (x, y) { + f(x, y); + })); +} let mapWithIndexU = Belt_Array.mapWithIndexU; -let mapWithIndex = Belt_Array.mapWithIndex; +function mapWithIndex(a, f) { + return Belt_Array.mapWithIndex(a, (function (x, y) { + return f(x, y); + })); +} let partitionU = Belt_Array.partitionU; -let partition = Belt_Array.partition; +function partition(a, f) { + return Belt_Array.partition(a, (function (x) { + return f(x); + })); +} let reduceU = Belt_Array.reduceU; -let reduce = Belt_Array.reduce; +function reduce(a, b, f) { + return Belt_Array.reduce(a, b, (function (x, y) { + return f(x, y); + })); +} let reduceReverseU = Belt_Array.reduceReverseU; -let reduceReverse = Belt_Array.reduceReverse; +function reduceReverse(a, b, f) { + return Belt_Array.reduceReverse(a, b, (function (x, y) { + return f(x, y); + })); +} let reduceReverse2U = Belt_Array.reduceReverse2U; -let reduceReverse2 = Belt_Array.reduceReverse2; +function reduceReverse2(a1, a2, c, f) { + return Belt_Array.reduceReverse2(a1, a2, c, (function (x, y, z) { + return f(x, y, z); + })); +} let someU = Belt_Array.someU; -let some = Belt_Array.some; +function some(a, f) { + return Belt_Array.some(a, (function (x) { + return f(x); + })); +} let everyU = Belt_Array.everyU; -let every = Belt_Array.every; +function every(a, f) { + return Belt_Array.every(a, (function (x) { + return f(x); + })); +} let every2U = Belt_Array.every2U; -let every2 = Belt_Array.every2; +function every2(a1, a2, f) { + return Belt_Array.every2(a1, a2, (function (x, y) { + return f(x, y); + })); +} let some2U = Belt_Array.some2U; -let some2 = Belt_Array.some2; +function some2(a1, a2, f) { + return Belt_Array.some2(a1, a2, (function (x, y) { + return f(x, y); + })); +} let cmpU = Belt_Array.cmpU; -let cmp = Belt_Array.cmp; +function cmp(a1, a2, f) { + return Belt_Array.cmp(a1, a2, (function (x, y) { + return f(x, y); + })); +} let eqU = Belt_Array.eqU; -let eq = Belt_Array.eq; +function eq(a1, a2, f) { + return Belt_Array.eq(a1, a2, (function (x, y) { + return f(x, y); + })); +} let $$Array$1 = { get: get diff --git a/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.res.js b/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.res.js index 008273bbc4..26d8c38aa9 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.res.js @@ -1,7 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -function makeVariant(param) { +function makeVariant() { return { TAG: "NonUnary", _0: 5, @@ -9,7 +9,7 @@ function makeVariant(param) { }; } -function makeABC(param) { +function makeABC() { return { TAG: "A", _0: { @@ -22,7 +22,7 @@ function makeABC(param) { }; } -function makeBC(param) { +function makeBC() { return { c: { TAG: "C", @@ -31,7 +31,7 @@ function makeBC(param) { }; } -function makeAC(param) { +function makeAC() { return { TAG: "A", _0: { @@ -42,7 +42,7 @@ function makeAC(param) { }; } -function makeAD(param) { +function makeAD() { return { TAG: "A", _0: { @@ -53,7 +53,7 @@ function makeAD(param) { }; } -function makeAE(param) { +function makeAE() { return { TAG: "A", _0: 3, @@ -61,7 +61,7 @@ function makeAE(param) { }; } -function makeFD(param) { +function makeFD() { return { TAG: "F", _0: { @@ -71,7 +71,7 @@ function makeFD(param) { }; } -function makeHD(param) { +function makeHD() { return { TAG: "H", _0: { @@ -82,7 +82,7 @@ function makeHD(param) { }; } -function makeJ(param) { +function makeJ() { return { TAG: "J", _0: { @@ -96,7 +96,7 @@ function makeJ(param) { }; } -function makeK(param) { +function makeK() { return { TAG: "K", _0: [ diff --git a/jscomp/gentype_tests/typescript-react-example/src/Shadow.res.js b/jscomp/gentype_tests/typescript-react-example/src/Shadow.res.js index 17539ddd9e..644dac7b01 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Shadow.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Shadow.res.js @@ -1,11 +1,11 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -function test(param) { +function test() { return "a"; } -function test$1(param) { +function test$1() { return "a"; } diff --git a/jscomp/gentype_tests/typescript-react-example/src/TestPromise.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/TestPromise.gen.tsx index 04f5f47e9f..3e7580c240 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/TestPromise.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/TestPromise.gen.tsx @@ -11,6 +11,6 @@ export type fromPayload = { readonly x: number; readonly s: string }; export type toPayload = { readonly result: string }; -export const convert: (_1:Promise) => Promise = TestPromiseJS.convert as any; +export const convert: (p:Promise) => Promise = TestPromiseJS.convert as any; export const barx: (x:(undefined | Promise<(undefined | string)>), _2:void) => boolean = TestPromiseJS.barx as any; diff --git a/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res b/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res index 6c05a608ee..80c84d3b48 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res +++ b/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res @@ -8,6 +8,6 @@ type fromPayload = { @genType type toPayload = {result: string} -@genType let convert = Js.Promise.then_(({s}) => Js.Promise.resolve({result: s})) +@genType let convert = p => Js.Promise.then_(({s}) => Js.Promise.resolve({result: s}), p) @genType let barx = (~x=Js.Promise.resolve(Some("a")), ()) => x == x diff --git a/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res.js b/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res.js index c9bc0047e8..7137896d8b 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res.js @@ -4,12 +4,12 @@ import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; import * as Js_promise from "rescript/lib/es6/js_promise.js"; import * as Caml_option from "rescript/lib/es6/caml_option.js"; -function convert(param) { +function convert(p) { return Js_promise.then_((function (param) { return Promise.resolve({ result: param.s }); - }), param); + }), p); } function barx(xOpt, param) { diff --git a/jscomp/gentype_tests/typescript-react-example/src/Uncurried.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Uncurried.gen.tsx index c9df733f62..69bc50070b 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Uncurried.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Uncurried.gen.tsx @@ -37,6 +37,6 @@ export const sumU: (n:number, m:number) => void = UncurriedJS.sumU as any; export const sumU2: (n:number) => (_1:number) => void = UncurriedJS.sumU2 as any; -export const sumCurried: (n:number, _2:number) => void = UncurriedJS.sumCurried as any; +export const sumCurried: (n:number) => (_1:number) => void = UncurriedJS.sumCurried as any; -export const sumLblCurried: (s:string, n:number, m:number) => void = UncurriedJS.sumLblCurried as any; +export const sumLblCurried: (s:string, n:number) => (m:number) => void = UncurriedJS.sumLblCurried as any; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res b/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res index 99b78fb6a7..f7bf1b94fa 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res +++ b/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res @@ -27,7 +27,7 @@ type authU = {loginU: (. unit) => string} @genType let sumU = (. n, m) => Js.log4("sumU 2nd arg", m, "result", n + m) -@genType let sumU2 = (. n, . m) => Js.log4("sumU2 2nd arg", m, "result", n + m) +@genType let sumU2 = (. n) => (. m) => Js.log4("sumU2 2nd arg", m, "result", n + m) @genType let sumCurried = n => { diff --git a/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res.js b/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res.js index 55c163c146..8420bac6b1 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res.js @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Curry from "rescript/lib/es6/curry.js"; function uncurried0() { return ""; @@ -23,11 +22,11 @@ function curried3(x, y, z) { } function callback(cb) { - return String(Curry._1(cb, undefined)); + return String(cb()); } function callback2(auth) { - return Curry._1(auth.login, undefined); + return auth.login(); } function callback2U(auth) { diff --git a/jscomp/gentype_tests/typescript-react-example/src/index.tsx b/jscomp/gentype_tests/typescript-react-example/src/index.tsx index eadf3cc8b9..5984d48e6b 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/index.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/index.tsx @@ -59,8 +59,8 @@ consoleLog( ); Uncurried.sumU(3, 4); Uncurried.sumU2(3)(4); -Uncurried.sumCurried(3, 4); -Uncurried.sumLblCurried("hello", 3, 4); +Uncurried.sumCurried(3)(4); +Uncurried.sumLblCurried("hello", 3)(4); ReactDOM.render(
diff --git a/jscomp/gentype_tests/typescript-react-example/src/nested/Types.res.js b/jscomp/gentype_tests/typescript-react-example/src/nested/Types.res.js index ecfa09bcab..f11c6c55cc 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/nested/Types.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/nested/Types.res.js @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as List from "rescript/lib/es6/list.js"; -import * as Curry from "rescript/lib/es6/curry.js"; import * as Belt_Option from "rescript/lib/es6/belt_Option.js"; function swap(tree) { @@ -21,7 +20,7 @@ function mutuallyRecursiveConverter(param) { } function testFunctionOnOptionsAsArgument(a, foo) { - return Curry._1(foo, a); + return foo(a); } function jsonStringify(prim) { @@ -58,7 +57,7 @@ function testInstantiateTypeParameter(x) { let currentTime = new Date(); -let optFunction = (function (param) { +let optFunction = (function () { return 3; });