Skip to content

Instantly share code, notes, and snippets.

@diegogriep
Created May 30, 2020 19:23
Show Gist options
  • Save diegogriep/80bf7623a9ba433781126ffbe745b02f to your computer and use it in GitHub Desktop.
Save diegogriep/80bf7623a9ba433781126ffbe745b02f to your computer and use it in GitHub Desktop.
interface DriverF1 {
firstName: string;
lastName: string;
}
const newDriverF1 = <T extends DriverF1>(obj: T) => {
return {
...obj,
fullName: `${obj.firstName} ${obj.lastName}`
}
}
let hamilton = newDriverF1({ firstName: 'Lewis', lastName: 'Hamilton', team: 'Mercedes' })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment