-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(types):
ExactOptionalPropertyTypes
Signed-off-by: Lexus Drumgold <[email protected]>
- Loading branch information
1 parent
0999e72
commit 6a8cb77
Showing
3 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* @file Type Definitions - ExactOptionalPropertyTypes | ||
* @module tutils/types/ExactOptionalPropertyTypes | ||
*/ | ||
|
||
import type ObjectPlain from './object-plain' | ||
|
||
/** | ||
* Removes `undefined` from optional properties. | ||
* | ||
* This is a workaround for [`Microsoft/TypeScript#46969`][1]. | ||
* | ||
* [1]: https://github.com/Microsoft/TypeScript/issues/46969 | ||
*/ | ||
type ExactOptionalPropertyTypes<T extends ObjectPlain> = { | ||
[K in keyof T]: Exclude<T[K], undefined> extends never | ||
? T[K] | ||
: Exclude<T[K], undefined> | ||
} & {} | ||
|
||
export type { ExactOptionalPropertyTypes as default } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters