Skip to content

Instantly share code, notes, and snippets.

@Devcon4
Created May 3, 2018 00:42
Show Gist options
  • Select an option

  • Save Devcon4/37f263ad6bcf8f423caf94ad2b79ae6a to your computer and use it in GitHub Desktop.

Select an option

Save Devcon4/37f263ad6bcf8f423caf94ad2b79ae6a to your computer and use it in GitHub Desktop.
type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
type rule<T> = {[key in FunctionPropertyNames<T>]?: T[key] extends (args: infer U) => void ? U : never};
class rules {
ruleOne(args: {first: string, second: number}) { }
}
function ruleTwo(args: {first: number}) { }
let test: rule<rules & {ruleTwo: typeof ruleTwo}> = {
ruleOne: { first: '', second: 3 },
ruleTwo: { first: 2 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment