TGViewer
Why Typescript is bad Why Typescript is bad @why_typescript_is_bad · 1.7K subscribers
Post #37 1.51K

Forwarded from кана

interface A { a(): string };
interface B { b(): string };

function f(x: A | B): string {
if ("a" in x) {
return x.a();
} else {
return x.b();
}
}

const x = { a: 10, b() { return "hello"; } };
const y: B = x;
f(y);


то есть вот пример, когда тс говорит все ок, а все не ок
  • 👍 1
More from @why_typescript_is_bad
  1. Apr 25, 2025Playground @js_monk Thanks for sharing this madness!
  2. Mar 11, 2025TypeScript decided to commit sudoku by rewriting its compiler in an even worse language: G…
  3. Mar 7, 2025Also this was about running DOOM in types https://www.youtube.com/watch?v=0mCsluv5FXA
  4. Mar 7, 2025That's it.
  5. Jan 27, 2025photo post
  6. Jan 25, 2025Eh?
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →