From b31233691138607462b43ecc8c78dd72436166ed Mon Sep 17 00:00:00 2001 From: Kostis Maninakis Date: Fri, 10 Feb 2023 11:38:58 +0100 Subject: [PATCH] feat(xor): show derived types instead of type names on hover --- src/types/Prettify.type.ts | 7 +++++++ src/types/Xor.type.ts | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/types/Prettify.type.ts diff --git a/src/types/Prettify.type.ts b/src/types/Prettify.type.ts new file mode 100644 index 0000000..9012eab --- /dev/null +++ b/src/types/Prettify.type.ts @@ -0,0 +1,7 @@ +/** + * Resolve mapped types and show the derived keys and their types when hovering in + * VS Code, instead of just showing the names those mapped types are defined with. + */ +export type Prettify = { + [K in keyof T]: T[K] +} & {} diff --git a/src/types/Xor.type.ts b/src/types/Xor.type.ts index 32bb07d..2494b8b 100644 --- a/src/types/Xor.type.ts +++ b/src/types/Xor.type.ts @@ -1,3 +1,4 @@ +import { Prettify } from './Prettify.type' import { Without } from './Without.type' /** @@ -11,5 +12,5 @@ import { Without } from './Without.type' * More: https://github.com/maninak/ts-xor/tree/master#description */ export type XOR = (T | U) extends object - ? (Without & U) | (Without & T) + ? (Prettify & U>) | (Prettify & T>) : T | U