From a6cf32aed1f13f931b05a80c74336e429309704d Mon Sep 17 00:00:00 2001 From: Sunny Hirai Date: Fri, 3 Jun 2022 18:02:05 -0700 Subject: [PATCH] Clarify documentation around optional and strictNullChecks --- docs/guides/06-using-typescript.md | 2 +- docs/reference/types.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/guides/06-using-typescript.md b/docs/guides/06-using-typescript.md index 0374490f..f779efe9 100644 --- a/docs/guides/06-using-typescript.md +++ b/docs/guides/06-using-typescript.md @@ -2,7 +2,7 @@ Superstruct is built with TypeScript, and is designed to integrate seamlessly with its guards and assertions. Which means that if you're using TypeScript too you'll get compile-time typings for your data. -> 🤖 Warning: If you are not using TypeScript's [`strictNullChecks`](https://www.typescriptlang.org/tsconfig#strictNullChecks) option, Superstruct will be unable to infer your "optional" types correctly and will mark all types as optional. +> 🤖 Warning: You must enable TypeScript's [`strictNullChecks`](https://www.typescriptlang.org/tsconfig#strictNullChecks) option in your `tsconfig.json` for Superstruct to work properly with "optional" types. Note that `strictNullChecks` is disabled by default. If you enable `strict`, `strictNullChecks` will automatically be enabled. ## Narrowing Types diff --git a/docs/reference/types.md b/docs/reference/types.md index 5d65b475..4d36ef87 100644 --- a/docs/reference/types.md +++ b/docs/reference/types.md @@ -244,6 +244,8 @@ undefined `optional` structs validate that a value matches a specific struct, or that it is `undefined`. +> 🤖 Warning: If you are using TypeScript, you must enable TypeScript's [`strictNullChecks`](https://www.typescriptlang.org/tsconfig#strictNullChecks) option in your `tsconfig.json` for Superstruct to work properly with "optional" types. Note that `strictNullChecks` is disabled by default. If you enable `strict`, `strictNullChecks` will automatically be enabled. + ### `record` ```ts