Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@

- Add experimental command to `rescript-tools` for extracting all ReScript code blocks from markdown, either a md-file directly, or inside of docstrings in ReScript code. https://github.com/rescript-lang/rescript/pull/7623

#### :bug: Bug fix

- Fix `typeof` parens on functions. https://github.com/rescript-lang/rescript/pull/7643


# 12.0.0-beta.1

#### :rocket: New Feature
Expand Down
7 changes: 6 additions & 1 deletion compiler/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -798,9 +798,14 @@ and expression_desc cxt ~(level : int) f x : cxt =
P.string f " in ";
expression ~level:0 cxt f obj)
| Typeof e ->
let is_fun =
match e.expression_desc with
| Fun _ -> true
| _ -> false
in
P.string f "typeof";
P.space f;
expression ~level:13 cxt f e
P.cond_paren_group f is_fun (fun _ -> expression ~level:13 cxt f e)
| Bin
( Minus,
{
Expand Down
5 changes: 5 additions & 0 deletions tests/tests/src/core/Test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ function run(loc, left, comparator, right) {
console.log(obj.stack.replace(/\n /g, "\n ").replace(/^Error\n/, "").replace(/^.+\n/, "").replace(/\n at .+\(node:internal.+\n?/g, ""));
}

console.log(typeof (prim => require(prim)));

let TypeofParensOnFun = {};

export {
dirname,
print,
run,
TypeofParensOnFun,
}
/* dirname Not a pure module */
6 changes: 6 additions & 0 deletions tests/tests/src/core/Test.res
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ ${codeFrame}
->Console.log
}
}

module TypeofParensOnFun = {
@val external require: string => {..} = "require"

Console.log(Type.typeof(require))
}