5 ms·
If it's just one property, you could specify it's optional using a question mark instead of creating an additional type: type Foo = { Hello: string;
by wildpeaks 6y ago
If it's just one property, you could specify it's optional using a question mark instead of creating an additional type:
type Foo = {
Hello: string;
Bar?: string;
};
But if you really need separated types, the extension syntax is so short that you could define it in the function definition directly:
type Foo = {
Hello: string;
};
function hello(myparam: Foo) {}
function world(myparam: Foo & {Bar: string}) {}