Skip to content

Instantly share code, notes, and snippets.

Created May 15, 2022 23:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bennycode/3443627bfab762dd5fa3e200513d9345 to your computer and use it in GitHub Desktop.
Generic Types and Inheritance in TypeScript
interface User {
name: string;
interface HappyUser extends User {
clap: () => void;
function printName<T extends User>(someone: T): T {
return someone;
const benny: HappyUser = {
name: 'Benny',
clap: (): void => {
const person = printName(benny);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment