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
/****************************************************************************** | |
* Implementation of `Nonempty` validator which checks that the provided type | |
* has at least one defined property, excluding `{}`. | |
******************************************************************************/ | |
type Nonempty<T extends { [key: string]: any }> = { [P in keyof T]: T }[keyof T]; | |
declare function wantsNonempty<T extends { [key: string]: any }>(x: Nonempty<T>): true; | |
wantsNonempty({ x: 1 }); | |
wantsNonempty({}); // error expected |