Skip to content

Commit

Permalink
TINY-7416: Turn on all warnings except 105, and fix the problems that…
Browse files Browse the repository at this point in the history
… highlights. Reformat code.
  • Loading branch information
TheSpyder committed May 31, 2021
1 parent 0cd2244 commit efda3d2
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
4 changes: 2 additions & 2 deletions bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
}
],
"warnings": {
"number": "+A-42-48-105-109",
"error": "+A-3-44-102"
"number": "+A-105",
"error": "+A"
},
"bs-dependencies": [
"bs-fetch"
Expand Down
23 changes: 13 additions & 10 deletions examples/dom_example.re
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ let unwrapUnsafely =
/*
* These SHOULD type check
*/
document->Document.createElement("div")->Element.className;
let _ = document->Document.createElement("div")->Element.className;

document->Document.createElement("div")->Element.nextElementSibling->map(Element.innerText); /* innerText is a function that accepts a Node */
let _ =
document->Document.createElement("div")->Element.nextElementSibling->map(Element.innerText); /* innerText is a function that accepts a Node */

/* Before subtyping:
document -> Document.createElement("div")
Expand All @@ -23,10 +24,11 @@ document->Document.createElement("div")->Element.nextElementSibling->map(Element
*/

/* After subtyping: */
document
->Document.createElement("div")
->Element.parentElement /* inherited from Node, returns DomRe.element */
->map(Element.innerText); /* inherited from Node */
let _ =
document
->Document.createElement("div")
->Element.parentElement /* inherited from Node, returns DomRe.element */
->map(Element.innerText); /* inherited from Node */

let el = document->Document.createElement("div")->Element.asHtmlElement->unwrapUnsafely;

Expand All @@ -43,10 +45,11 @@ let el = document->Document.createElement("div")->Element.asHtmlElement->unwrapU
*/

/* After subtyping: */
document
->Document.asHtmlDocument
->flatMap(HtmlDocument.body)
->map(body => body->Element.appendChild(el));
let _ =
document
->Document.asHtmlDocument
->flatMap(HtmlDocument.body)
->map(body => body->Element.appendChild(el));

/*
/*
Expand Down
6 changes: 4 additions & 2 deletions src/Webapi/Canvas/Webapi__Canvas__Canvas2d.re
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,10 @@ external arc:
[@set] external font: (t, string) => unit;
[@set] external textAlign: (t, string) => unit;
[@set] external textBaseline: (t, string) => unit;
[@send] external fillText: (t, string, ~x: float, ~y: float, ~maxWidth: float=?, [@ignore] unit) => unit;
[@send] external strokeText: (t, string, ~x: float, ~y: float, ~maxWidth: float=?, [@ignore] unit) => unit;
[@send]
external fillText: (t, string, ~x: float, ~y: float, ~maxWidth: float=?, [@ignore] unit) => unit;
[@send]
external strokeText: (t, string, ~x: float, ~y: float, ~maxWidth: float=?, [@ignore] unit) => unit;
[@send] external measureText: (t, string) => measureText;
[@get] external width: measureText => float;

Expand Down
8 changes: 4 additions & 4 deletions tests/Webapi/Canvas/Webapi__Canvas__Canvas2d__test.re
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ let width = width(measureText);
ctx->fillText("foo!", ~x=0.0, ~y=0.0, ~maxWidth=width, ());
ctx->strokeText("foo!", ~x=0.0, ~y=0.0, ~maxWidth=width, ());
let imageData = createImageDataCoords(ctx, ~width=0.0, ~height=0.0);
createImageDataFromImage(ctx, imageData);
Image.width(imageData);
Image.height(imageData);
let _ = createImageDataFromImage(ctx, imageData);
let _ = Image.width(imageData);
let _ = Image.height(imageData);

getImageData(ctx, ~sx=0.0, ~sy=0.0, ~sw=0.0, ~sh=0.0);
let _ = getImageData(ctx, ~sx=0.0, ~sy=0.0, ~sw=0.0, ~sh=0.0);
let _: unit = putImageData(ctx, ~imageData, ~dx=0.0, ~dy=0.0);
let _: unit =
putImageDataWithDirtyRect(
Expand Down
2 changes: 1 addition & 1 deletion tests/Webapi/Dom/Webapi__Dom__EventTarget__test.re
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ let customEvent = CustomEvent.makeWithOptions("custom-event", {
"test": "test",
},
});
target->dispatchEvent(customEvent);
let _ = target->dispatchEvent(customEvent);
3 changes: 2 additions & 1 deletion tests/Webapi/Dom/Webapi__Dom__Window__test.re
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ let _ = Window.getSelection(window);
let _ = window->Window.matchMedia("max-height: 400");
let _ = window->Window.moveBy(10, -10);
let _ = window->Window.moveTo(120, 300);
let _: option(Dom.window) = window->Window.open_(~url="http://...", ~name="my window", ~features="menubar=yes" ,());
let _: option(Dom.window) =
window->Window.open_(~url="http://...", ~name="my window", ~features="menubar=yes", ());
let _: option(Dom.window) = window->Window.open_(~url="http://...", ~name="my window", ());
window->Window.postMessage("my message", "*");
Window.print(window);
Expand Down

0 comments on commit efda3d2

Please sign in to comment.