-
-
Save jcalz/32e730f310bca1c0b767036813ea6745 to your computer and use it in GitHub Desktop.
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
type CustomType<K extends keyof any> = { | |
[P in K]: number | |
}; | |
type Config<K extends keyof any> = { | |
[P in K]?: { | |
highPriority: boolean; | |
callback: (values: any[]) => number[]; | |
} | |
}; | |
declare const customFunction: | |
<K extends keyof any>(values: Record<K, any>[], config: Config<K>) => Array<CustomType<K>> | |
const values = [ | |
{ | |
foo: 'foo', | |
bar: 'bar' | |
}, | |
{ | |
foo: 'foo', | |
bar: 'bar' | |
} | |
]; | |
const config = { | |
foo: { | |
highPriority: true, | |
callback: () => [] | |
}, | |
wrong: { | |
highPriority: true, | |
callback: () => [] | |
} | |
}; | |
// error as desired | |
const result = customFunction(values, config); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment