tell a joke in typescript

Here's a simple joke in TypeScript:

index.ts
const x: string = "10";
const y: number = 5;
console.log(x + y); // "105"
74 chars
4 lines

The joke is that TypeScript is a strongly typed language that will usually throw an error if you try to concatenate a string and a number. However, in this case, because we have explicitly defined the type of x as a string, TypeScript will allow the addition of a number to it and return a concatenated string without error.

Of course, this type of behavior is generally not recommended and can lead to unintended consequences, so it's important to always pay attention to the types in your code!

gistlibby LogSnag