5

I'll preface this by saying that TypeScript is a beautiful language.

But also UTTERLY INCOMPLETE.

Here's what I'm trying to do: give the compiler well-defined contextual type information for a decorator's argument (a lambda signature) and for the decorated class method, so the user would not have to toil and type every single argument.

But does that happen? No.

I'm honestly disappointed.

Comments
  • 0
    Ah, that moment when you have a gigantic type signature just to declare a function that adds one. As a person who rather likes C++ I can totally understand how that feels.

    I don't know know anything about Typescript, but I assume your problem has something to do with how complex a type inference algorithm they used? As far as I know TS isn't exactly as straightforward as, say, OCaml in its type system, you can't just yolo it and apply Hindley-Milner inference.
  • 1
    @RememberMe Nah, typescript is pretty good with type inference, the problem is that decorators can't provide any contextual type information. So to use such a decorator you have to declare the method/lambda signature to the fullest (even unused arguments)

    I prefer TypeScript for prototyping ideas, but my main language for development is C++. So I completely understand where you're coming from.

    TS generics are somewhat similar to templates in C++, although the syntax is not as flexible as modern C++17.

    Sigh, Microsoft needs to fix this soon. Sadly I can't complain because decorators are an "experimental" right now, despite wide use in production code.
Add Comment