You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Core standard library support for genType (#6019)
* Add `Core` standard library support for `genType`
See https://forum.rescript-lang.org/t/difficulty-with-shims-and-undefined-t-and-null-t/4240
* genType: treat Dict.t type as built-in.
* Support `Promise.t`.
* Support `Date.t`.
* Support BigInt
* Support RegExp.
* Support Map and WeakMap
* Support Set and WeakSet.
* Update CHANGELOG.md
* Clean up unused Record and RecordC.
* genType: treat option<t> as t | undefined
This produces strictly fewer conversion functions, as it does not need to transform `null` to `undefined`.
* Remove special treatment of `{x:option<t>}` as optional field.
This is a breaking changes, but aligns more closely with TS.
The two TS types:
```ts
type t1 = { x?: string };
type t2 = { x: (undefined | string) };
```
now correspond to the ReScript types:
```res
@genType
type t1 = {x?: string}
@genType
type t2 = {x: Js.undefined<string>}
```
The special treatment of fields of option type comes from a time where records with optional fields did not exist.
* Add examples of what can and cannot be used in bindings to functions.
* Update CHANGELOG.md
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ subset of the arguments, and return a curried type with the remaining ones https
26
26
- Add support for toplevel `await`https://github.com/rescript-lang/rescript-compiler/pull/5940
27
27
- Support optional named arguments without a final unit in uncurried functions https://github.com/rescript-lang/rescript-compiler/pull/5907
28
28
- Add experimental suppport for directives. An annotation such as `@@directive("use client;")` emits `use client;` verbatim before imports https://github.com/rescript-lang/rescript-compiler/pull/5998
29
+
-`genType`: add `Core` standard library support for the following builtin types: `Null.t`, `Nullable.t`, `Undefined.t`, `Dict.t<_>`, `Promise.t<_>`, `Date.t`, `BigInt.t`, `RegExp.t`, `Map.t<_, _>`, `WeakMap.t<_, _>`, `Set<_>`, `WeakSet<_>`https://github.com/rescript-lang/rescript-compiler/pull/6019
29
30
30
31
#### :boom: Breaking Change
31
32
@@ -39,6 +40,9 @@ subset of the arguments, and return a curried type with the remaining ones https
39
40
Also, `(. int) => string => bool` is not equivalen to `(. int, string) => bool` anymore.
40
41
These are only breaking changes for unformatted code.
41
42
- Exponentiation operator `**` is now right-associative. `2. ** 3. ** 2.` now compile to `Math.pow(2, Math.pow(3, 2))` and not anymore `Math.pow(Math.pow(2, 3), 2)`. Parentheses can be used to change precedence.
43
+
-`genType`: streamline the treatment of optionals as undefined https://github.com/rescript-lang/rescript-compiler/pull/6022
44
+
- Represent `option<t>` as `undefined | t` instead of `null | undefined | t`. This is more permissive when importing functions taking optional values (allows to use option types), but stricter when e.g. exporting ReScript functions taking arguments of option type. Fallback: use `Js.undefined<_>` instead.
45
+
- Represent `{x:option<string>}` as `{x:(undefined | string)}` instead of `{x?: string}`. This is more in line with TS's behaviour. Fallback: use `{x?:string}`.
0 commit comments