Skip to content

Commit

Permalink
feat(xor): show derived types instead of type names on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
maninak committed Feb 10, 2023
1 parent 60f4a7e commit b312336
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/types/Prettify.type.ts
Original file line number Diff line number Diff line change
@@ -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<T> = {
[K in keyof T]: T[K]
} & {}
3 changes: 2 additions & 1 deletion src/types/Xor.type.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Prettify } from './Prettify.type'
import { Without } from './Without.type'

/**
Expand All @@ -11,5 +12,5 @@ import { Without } from './Without.type'
* More: https://github.com/maninak/ts-xor/tree/master#description
*/
export type XOR<T, U> = (T | U) extends object
? (Without<T, U> & U) | (Without<U, T> & T)
? (Prettify<Without<T, U> & U>) | (Prettify<Without<U, T> & T>)
: T | U

0 comments on commit b312336

Please sign in to comment.