0
mr0cket
4y

TypeScript is bullshit. Change My Mind:

I am a student and I started learning typescript as an advanced project at the recommendation of my teachers because I am a bit ahead of where my software development course is.

I started by testing the logic of types, and then I encountered type: unknown.

According to the TS handbook:

"If you have a variable with an unknown type, you can narrow it to something more specific by doing typeof checks, comparison checks, or more advanced type guards that will be discussed in a later chapter:"

So according to what this says, if you check a variable of type unknown, to equal a certain object type, typescript will allow you to assign that unknown value a I tested this out with a data type - objects and typescript freaks out.

Also, if create object with a property assigned to a function, it won't even show you that property when you console.log the object

ALSO, you can't post urls in this website, so this website is also pretty trash.

Comments
  • 0
    So that one thing causes the entire language to be bullshit?

    It's still a superset of javascript, you can <any> everything if you want. Doesn't mean it gets through code review though
  • 4
    If you find this website pretty trash, just leave it. It’s your free will.

    Also, You can post links, juuuust saying.
  • 4
    s/a\sabit\sahead/way behind/g
  • 0
    The point of unknown is to allow type narrowing at compile-time, but make decisions at runtime.

    Versus any, which ignores everything at compile-time and you can only re-type it’s signature to enhance it’s type specificity.

    And all that, is actually quite good, for a dynamic language.
  • 6
    Someones ego needs to be deflated.
  • 1
    You can post URL, but not with 0 karma, As it should be
  • 2
    You're most unwelcome to DevRant
  • 3
  • 1
    You're misunderstanding how types work

    Any value will always have a type, but a variable might not.
    Just because you store a value in an untyped variable doesn't mean the value itself is untyped and can be cast to whatever you want. It just means that you don't know what's stored in there

    You generally shouldn't have untyped variables for this exact reason: Now you don't know what the variable contains so you have to manually do a bunch of type checks to figure out it's type (Is it a number? An array? An object? etc.)
  • 1
    What possible benefit could there be for any of us to talk a standoffish person off a cliff? The gamut of possibility for you at this point is:

    A) you'll figure out you're riding high on the low end of the Dunning-Kruger curve
    B) you'll drop out and switch to underwater basket weaving
    C) you won't be competition

    None of those are negatives for the rest of us. You'll either figure out you're wrong, or you'll filter yourself out.
  • 4
    Imagine thinking that still being a student you could argue the architecture of a programming language with the dude who made c# and Delphi + the whole Microsoft development team.

    You clearly never developed in JS on enterprise apps to know how good ts is in comparison.
  • 0
    I can't, it is bullshit :D
Add Comment