From 1587b6a774cec4d78fb19a7a72a86b70fd6e46ba Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 22 Apr 2024 07:52:50 -0700 Subject: [PATCH] Updated FAQ (markdown) --- FAQ.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/FAQ.md b/FAQ.md index e1e6db61..bd8a0487 100644 --- a/FAQ.md +++ b/FAQ.md @@ -389,6 +389,17 @@ This flag is a "big hammer", so to speak, and does not have any mechanisms for d ### Require Properties to Either Be Missing or Not `undefined`: `exactOptionalPropertyTypes` You can turn on `exactOptionalPropertyTypes` to change the behavior such that an optional property can't be explicitly provided with the value `undefined`. +This has important effects on things like object spread: +```ts +type Foo = { bar: number }; +const base: Foo = { bar: 42 }; +// Somewhat-suspect initialization of Partial +const partial: Partial = { bar: undefined }; + +// If using spread, the 'undefined' value can be present +// at Foo.bar +const possiblyBad: Foo = { ...base, ...partial }; +``` This flag affects *all* optional properties and there is no mechanism for doing this on a per-type basis.