top | item 43924569

(no title)

phiresky | 9 months ago

TypeScript does supports all of these - `C implements I` is not necessary but gives compile errors if not fulfilled.

You can use `o satisfies T` wherever you want to ensure that any object/instance o implements T structurally.

To verify a type implements/extends another type from any third-party context (as your third point), you could use `(null! as T1) satisfies T2;`, though usually you'd find a more idiomatic way depending on the context.

Of course it's all type-level - if you are getting untrusted data you'll need a library for verification. And the immutable story in TS (readonly modifier) is not amazing.

discuss

order

roguecoder|9 months ago

The problem with TypeScript is that it is ridiculously verbose. It is everything people used to complain Java was back in the 90s.