4 ms·
Typescript is nice but its type system is not the strongest selling point. For example this compiles without warnings: const foo: Promise<string|null> = Pr
by deno 10y ago
Typescript is nice but its type system is not the strongest selling point.
For example this compiles without warnings:
const foo: Promise<string|null> = Promise.resolve(null);
const bar: Promise<string> = foo;
bar.then((value) => value.toString()); // runtime null error
- coldtea 10y agoThat's because null is an acceptable value for a string object. Which is the same thing as in Java and plenty of other languages.