4 ms·
Well Typescript is really a static code analyser for Javascript and not a language, since it does nothing at runtime, and that's fine, its type system can catch
by throw_m239339 6y ago
Well Typescript is really a static code analyser for Javascript and not a language, since it does nothing at runtime, and that's fine, its type system can catch a broad range of issues and improve code quality drastically. It's a huge godsend for big codebases. But afaik it doesn't guard against null by default.
A simpler example:
declare type Foo = {name:String};
declare function getFoo():Foo|null;
const f = getFoo();
if(f!==null) // mandatory or yields an error
console.log(f.name);
But afaik it doesn't guard against null by default.