Skip to content

Instantly share code, notes, and snippets.

@KrishnaPravin
Created June 4, 2025 00:36
Show Gist options
  • Save KrishnaPravin/c160bdea9737eb92e19392abf12731d2 to your computer and use it in GitHub Desktop.
Save KrishnaPravin/c160bdea9737eb92e19392abf12731d2 to your computer and use it in GitHub Desktop.
Enforce caller to provide generic type, where the generic type is also used as a type of one of the params. This also prevents type inference from the caller's param type.
// Enforce caller to provide generic type, where the generic type is also used as a type of one of the params.
// This also prevents type inference from the caller's param type.
async sendMessage<T = never, P extends T = T>(
param1: string,
param2: P
) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment