Skip to content

Instantly share code, notes, and snippets.

@maslade
Last active March 24, 2021 23:58
Show Gist options
  • Save maslade/d68d7c6d1b3e0f3167e45778dddd7ef3 to your computer and use it in GitHub Desktop.
Save maslade/d68d7c6d1b3e0f3167e45778dddd7ef3 to your computer and use it in GitHub Desktop.
// not great
interface IGenericRequest {
requestId: string;
}
interface IGetUserRequest extends IGenericRequest {
username: string;
}
function handler(request: IGenericRequest) {
const getUserRequest = request as IGetUserRequest;
if (getUserRequest.username && getUserRequest.username.length > 0) {
const username = getUserRequest.username;
// ...the rest of the handler...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment