DEV Community

Mahabubur Rahman
Mahabubur Rahman

Posted on

Union and Intersection Typescript

First Type

type NobDeveloper = {
    name: string;
};
Enter fullscreen mode Exit fullscreen mode

Second Type [Intersection]

type JuniorDeveloper = NobDeveloper & {
    expertise: string;
    experience: number;
};
Enter fullscreen mode Exit fullscreen mode

[Union]

const newDeveloper: NobDeveloper | JuniorDeveloper = {
    name: "Tom Holand",
    expertise: "JS",
    experience: 5,
};
Enter fullscreen mode Exit fullscreen mode

Top comments (0)