TypeScript Stories
60 subscribers
40 links
Download Telegram
Channel created
1️⃣
string + string | number => string
number + string | number => error 2365

▶️ Playground
2️⃣
No error firing on generic wrong return type.

▶️ Playground
3️⃣
Type guard wrong types intersection via casting to unknown.

▶️ Playground
4️⃣
🤔 Guarded type narrowing.

▶️ Playground
5️⃣
🧐 A bit more complex guarded type.

▶️ Playground
6️⃣
Inaccurate "1/1" | "2/2" type inference.

▶️ Playground
7️⃣
No errors when mutating tuples by number index.

▶️ Playground
8️⃣
Interface doesn't fit Record<string, unknown>.

▶️ Playground
9️⃣
🤯 Type any passes extends operator along both branches.

▶️ Playground
🔟
Brand as key of Record might be type unsafe.
▶️ Playground

🤨 But Flavour as key of Record is just OK.
▶️ Playground
1️⃣1️⃣
😢 Would be more useful to warn about useless operations.

▶️ Playground
1️⃣2️⃣
No error on Record<string, number> addition assignments with
"compilerOptions": {
"noUncheckedIndexedAccess": true
}

▶️ Playground
1️⃣3️⃣
Implicit coercion in TypeScript.

▶️ Playground

UPD: not relevant anymore for TS v5.0.2

▶️ Playground
1️⃣4️⃣
Strange default parameter type behavior.

▶️ Playground
1️⃣5️⃣
🤨 Mysterious undefined appearance.

▶️ Playground
1️⃣6️⃣
Dynamic destructuring of function parameter is not allowed.

▶️ Playground
1️⃣7️⃣
😢 Wrong optional chaining type narrowing in if statement.

▶️ Playground
1️⃣8️⃣
Using variable before assignment is not forbidden.

▶️ Playground
1️⃣9️⃣
Wrong type inference of union with object.

▶️ Playground