From 72612ee900f9949d4d6cb05ff8df3ff79b512cb8 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Wed, 29 Jan 2020 06:49:43 +0100 Subject: [PATCH] Add more principles. --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index ecc073b..36cd902 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,31 @@ function sum(a, b) { } ``` +### 💩 Don't specify types and/or don't do type checks if language allows you to do so. + +_Good 👍🏻_ + +```javascript +function sum(a, b) { + return a + b; +} + +// Having untyped fun here. +const guessWhat = sum([], {}); // -> "[object Object]" +const guessWhatAgain = sum({}, []); // -> 0 +``` + +_Bad 👎🏻_ + +```javascript +function sum(a: number, b: number): number { + return a + b; +} + +// This one fails during the transpilation/compilation. +const guessWhat = sum([], {}); +``` + ### 💩 You need to have an unreachable piece of code This is your "Plan B".