TypeScript is a superset of JavaScript, which allows you to benefit from static-typing checks at build time. However, it still ‘transpiles’ to standard JavaScript for execution, where type checking is not enforced by the runtime and ‘duck testing’ is commonly used instead.
Types are inferred, so an object can satisfy a check against an interface without being typed such that it *explicitly* implements it. Your implementation code can be very OO-lite whilst still benefitting from all of the build-time benefits. This can significantly flatten designs that would otherwise require multiple tiers to model a concept in classic OOP.
Being able to trivially deserialise objects during runtime, without typing them, saves a lot of complexity. You can write code that definitely *should* work, as long as it receives correctly formatted data.
Complex type checking at build-type, followed by execution in a simpler environment. Best of both worlds.
Recent Comments