Hacker News new | ask | show | jobs
by ChrisSD 2015 days ago
The character count isn't the important point.

The point is that there's no way to use a `Option<File>` type as a `File` without first checking for null. And once you do get a `File` you know that from then on it can't be null.

On the other hand, using a nullable `File` requires that you remember the null check. And that you remember it for every function that takes a `File`. Yes, that last part shouldn't be necessary with sufficient care but historically people do make mistakes that go unnoticed when refactoring or generally just editing code or reusing functions in large projects.

1 comments

But it doesn't require "remembering" the null check since TypeScript will error when you try to access a member of a nullable value?