Note: Typescript is a compiled language, it cannot run directly on the browser and Nodejs.
let first_name: string = "Abdul"
let last_name: string = "Fattah"
let age: number = 20
function getFullName(first: string, last: string) {
return `${first_name} ${last_name}`
}
getFullName(first_name, last_name)
getFullName(first_name, age) // error
interface IBaseEntity {
id: number
}
interface IUser extends IBaseEntity {
first_name: string
last_name: string
}
See on the TypeScript Playground
TypeScript: Documentation - Utility Types (typescriptlang.org)
The most commonly used and we will use the first three of them in this project:
Partial<Type>
Pick<Type, Keys>
Omit<Type, Keys>
Required<Type>
Record<Keys, Type>