TypeScript strictNullChecksについて

strictNullChecksがfalseの場合、すべての型にnullもしくはundefinedを入れることができます。

type Hoge = string
const str1: Hoge = null //エラーにならない
const str2: Hoge = undefined //エラーにならない

strictNullChecksをtrueにすると、明示的にnullやundefinedを型に指定しない限りエラーになります。

type Hoge = string
const str1: Hoge = null //エラーにならない
const str2: Hoge = undefined //エラーにならない

TypeScript Playground はデフォルトでtrueなのでご注意ください。

https://www.typescriptlang.org/play