7
submitted 2 years ago* (last edited 2 years ago) by CannotSleep420@lemmygrad.ml to c/programmerhumor@lemmy.ml
class Lol {
    get length() {
        console.log('Lol. LMAO even.');
        return 5;
    }
}

const noLolsAllowed = (notALol: string) => {
    for (let i = 0; i < notALol.length; ++i) {
        console.log('No lols here');
    }
}

noLolsAllowed(new Lol() as unknown as string);
you are viewing a single comment's thread
view the rest of the comments
[-] DerPapa69@lemmy.ml 2 points 2 years ago

Yeah, I do agree that it's a bit weird with TS. It's fully understandable though, since it just transpiles to JS, which doesn't have any type information during runtime. I think as far as webdev goes though, TS makes it at least somewhat bearable.

Sorry for the downvote btw - that wasn't me!

this post was submitted on 04 Mar 2023
7 points (100.0% liked)

Programmer Humor

32355 readers
1216 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS