Skip to content

13.0.0-alpha.7

Pre-release
Pre-release

Choose a tag to compare

@cknitt cknitt released this 05 Nov 18:30
· 91 commits to master since this release
Immutable release. Only release title and notes can be modified.
89d5411

⭐ Highlights

  1. New build system
    • rescript now runs a build system rewritten in OCaml that compiles modules in-process on several CPU cores. The Rust implementation remains available as rescript-rust. #8780 #8781 #9170
    • Modules with many JSX DOM elements compile up to 10× faster, with .cmt files up to 30× smaller. #9149
    • Large char ranges, list literals, nested inlining and let rec groups no longer take quadratic time. #8893 #8794 #8801 #9153
  2. New language features
    • try … finally. #8931
    • Int range patterns such as 200 .. 299, with char now an alias of int. #8894 #8892
    • $ in identifiers, e.g. let count$ = signal(0). #8791
    • for..of over generators and iterators directly. #8937
  3. Untagged variants for JavaScript classes
    • @instanceOf("Class") and @typeOf make bound JavaScript classes and opaque types untagged variant cases; File, Blob, JsError, Symbol and the Intl classes work as cases. #8950
    • Switches on untagged variants generate less code and test literals and typeof before any instanceof. #9015
  4. Standard library
    • Temporal bindings. #9094
  5. React Server Components
    • Nested components such as <Sidebar.Provider /> work as client references. #8904
  6. Error messages
    • Signature mismatches show only the items that differ, in ReScript syntax. #9140 #9078
  7. Upgrading from v12
    • The APIs deprecated in v12 are removed; run rescript-tools migrate-all with 12.3.2 before upgrading. #9052
    • @deriving(abstract) and @deriving(jsConverter), the @ocaml.* attributes, @ocaml.doc/@ns.doc doc comments, record syntax for dicts and macOS Intel support are removed. See the breaking changes below. #8729 #8928 #8992 #8751 #8912

💥 Breaking Change

  • Records whose fields are named "0", "1", … with @as are JavaScript arrays; record rest patterns, coercions and untagged variants that would treat them as objects are now errors. #9224
  • Replace %debugger with a debugger() function. #9163
  • Coercing another type into a private record or variant is an error. #9125
  • TypedArray.map and TypedArray.mapWithIndex keep the element type. #9112
  • The new Temporal stdlib module shadows project modules named Temporal; nested modules named Temporal are exported to JavaScript as $$Temporal. #9094
  • Remove the stdlib APIs deprecated in v12, such as List.has, Error and Exn; run rescript-tools migrate-all with 12.3.2 first. #9052
  • Typed array types such as Int8Array.t are no longer interchangeable; upcast with :> TypedArray.t<_> to use the generic TypedArray functions. #9050
  • @unboxed can only be written on a variant type, not on a constructor. On the type, it makes a single-field inline record payload the field itself instead of the record object; give the record type a name to keep the object. #9040
  • .cmi and .cmt files use ReScript magic numbers, so tools that read them as OCaml files no longer accept them. #9000
  • Read doc comments only from /** */; @ocaml.doc and @ns.doc are ignored. #8992
  • Remove the @ocaml.* attribute spellings, such as @ocaml.warning, and %extension_constructor; PPX output keeps working. #8928
  • Drop support for macOS on Intel (darwin-x64). Intel Mac users can stay on ReScript 12. #8912
  • Remove @res.hoistedFunction; nested functions other than make are no longer exported as top-level A$B$f values. #8904
  • \"_" is no longer a valid quoted identifier. #8795
  • rescript ignores RESCRIPT_BSC_EXE; only rescript-rust reads it. #8781
  • rescript rejects duplicate keys in rescript.json, namespace-entry without namespace and a value after --no-timing. #8780
  • rescript --filter supports only common regular expression syntax. #8780
  • A failing --after-build command fails the build. #8780
  • rescript format -v and rescript compiler-args -v write their logs to stderr instead of stdout. #8780
  • rescript does not export OpenTelemetry traces; rescript-rust still does. #8780
  • Record syntax no longer creates or matches dicts, e.g. let d: dict<int> = {foo: 1}; it's an error pointing to dict{...}. #8751
  • Remove the call-site @inlined attribute, which had no effect. #8734
  • Remove the builtin primitives %obj_is_int, %obj_dup, %obj_field, %array_safe_set, %null_to_opt and %nullable_to_opt. #8731
  • Remove the -pp compiler flag, which had no effect. #8731
  • Remove @deriving(abstract) and @deriving(jsConverter); use records and polymorphic variants directly. #8729

