Skip to content

Instantly share code, notes, and snippets.

@41y08h
Created November 3, 2021 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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