File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 22
33## Next version
44
5+ - Add ` Nullable.isNullable ` function. https://github.com/rescript-association/rescript-core/pull/227
56- Remove some deps to Belt, Pervasives and Js. https://github.com/rescript-association/rescript-core/pull/226/commits
67
78## 1.3.0
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ external null: t<'a> = "#null"
77
88external undefined : t <'a > = "#undefined"
99
10+ external isNullable : t <'a > => bool = "#is_nullable"
11+
1012external make : 'a => t <'a > = "%identity"
1113
1214external toOption : t <'a > => option <'a > = "#nullable_to_opt"
Original file line number Diff line number Diff line change @@ -38,6 +38,27 @@ Console.log(undefined) // Logs `undefined` to the console.
3838*/
3939external undefined : t <'a > = "#undefined"
4040
41+ /**
42+ `isNullable(a)` returns `true` if `a` is null or undefined, `false` otherwise.
43+
44+ ## Examples
45+
46+ ```rescript
47+ let myStr = "Hello"
48+ let asNullable = myStr->Nullable.make
49+
50+ // Can't do the below because we're now forced to check for nullability
51+ // myStr == asNullable
52+
53+ // Check if asNullable is not null or undefined
54+ switch asNullable->Nullable.isNullable {
55+ | true => assert(false)
56+ | false => assert(true)
57+ }
58+ ```
59+ */
60+ external isNullable : t <'a > => bool = "#is_nullable"
61+
4162/**
4263Creates a new nullable value from the provided value.
4364This means the compiler will enforce null checks for the new value.
You can’t perform that action at this time.
0 commit comments