🚀 New Feature

  • Add Temporal bindings to the standard library. #9094
  • Allow coercing iterator, generator, Array.arrayLike and taggedTemplate types through their type parameters, e.g. Iterator.t<sub> to Iterator.t<super>. #8981
  • Add @instanceOf and @typeOf, so that JavaScript classes and opaque primitive types can be untagged variant cases. #8950 #9017 #9050
  • for..of and for await..of accept generators and other iterator types directly, without asIterable. #8937
  • Add try ... finally { ... } and try ... catch { ... } finally { ... }, compiled to JavaScript finally blocks. #8931
  • Export nested make functions flat (A$B$make), so that nested components work as React Server Components client references. #8904
  • Support int range patterns such as 200 .. 299. #8894
  • Make char an alias of int. #8892
  • Allow $ in identifiers, e.g. let count$ = signal(0). #8791
  • rescript now runs a build system rewritten in OCaml; the Rust implementation remains available as rescript-rust. #8780
  • Allow an untagged variant to have both a true or false literal case and a bool payload case. #8777 #9036

🐛 Bug fix

  • Keep records with fields named "0", "1", … JavaScript arrays when they are spread, written as {} or defined with let rec, and match them as arrays in untagged variants. #9224 #9232
  • Reject await in a functor body, which produced invalid JavaScript. #9220
  • Reject coercing unit to string and polymorphic variants to bool or unit. #9218
  • Reject spreading bool or unit into a variant. #9218
  • Fix an @string or @int argument of an external being evaluated twice, as in on(t, mk()), or breaking await. #9217
  • Parse several doc comments before the | of a variant constructor, as the formatter prints them. #9203
  • Complete array elements after a spread, such as [...xs, <cursor>]. #9199
  • Fix await, break and continue in a while condition. #9177
  • Stop the optimizer from replacing an async or @directive function that only forwards its parameters with the function it calls, as in let g = async n => f(n). #9176
  • Reject await in a function that an async function returns, as in async x => y => await y. #9169
  • Fix the end location of template literals without interpolations when PPXs are used. #9166
  • Fix %todo calling a user-defined JsError module instead of the standard library one. #9160
  • Show the file name and columns in the %todo error location. #9160
  • Fix an argument or literal element being evaluated after a later one that is a { ... } block with statements. #9159
  • Fix a type hole where a record spread or {} with a mutable field could store a value at one type and read it at another. #9158 #9152
  • Editor "find references" on a record field no longer lists record literals that leave the optional field out. #9149
  • Reject @@jsxConfig versions other than 4 instead of disabling the JSX transform. #9145
  • Print non-ASCII @as names and external strings as written instead of as escapes. #9143
  • Keep @tag, @notUndefined, @instanceOf and @typeOf in printed type declarations. #9136
  • Fix a switch on a mutable field taking a case that no longer matches after a guard changed the field. #9131
  • Accept attributes on a let that destructures a GADT constructor. #9128
  • Keep comments around a lone list pattern spread, as in list{/* c */ ...r}, when formatting. #9127
  • Accept a UTF-8 byte order mark and lines that end in a carriage return alone. #9120
  • Fix the formatter misplacing doc comments and comments in several positions. #9119
  • Fix the coercion hint after a parenthesized operand. #9118
  • Evaluate JSX children after the other props in plain JSX mode, as in preserve mode. #9117
  • Make the formatter keep line breaks inside literals as written. #9116
  • Accept attributes and doc comments after = private and doc comments after = in type declarations. #9115
  • Fix the JavaScript simplifier treating equal float constants as different, which turned x == 2.5 && x == 2.5 into false. #9114
  • Fix untagged variant matches with both true and false literal cases skipping the other checks. #9113
  • Type the typed arrays' copyWithin and copyAllWithin as returning the typed array. #9112
  • Fix the formatter moving attributes onto a labeled parameter alias like ~a as x. #9111
  • Fill cases added by editor code actions with %todo. #9110
  • Record coercion no longer makes an immutable field mutable or changes a mutable field's type. #9086
  • Keep let f: type a. t => a = x => on one line when it fits. #9082
  • Keep attributes and doc comments, fix indentation, and print the types of applied functors and includes in interfaces created by the editor. #9077 #9096 #9144 #9207
  • Keep a line comment in a switch, if, try or loop operand in place when formatting. #9061
  • Parse a doc comment before a function parameter. #9055
  • Print a type reached through a module alias only once in type errors. #9054
  • Suggest a coercion to the whole expected type, not the nested part that differs. #9053
  • Make the formatter keep each file's line endings, also on Windows. #9042 #9201
  • On Windows, fix removing lib/watch.lock sometimes failing to stop a watcher. #9034
  • Make editor analysis output work outside VS Code. #9031
  • Fix negated float comparisons with NaN, such as !(x < 0.0). #9024
  • Fix a stack overflow when compiling option of a recursive @unboxed variant. #9019
  • Fix untagged variant switches with a _ arm sending class instances or literals it should handle to a named arm. #9010
  • Reject an implementation whose variant @as tags differ from its interface. #9009
  • Keep Some(U) distinct from None when U is @as(undefined). #9008
  • Print private for abbreviations and variants in type errors. #8999
  • Show polymorphic variant labels like #644 in completion as the formatter prints them. #8990
  • genType emits char as number. #8988
  • Report an error when two bindings get the same JavaScript name, such as delete and $$delete. #8982
  • Reject @as literals of one variant with the same JavaScript value, such as @as(1) and @as(1.0). #8965
  • Reject an implementation that can hold undefined for a type its interface declares @notUndefined. #8950
  • Match File before Blob in untagged variants whatever the case order, and allow JsError.t, Symbol.t and the Intl classes as cases. #8950
  • Stop rescript from recompiling unchanged modules on every build when a source dir is "." or "./src". #8940
  • Fix builds of a namespaced package failing with "… is an alias for module …, which is missing", or staying stale, when a module refers to a sibling as Namespace.Module. #8939
  • Evaluate the callee and arguments of a partial application f(a, ...) once, so that await works in them. #8936
  • Parse a switch guard that calls a function named async. #8935
  • Reject a rescript.json namespace that is not a valid module name. #8927
  • Show compiled file names as written, such as ABC.cmi instead of aBC.cmi, on case-insensitive file systems. #8925
  • Warn when a @deprecated binding of a module without an interface is used. #8924
  • Make rescript-tools migrate leave files untouched when no migration applies. #8922
  • genType refers to values named like JS keywords or globals, such as delete, by their JavaScript names. #8920
  • Keep attributes and doc comments after = in front of a record or .. type, as in type t = @s.strict {...}, so that PPXs see them. #8919
  • Keep inline records in exceptions and constructors multiline when the source breaks the line after {. #8918
  • Reanalyze no longer reports Division_by_zero for a non-zero literal divisor. #8917
  • Make rescript-tools migrate refuse files changed since the last build. #8916
  • Warn about untagged variant payload patterns that a literal case makes unreachable, and accept Yes | Ans(false) as exhaustive for @as(true) Yes | Ans(bool). #8914
  • Fix the formatter dropping spreads, attributes and comments in array and list literals with spreads. #8905
  • Fix a compiler crash on a guarded or-pattern that an earlier case makes unreachable. #8896
  • Compile template and braced %raw and %ffi payloads the same with and without PPXs. #8879
  • Remove the temporary PPX files when a PPX fails or a build is interrupted. #8864
  • Reject JSX props of an @unboxed record type. #8857
  • Fix the formatter indenting dict literal rows after a spread twice. #8853
  • Fix the formatter dropping comments in dict patterns, variant spread patterns and dict literals with spreads. #8850
  • Fix module M = await (P: S) at the top level of a module compiling to a static import of P. #8848
  • Fix external PPXs changing dict literals and Primitive_dict.make(...) calls. #8846
  • Fix the formatter printing await on a typed first-class module in a form that does not parse. #8845
  • Fix JSX preserve mode passing a copy of the props instead of the props themselves for <C {...props} /> compiled to a call. #8844
  • Fix a crash and wrong code for matches that test an optional field or dict key both for a value and for presence. #8842
  • rescript-rust: keep watching a source folder on Linux when an overlapping source folder is removed. #8839
  • Add the missing keys, such as allowed-dependents and features, to the rescript.json schema. #8835
  • Derive module names from file names consistently, so that Button.test.res can reference Button. #8797
  • Fix the formatter printing escaped identifiers starting with _ in a form that does not parse. #8795
  • Evaluate the arguments of an inlined call left to right, as the call does, including unused ones. #8786 #9177
  • Fix a @val global being read from a local binding of the same name. #8785
  • Fix parser recovery and completion for a missing record or dict value, as in {a: , b: 1}. #8779
  • Fix generated JavaScript names colliding with identifiers containing $. #8778
  • Fix installing on Windows on ARM, broken since v12, by using the x64 binaries again. #8776
  • Fix editor completion of values from modules included with include await M. #8770
  • Fix editor completion inside dict literals and dict patterns. #8770
  • Report the required Node.js version 22 when the platform package can't be found. #8770
  • Fix JSX preserve mode emitting JSX that means something other than the compiled call. #8754
  • Fix exhaustiveness checks for dict patterns, and reject a key matched twice in one pattern. #8751
  • Fix the formatter duplicating and dropping attributes on patterns. #8750
  • Emit "__proto__" keys in object literals as computed keys, so that they do not set the prototype. #8747
  • Fix the formatter dropping attributes on dict literals and flattening nested dict spreads. #8746
  • Give unused-pattern warnings for variant spreads a location. #8744
  • Keep @warning("-4") on if expressions when formatting. #8741
  • Fix the formatter dropping a @res.ternary attribute written in source. #8740
  • Respect @warning on the module in module type of. #8738
  • Fix the formatter dropping attributes and await on module expressions and printing invalid module constraints. #8735
  • Fix the sign of @inline bigint constants in printed signatures. #8732
  • rescript-rust: fix watch sometimes not exiting on macOS when lib/watch.lock is removed. #8730
  • Keep parentheses around statements that start with a regexp literal when formatting. #8720
  • Preserve the scope of attributes on ternary conditions when formatting. #8720
  • Fix compiler crashes on Some and optional arguments whose types come from a transitive dependency. #8719
  • Fix switches on ints at the int32 limits; aliased int patterns such as 0xFFFF_FFFF and -1 may now be reported as unused. #8717
  • Fix RescriptTools.binaryPath failing with ERR_PACKAGE_IMPORT_NOT_DEFINED when used from a user project. #8694
  • genType types inline-record cases of untagged variants as objects instead of their single field's type. #8693
  • Fix invalid JavaScript for a module whose toplevel always throws. #8692
  • Stop a long source path from shortening parts of module inclusion errors to .... #8691
  • Keep comments on labeled parameters with defaults and before =? when formatting. #8690
  • rescript-rust: keep compiling independent modules after an unrelated failure. #8667
  • Keep watch mode running when a rebuild fails to initialize. #8641
  • Make rescript clean work with an invalid module graph and remove out-of-source outputs too. #8640
  • Fix genType path resolution for Windows short paths and symlinked projects. #8639
  • rescript-rust: rebuild dependencies when the project's package output settings change. #8540

📝 Documentation

  • State in the rescript.json schema that namespace-entry requires namespace. #8984

💅 Polish

  • Stop describing bool and unit as variants in coercion errors. #9218
  • Name the wrong field in record and inline record coercion errors. #9205
  • Point errors and editor features at the text of a template literal segment, without its backquotes, ${ or }. #9166
  • Clearer errors for an unknown deriver and for a configuration passed to @deriving(accessors). #9157
  • Compile large let rec groups in linear time. #9153
  • Stop storing a None for every omitted optional field, so that modules with many JSX DOM elements compile up to 10× faster. #9149
  • Stop suggesting the @uncurry decorator in editor completion; the compiler no longer supports it. #9146
  • Show a signature mismatch as the actual and expected declarations, limited to the items that differ. #9140
  • Keep the location of extension constructors and exceptions declared in an interface. #9140
  • Report every difference between the record fields or variant constructors of an implementation and its interface. #9133
  • Indent multi-line types in error messages under their heading. #9091
  • Stop mentioning switch branches in type errors after a let that destructures a GADT constructor. #9081
  • Show GADT existential types as $a and name the constructor that binds an escaping one. #9080
  • Give the same type rec hint for every GADT constructor of a type declared without rec. #9079
  • Print signature mismatch errors in ReScript syntax. #9078
  • Add the missing JSX DOM event handlers through React 19.3. #9075
  • Reuse one object per depth for nested None, so that creating one no longer allocates. #9025
  • Stop emitting bare conditions like x === null; and empty if/else branches. #9024
  • Generate less code when matching Some(x). #9022
  • Allow @notUndefined on type abbreviations. #9017
  • Generate smaller untagged variant switches that test literals and typeof before any instanceof. #9015 #9046 #9047
  • List floats and bigints in the error for an invalid @as payload, since @as accepts them. #8987
  • Put a blank line around multi-line top-level and module-level items when formatting. #8961
  • Use constant arguments directly when inlining a function. #8942
  • Import the default export for @module externals whose @scope starts with "default". #8923
  • Report a spread of the wrong collection type, such as a list spread into an array, at the spread. #8905
  • Explain that a JSX tag needs a component module that defines make. #8885
  • Report unsupported JSX component annotation payloads; a payload on @react.componentWithProps is deprecated. #8884 #8944
  • Treat json template literals outside @as(json`...`) _ as ordinary tagged templates. #8875
  • Compile char range patterns as fast as a single char and show ranges in missing-case warnings. #8868 #8893
  • Remove the rescript/lib/es6/* and rescript/lib/js/* package exports, which pointed to missing files. #8837
  • Stop inlining nested calls more than four levels deep, avoiding quadratic compile time and output size. #8801
  • Speed up type checking of records with many fields. #8799
  • Generate JavaScript for list literals that grows linearly with their length instead of quadratically. #8794
  • Emit the imports of a module used both with and without default in a stable order. #8787
  • Speed up rescript builds by compiling modules in-process on several CPU cores. #8781 #8869 #9170 #9187 #9188
  • Make .cmt and .cmti files smaller by no longer embedding a copy of the .cmi. #8774
  • Speed up dead code elimination of toplevel bindings in large modules. #8773
  • Speed up compiling nested functions with local bindings named like JavaScript globals. #8772
  • Speed up inlining decisions for large functions. #8771
  • Make compilation slightly faster. #8769
  • Compile dict spreads to object spread syntax instead of Object.assign. #8747
  • Name the allowed-dependents key in the hint for a dependency that is not allowed. #8696
  • Require Node.js 22 in the platform binary packages. #8695
  • Format else branches consistently with if branches. #8678
  • Omit redundant braces around multi-statement switch case bodies when formatting. #8677
  • Wrap JSX expression children and comments in braces when formatting, to prepare for literal text children. #8666
  • Avoid running rescript-schema-ppx and sury-ppx on source files without an @schema annotation. #8662

🏠 Internal

  • Require lsp below 1.28. #9234
  • Dispatch @deriving by name instead of through a registry that had a single deriver. #9157
  • Remove stale CI steps. #9147
  • Develop and test with Node.js 26. #9059
  • Upgrade js_of_ocaml and wasm_of_ocaml to 6.5.0. #9051
  • Build the dispatch of an untagged variant switch as a plan before printing it. #9045
  • Upgrade the development toolchain and CI builds to OCaml 5.5.2. #9043
  • Run the syntax roundtrip tests and format checks on Windows CI. #9042
  • Run the remaining test suites on Windows CI. #9041
  • Update vite to 8.3.5 in the dev playground. #9011
  • Fix the cleanup of the concurrent async compiler request test. #8989
  • Add make test-rewatch-rust for testing the Rust build system. #8983
  • Document the rules of untagged variants in compiler/ml/UntaggedVariants.md. #8952
  • Recognize stdlib classes in untagged variants only through their @instanceOf annotations. #8950
  • Publish API documentation to the website branch matching the compiler major. #8945
  • Update Binaryen to 133 in CI and pin the remaining unpinned actions. #8913
  • Remove the hashing fast paths for switches with many distinct constants, which char ranges no longer need. #8900
  • Remove the error variant catalog tests/ERROR_VARIANTS.md. #8898
  • Update Yarn, mocha, Biome and other development dependencies. #8890
  • Upgrade opam to 2.6.1 in the devcontainer. #8889
  • Build the OCaml build system against libuv 1.53.0 via the rescript-lang/luv fork. #8883
  • Make compiler requests safe to run repeatedly and in parallel in one process. #8864
  • Fix spurious failures when updating the super_errors snapshots. #8840
  • Add and fix tests for reanalyze, the formatter, rescript-tools migrate and the build test fixtures. #8838 #8855 #8856
  • Run the TypeScript type check of the JS sources in CI. #8836
  • Fix stale comments and docs. #8835 #8841 #8851 #8854
  • Remove the S-expression parsetree printer (res_parser -print sexp). #8803
  • Use one set of OCaml warning flags for the whole repository. #8796
  • Use the OCaml standard library's hash tables, sets and maps in the compiler. #8786 #8787 #8789 #8790
  • Remove the compiler's own growable vector (Vec) in favor of plain arrays. #8784
  • Make dict an abstract type instead of a record with a hidden field. #8752
  • Remove the unused res.iflet encoding of if let. #8741
  • Merge the formatter's internal attribute filters into one. #8740
  • Remove dead code and OCaml leftovers across the compiler, editor analysis, reanalyze, genType and rewatch. #8731 #8756 #8793 #8805 #8849 #8852 #8859 #8991 #9146
  • Remove unused parsetree nodes and make expression attributes immutable. #8682 #8684 #8685
  • Replace parsetree attribute encodings, such as for ternaries, dicts and spreads, with dedicated nodes. #8674 #8678 #8686 #8738 #8742 #8746 #8749 #8751 #8875 #8879 #8884 #8905 #9161
  • Add before/after optimization views to the developer playground's Lambda tab. #8636