From 86d7e46c2c66eb59ed2be418e6691938f666d3cb Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 25 Jul 2024 04:31:46 +0900 Subject: [PATCH 1/3] fix `JSBigInt` payload type --- jscomp/others/js_types.res | 7 ++----- jscomp/others/js_types.resi | 7 ++----- jscomp/test/typeof_test.js | 3 +++ jscomp/test/typeof_test.res | 4 +++- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/jscomp/others/js_types.res b/jscomp/others/js_types.res index 9048765d8d..7a385823b8 100644 --- a/jscomp/others/js_types.res +++ b/jscomp/others/js_types.res @@ -25,9 +25,6 @@ /** Js symbol type only available in ES6 */ type symbol -/** Js bigint type only available in ES2020 */ -type bigint_val = bigint - type obj_val /** This type has only one value `undefined` */ type undefined_val @@ -46,7 +43,7 @@ type rec t<_> = | Function: t | Object: t | Symbol: t - | BigInt: t + | BigInt: t type tagged_t = | JSFalse @@ -58,7 +55,7 @@ type tagged_t = | JSFunction(function_val) | JSObject(obj_val) | JSSymbol(symbol) - | JSBigInt(bigint_val) + | JSBigInt(bigint) let classify = (x: 'a): tagged_t => { let ty = Js.typeof(x) diff --git a/jscomp/others/js_types.resi b/jscomp/others/js_types.resi index f267cd2c79..a2faaf8afe 100644 --- a/jscomp/others/js_types.resi +++ b/jscomp/others/js_types.resi @@ -27,9 +27,6 @@ /** Js symbol type (only available in ES6) */ type symbol -/** Js bigint type only available in ES2020 */ -type bigint_val - type obj_val /** This type has only one value `undefined` */ @@ -49,7 +46,7 @@ type rec t<_> = | Function: t | Object: t | Symbol: t - | BigInt: t + | BigInt: t /** `test(value, t)` returns `true` if `value` is `typeof t`, otherwise `false`. @@ -75,6 +72,6 @@ type tagged_t = | JSFunction(function_val) | JSObject(obj_val) | JSSymbol(symbol) - | JSBigInt(bigint_val) + | JSBigInt(bigint) let classify: 'a => tagged_t diff --git a/jscomp/test/typeof_test.js b/jscomp/test/typeof_test.js index 0c3b24f510..e10187f05c 100644 --- a/jscomp/test/typeof_test.js +++ b/jscomp/test/typeof_test.js @@ -22,6 +22,9 @@ function string_or_number(x) { case "JSFunction" : console.log("Function"); return false; + case "JSBigInt" : + console.log(ty._0.toString()); + return true; default: return false; } diff --git a/jscomp/test/typeof_test.res b/jscomp/test/typeof_test.res index 29119c26ed..22fb866330 100644 --- a/jscomp/test/typeof_test.res +++ b/jscomp/test/typeof_test.res @@ -15,7 +15,9 @@ let string_or_number = (type t, x) => { false | JSObject(_) => false | JSSymbol(_) => false - | JSBigInt(_) => false + | JSBigInt(v) => + v->Js.BigInt.toString->Js.log + true } } From d5c4d7971f516944b4c03c745809efb796988636 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 25 Jul 2024 04:35:46 +0900 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba2a0b5c2b..5870c8501c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,7 @@ - Turn off transformation for closures inside loops when capturing loop variables, now that `let` is emitted instead of `var`. https://github.com/rescript-lang/rescript-compiler/pull/6480 - Improve unused attribute warning message. https://github.com/rescript-lang/rescript-compiler/pull/6787 - Remove internal option `use-stdlib` from build schema. https://github.com/rescript-lang/rescript-compiler/pull/6778 +- Fix `Js.Types.JSBigInt` payload to use native `bigint` type. https://github.com/rescript-lang/rescript-compiler/pull/6911 # 11.1.2 From 8322b2b80049e920706e99910cf3ca8bc9c825d2 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 25 Jul 2024 06:30:00 +0900 Subject: [PATCH 3/3] fix genType test --- jscomp/gentype_tests/typescript-react-example/src/BigInt.res | 1 - .../gentype_tests/typescript-react-example/src/BigInt.res.js | 2 -- .../gentype_tests/typescript-react-example/src/Core.gen.tsx | 4 +--- jscomp/gentype_tests/typescript-react-example/src/Core.res | 5 +---- .../gentype_tests/typescript-react-example/src/Core.res.js | 5 ----- 5 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 jscomp/gentype_tests/typescript-react-example/src/BigInt.res delete mode 100644 jscomp/gentype_tests/typescript-react-example/src/BigInt.res.js diff --git a/jscomp/gentype_tests/typescript-react-example/src/BigInt.res b/jscomp/gentype_tests/typescript-react-example/src/BigInt.res deleted file mode 100644 index 2a3956d058..0000000000 --- a/jscomp/gentype_tests/typescript-react-example/src/BigInt.res +++ /dev/null @@ -1 +0,0 @@ -type t = Js.Types.bigint_val \ No newline at end of file diff --git a/jscomp/gentype_tests/typescript-react-example/src/BigInt.res.js b/jscomp/gentype_tests/typescript-react-example/src/BigInt.res.js deleted file mode 100644 index d856702bfe..0000000000 --- a/jscomp/gentype_tests/typescript-react-example/src/BigInt.res.js +++ /dev/null @@ -1,2 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/jscomp/gentype_tests/typescript-react-example/src/Core.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Core.gen.tsx index 08e72401d0..b4a763cad7 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Core.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Core.gen.tsx @@ -51,9 +51,7 @@ export const date0: (x:Date) => Date = CoreJS.date0 as any; export const date1: (x:Date) => Date = CoreJS.date1 as any; -export const bigint0: (x:BigInt) => BigInt = CoreJS.bigint0 as any; - -export const bigint1: (x:BigInt) => BigInt = CoreJS.bigint1 as any; +export const bigint0: (x:bigint) => bigint = CoreJS.bigint0 as any; export const regexp0: (x:RegExp) => RegExp = CoreJS.regexp0 as any; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Core.res b/jscomp/gentype_tests/typescript-react-example/src/Core.res index 75fc44fe3b..491d106c88 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Core.res +++ b/jscomp/gentype_tests/typescript-react-example/src/Core.res @@ -35,10 +35,7 @@ let date0 = (x: Js.Date.t) => x let date1 = (x: Date.t) => x @genType -let bigint0 = (x: Js.Types.bigint_val) => x - -@genType -let bigint1 = (x: BigInt.t) => x +let bigint0 = (x: bigint) => x @genType let regexp0 = (x: Js.Re.t) => x diff --git a/jscomp/gentype_tests/typescript-react-example/src/Core.res.js b/jscomp/gentype_tests/typescript-react-example/src/Core.res.js index b967c504e0..45c65ff3a7 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Core.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Core.res.js @@ -54,10 +54,6 @@ function bigint0(x) { return x; } -function bigint1(x) { - return x; -} - function regexp0(x) { return x; } @@ -116,7 +112,6 @@ export { date0, date1, bigint0, - bigint1, regexp0, regexp1, $$Map,