3 ms·
Modern TypeScript aims to add typings to JavaScript, so eliminating a core language primitive—even a rather appendiceal one like null—is probably out of that sc
by mattbierner 8y ago
Modern TypeScript aims to add typings to JavaScript, so eliminating a core language primitive—even a rather appendiceal one like null—is probably out of that scope, especially because some js libraries do differentiate between null and undefined.
I highly recommend using TypeScript's strict null checks mode as it makes undefined and null their own distinct types and requires that you explicitly state when a field or argument is nullable. The programming experience is somewhat similar to working with 'optional' types in languages like Scala or Swift. See the 'nullable types' section of this document for more info: https://www.typescriptlang.org/docs/handbook/advanced-types.html https://www.typescriptlang.org/docs/handbook/advanced-types....