Created
September 8, 2018 17:41
-
-
Save kasper573/c02aff5c67feb39fc74476eaec3de74b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
type QueryValue = number | string | boolean | Date; | |
type Query<T> = { | |
[P in SubTypeKeys<T, QueryValue>]?: T[P] | T[P][] | |
}; | |
type SubTypeKeys<Base, Condition> = { | |
[Key in keyof Base]: Base[Key] extends Condition ? Key : never | |
}[keyof Base]; | |
class Foo { | |
bar: string; | |
} | |
type Combination = number & {whatever: string}; | |
const value: Combination = null; | |
const query: Query<Foo> = value; // Should not be allowed |
lumie1337
commented
Sep 8, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment