Tutorial by Examples

By default, all types in TypeScript allow null: function getId(x: Element) { return x.id; } getId(null); // TypeScript does not complain, but this is a runtime error. TypeScript 2.0 adds support for strict null checks. If you set --strictNullChecks when running tsc (or set this flag in you...
The non-null assertion operator, !, allows you to assert that an expression isn't null or undefined when the TypeScript compiler can't infer that automatically: type ListNode = { data: number; next?: ListNode; }; function addNext(node: ListNode) { if (node.next === undefined) { nod...

Page 1 of 1