diff --git a/pages/Basic Types.md b/pages/Basic Types.md index 0d40b5f2e..fab64ba57 100644 --- a/pages/Basic Types.md +++ b/pages/Basic Types.md @@ -190,6 +190,27 @@ Declaring variables of type `void` is not useful because you can only assign `un let unusable: void = undefined; ``` +# Null and Undefined + +In TypeScript, both `undefined` and `null` actually have their own types named `undefined` and `null` respectively. +Much like `void`, they're not extremely useful on their own: + +```ts +// Not much else we can assign to these variables! +let u: undefined = undefined; +let n: null = null; +``` + +By default `null` and `undefined` are subtypes of all other types. +That means you can assign `null` and `undefined` to something like `number`. + +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. + +> As a note: we encourage the use of `--strictNullChecks` when possible, but for the purposes of this handbook, we will assume it is turned off. + # Type assertions Sometimes you'll end up in a situation where you'll know more about a value than TypeScript does. diff --git a/pages/Compiler Options in MSBuild.md b/pages/Compiler Options in MSBuild.md index e918a8184..b162f3030 100644 --- a/pages/Compiler Options in MSBuild.md +++ b/pages/Compiler Options in MSBuild.md @@ -80,7 +80,7 @@ Compiler Option | MSBuild Property Name `--suppressImplicitAnyIndexErrors` | TypeScriptSuppressImplicitAnyIndexErrors | boolean `--target` | TypeScriptTarget | `ES3`, `ES5`, or `ES6` `--traceResolution` | *Not supported in MSBuild* | -`--types` | *Not supported in MSBuild* | +`--types` | *Not supported in MSBuild* | `--typeRoots` | *Not supported in MSBuild* | `--watch` | *Not supported in MSBuild* | *MSBuild only option* | TypeScriptAdditionalFlags | *Any compiler option*