Hacker News new | ask | show | jobs
by dmgd 3739 days ago
you mean value types rather than primitives right? (Strings are objects)

It would be saner if everything was non null by default. There'd be no need for a ! then and no ambiguity for beginners around whether something is nullable or not. No downside for non-beginners either unless they're in the habit of using more nullable parameters/vars than non-nullable, which doesn't seem like a particularly good idea...

1 comments

Yes, value types, thank you.

Agreed on the defaults, although you then have the problem of reconciling with the native JS type system. I'm unclear on what this PR does to address that for TS - in strict null check mode, can an e.g. Node be null by default? If so, does the native "Node" object then become "Node|null"? At some level this has to be addressed.

There is no native type system.

Native objects can never be null. If its an object, it already isnt null. Functions,property accessors etc. can return Node or null or undefined, which can be modelled accordingly on a per-function basis