Skip to content

Instantly share code, notes, and snippets.

@41y08h
Created November 3, 2021 14:17
Show Gist options
  • Save 41y08h/1439f1ef6418b928f9684098f1d688fc to your computer and use it in GitHub Desktop.
Save 41y08h/1439f1ef6418b928f9684098f1d688fc to your computer and use it in GitHub Desktop.
refer to generic arguments inside a function
export default function validate<T>(schema: T) {
const {errors} = Joi.object<T>(schema); // You can use T type here
}
const validate: <T>(schema: T) => void = () => {
const {errors} = Joi.object<T>(schema); // You can't use T type here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment