From 3ebdb5534ea21b3ee027875de5d2b6188879c554 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Thu, 20 Jul 2023 18:18:49 +0000 Subject: [PATCH 1/3] Mention preference for overloads in contrib doc --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f1437a618..7a12fd93f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,6 +54,7 @@ Please: * Use `def` for read-only properties unless there is a compelling reason it should be a `val` (i.e., the spec definitively states it is constant) * Use `Double` for integer-values that can fall outside the range of `Int` +* Prefer adding overloads instead of using union `|` types for method and constructor parameters * Add scaladocs via copy-paste from MDN From c25e13f38a5763a98e061e82139fbcc21d5db95f Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 26 Jul 2023 06:47:35 -0700 Subject: [PATCH 2/3] Add an example Co-authored-by: zetashift --- CONTRIBUTING.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7a12fd93f..e1bbce177 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,7 +54,12 @@ Please: * Use `def` for read-only properties unless there is a compelling reason it should be a `val` (i.e., the spec definitively states it is constant) * Use `Double` for integer-values that can fall outside the range of `Int` -* Prefer adding overloads instead of using union `|` types for method and constructor parameters +* Prefer adding overloads instead of using union `|` types for method and constructor parameters. For example: +```diff +- def createElement(tagName: String, options: String | ElementCreationOptions = js.native): Element = js.native ++ def createElement(tagName: String): Element = js.native ++ def createElement(tagName: String, options: String): Element = js.native ++ def createElement(tagName: String, options: ElementCreationOptions): Element = js.native * Add scaladocs via copy-paste from MDN From 9f55fd08606ea1afe351643d5ed681227aebb420 Mon Sep 17 00:00:00 2001 From: zetashift Date: Wed, 26 Jul 2023 15:49:30 +0200 Subject: [PATCH 3/3] Fix ending backticks for example --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e1bbce177..18737f53b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,6 +60,7 @@ Please: + def createElement(tagName: String): Element = js.native + def createElement(tagName: String, options: String): Element = js.native + def createElement(tagName: String, options: ElementCreationOptions): Element = js.native +``` * Add scaladocs via copy-paste from MDN