According to the documentation Null and Undefined are assignable to void.
However, when using the --strictNullChecks flag, null and undefined are only assignable to void and their respective types. This helps avoid many common errors. In cases where you want to pass in either a string or null or undefined, you can use the union type string | null | undefined. Once again, more on union types later on.
Bun in my experience only undefined is actually assignable to void:
TypeScript Version: 2.3
Code
let thing: void = null; // <- Type 'null' is not assignable to type 'void'.
Expected behavior:
I would expect null to be assignable to void. It makes for void to be just a union type void = null | undefined otherwise it's just an alias for undefined.
Actual behavior:
Only undefined is assignable to void.
According to the documentation Null and Undefined are assignable to
void.Bun in my experience only
undefinedis actually assignable tovoid:TypeScript Version: 2.3
Code
Expected behavior:
I would expect
nullto be assignable tovoid. It makes forvoidto be just a uniontype void = null | undefinedotherwise it's just an alias forundefined.Actual behavior:
Only
undefinedis assignable tovoid.