Optional parent properties interface
up vote
1
down vote
favorite
I need to create an object from an interface which extends from another interface, but I need to set all the parents' properties and they are a lot of. Is it possible to make them optional?
Example:
interface Auto
radio: any;
interface Mazda extends Auto
// mazda properties
const m = <Mazda>
// just mazda properties
Actually I need that the parent properties mappend on the son to be optional, with Partial would be needed to create a property containing a parent object, but I want to extend and to have all the extended properties as optional.
typescript interface
add a comment |
up vote
1
down vote
favorite
I need to create an object from an interface which extends from another interface, but I need to set all the parents' properties and they are a lot of. Is it possible to make them optional?
Example:
interface Auto
radio: any;
interface Mazda extends Auto
// mazda properties
const m = <Mazda>
// just mazda properties
Actually I need that the parent properties mappend on the son to be optional, with Partial would be needed to create a property containing a parent object, but I want to extend and to have all the extended properties as optional.
typescript interface
Partial<Auto> & Pick<Mazda, Exclude<keyof Mazda, keyof Auto>>
?
– jcalz
Nov 8 at 20:22
Possible duplicate of Make all properties within a Typescript interface optional
– Heretic Monkey
Nov 8 at 20:22
I think if you want a more meaningful answer, you'll need to flesh this question out into a full Minimal, Complete, and Verifiable example, including how you intend to use the type.
– jcalz
Nov 9 at 0:33
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I need to create an object from an interface which extends from another interface, but I need to set all the parents' properties and they are a lot of. Is it possible to make them optional?
Example:
interface Auto
radio: any;
interface Mazda extends Auto
// mazda properties
const m = <Mazda>
// just mazda properties
Actually I need that the parent properties mappend on the son to be optional, with Partial would be needed to create a property containing a parent object, but I want to extend and to have all the extended properties as optional.
typescript interface
I need to create an object from an interface which extends from another interface, but I need to set all the parents' properties and they are a lot of. Is it possible to make them optional?
Example:
interface Auto
radio: any;
interface Mazda extends Auto
// mazda properties
const m = <Mazda>
// just mazda properties
Actually I need that the parent properties mappend on the son to be optional, with Partial would be needed to create a property containing a parent object, but I want to extend and to have all the extended properties as optional.
typescript interface
typescript interface
edited Nov 19 at 20:42
asked Nov 8 at 20:18
Julian Torregrosa
13612
13612
Partial<Auto> & Pick<Mazda, Exclude<keyof Mazda, keyof Auto>>
?
– jcalz
Nov 8 at 20:22
Possible duplicate of Make all properties within a Typescript interface optional
– Heretic Monkey
Nov 8 at 20:22
I think if you want a more meaningful answer, you'll need to flesh this question out into a full Minimal, Complete, and Verifiable example, including how you intend to use the type.
– jcalz
Nov 9 at 0:33
add a comment |
Partial<Auto> & Pick<Mazda, Exclude<keyof Mazda, keyof Auto>>
?
– jcalz
Nov 8 at 20:22
Possible duplicate of Make all properties within a Typescript interface optional
– Heretic Monkey
Nov 8 at 20:22
I think if you want a more meaningful answer, you'll need to flesh this question out into a full Minimal, Complete, and Verifiable example, including how you intend to use the type.
– jcalz
Nov 9 at 0:33
Partial<Auto> & Pick<Mazda, Exclude<keyof Mazda, keyof Auto>>
?– jcalz
Nov 8 at 20:22
Partial<Auto> & Pick<Mazda, Exclude<keyof Mazda, keyof Auto>>
?– jcalz
Nov 8 at 20:22
Possible duplicate of Make all properties within a Typescript interface optional
– Heretic Monkey
Nov 8 at 20:22
Possible duplicate of Make all properties within a Typescript interface optional
– Heretic Monkey
Nov 8 at 20:22
I think if you want a more meaningful answer, you'll need to flesh this question out into a full Minimal, Complete, and Verifiable example, including how you intend to use the type.
– jcalz
Nov 9 at 0:33
I think if you want a more meaningful answer, you'll need to flesh this question out into a full Minimal, Complete, and Verifiable example, including how you intend to use the type.
– jcalz
Nov 9 at 0:33
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53215520%2foptional-parent-properties-interface%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Partial<Auto> & Pick<Mazda, Exclude<keyof Mazda, keyof Auto>>
?– jcalz
Nov 8 at 20:22
Possible duplicate of Make all properties within a Typescript interface optional
– Heretic Monkey
Nov 8 at 20:22
I think if you want a more meaningful answer, you'll need to flesh this question out into a full Minimal, Complete, and Verifiable example, including how you intend to use the type.
– jcalz
Nov 9 at 0:33