Make the TypeScript interface partially optional/required | pawelgrzybek.com
interface Dude {
name: string;
age: number;
}
type DudeAllOptional = Partial<Dude>;
// name and age are optional
const dan: DudeAllOptional = {};
interface Dude {
name: string;
age?: number;
}
type DudeAllRequired = Required<Dude>; // all required
etc...
No comments:
Post a Comment