From edf1027f38761b11f591c277341a4510007c0447 Mon Sep 17 00:00:00 2001 From: Dmitry Zakharov Date: Sat, 1 Jul 2023 03:24:11 +0400 Subject: [PATCH] Improve Core__Type --- CHANGELOG.md | 3 +++ src/Core__Type.res | 12 +++++++----- src/Core__Type.resi | 10 ++-------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66ec2a55..ec45a637 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ - Map, Set, WeakMap, WeakSet: use the types defined in the Js namespace. https://github.com/rescript-association/rescript-core/pull/143 - Symbol: use the types defined in the Js namespace. https://github.com/rescript-association/rescript-core/pull/145 +- The types `RescriptCore.Type.function` and `RescriptCore.Type.object` use the types defined in the Js namespace. https://github.com/rescript-association/rescript-core/pull/146 +- The type `RescriptCore.Type.symbol` removed in favor of `RescriptCore.Symbol.t`. https://github.com/rescript-association/rescript-core/pull/146 +- Added `BigInt` support for `RescriptCore.Classify.t`. https://github.com/rescript-association/rescript-core/pull/146 - `Array` mutable & immutable helper name changed to conform to JS' upcoming APIs [such as `toSorted`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted) - `sort` -> `toSorted`, `sortInPlace` -> `sort` - `reverse` -> `toReversed`, `reverseInPlace` -> `reverse` diff --git a/src/Core__Type.res b/src/Core__Type.res index aaea1806..4680f491 100644 --- a/src/Core__Type.res +++ b/src/Core__Type.res @@ -3,9 +3,8 @@ type t = [#undefined | #object | #boolean | #number | #bigint | #string | #symbo external typeof: 'a => t = "#typeof" module Classify = { - type function - type object - type symbol + type function = Js.Types.function_val + type object = Js.Types.obj_val type t = | Bool(bool) @@ -15,7 +14,8 @@ module Classify = { | Number(float) | Object(object) | Function(function) - | Symbol(symbol) + | Symbol(Core__Symbol.t) + | BigInt(Core__BigInt.t) @val external _internalClass: 'a => string = "Object.prototype.toString.call" external _asBool: 'a => bool = "%identity" @@ -23,7 +23,8 @@ module Classify = { external _asFloat: 'a => float = "%identity" external _asObject: 'a => object = "%identity" external _asFunction: 'a => function = "%identity" - external _asSymbol: 'a => symbol = "%identity" + external _asSymbol: 'a => Core__Symbol.t = "%identity" + external _asBigInt: 'a => Core__BigInt.t = "%identity" let classify = value => { switch _internalClass(value) { @@ -37,6 +38,7 @@ module Classify = { | "[object AsyncFunction]" => Function(_asFunction(value)) | "[object Symbol]" => Symbol(_asSymbol(value)) + | "[object BigInt]" => BigInt(_asBigInt(value)) | _ => Object(_asObject(value)) } } diff --git a/src/Core__Type.resi b/src/Core__Type.resi index 8bfe4bdf..c5d1d9be 100644 --- a/src/Core__Type.resi +++ b/src/Core__Type.resi @@ -47,13 +47,6 @@ module Classify: { */ type object - /** - An abstract type representing a JavaScript symbol. - - See [`symbol`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) on MDN. - */ - type symbol - /** The type representing a classified JavaScript value. */ @@ -65,7 +58,8 @@ module Classify: { | Number(float) | Object(object) | Function(function) - | Symbol(symbol) + | Symbol(Core__Symbol.t) + | BigInt(Core__BigInt.t) /** `classify(anyValue)`