|
|
|
|
|
by phiresky
402 days 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. |
|