Skip to content

Commit 21bff5a

Browse files
DZakhzth
authored andcommitted
Improve Core__Type
1 parent dc9d9a0 commit 21bff5a

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
- Map, Set, WeakMap, WeakSet: use the types defined in the Js namespace. https://github.com/rescript-association/rescript-core/pull/143
88
- Symbol: use the types defined in the Js namespace. https://github.com/rescript-association/rescript-core/pull/145
9+
- 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
10+
- The type `RescriptCore.Type.symbol` removed in favor of `RescriptCore.Symbol.t`. https://github.com/rescript-association/rescript-core/pull/146
11+
- Added `BigInt` support for `RescriptCore.Classify.t`. https://github.com/rescript-association/rescript-core/pull/146
912
- `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)
1013
- `sort` -> `toSorted`, `sortInPlace` -> `sort`
1114
- `reverse` -> `toReversed`, `reverseInPlace` -> `reverse`

src/Core__Type.res

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ type t = [#undefined | #object | #boolean | #number | #bigint | #string | #symbo
33
external typeof: 'a => t = "#typeof"
44

55
module Classify = {
6-
type function
7-
type object
8-
type symbol
6+
type function = Js.Types.function_val
7+
type object = Js.Types.obj_val
98

109
type t =
1110
| Bool(bool)
@@ -15,15 +14,17 @@ module Classify = {
1514
| Number(float)
1615
| Object(object)
1716
| Function(function)
18-
| Symbol(symbol)
17+
| Symbol(Core__Symbol.t)
18+
| BigInt(Core__BigInt.t)
1919

2020
@val external _internalClass: 'a => string = "Object.prototype.toString.call"
2121
external _asBool: 'a => bool = "%identity"
2222
external _asString: 'a => string = "%identity"
2323
external _asFloat: 'a => float = "%identity"
2424
external _asObject: 'a => object = "%identity"
2525
external _asFunction: 'a => function = "%identity"
26-
external _asSymbol: 'a => symbol = "%identity"
26+
external _asSymbol: 'a => Core__Symbol.t = "%identity"
27+
external _asBigInt: 'a => Core__BigInt.t = "%identity"
2728

2829
let classify = value => {
2930
switch _internalClass(value) {
@@ -37,6 +38,7 @@ module Classify = {
3738
| "[object AsyncFunction]" =>
3839
Function(_asFunction(value))
3940
| "[object Symbol]" => Symbol(_asSymbol(value))
41+
| "[object BigInt]" => BigInt(_asBigInt(value))
4042
| _ => Object(_asObject(value))
4143
}
4244
}

src/Core__Type.resi

+2-8
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ module Classify: {
4747
*/
4848
type object
4949

50-
/**
51-
An abstract type representing a JavaScript symbol.
52-
53-
See [`symbol`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) on MDN.
54-
*/
55-
type symbol
56-
5750
/**
5851
The type representing a classified JavaScript value.
5952
*/
@@ -65,7 +58,8 @@ module Classify: {
6558
| Number(float)
6659
| Object(object)
6760
| Function(function)
68-
| Symbol(symbol)
61+
| Symbol(Core__Symbol.t)
62+
| BigInt(Core__BigInt.t)
6963

7064
/**
7165
`classify(anyValue)`

0 commit comments

Comments
 (0)