0

I have a class as below.

export class Cars implements Vehicales {
    color?: string;
    type?: string[];
}

Due to some reason I cannot modify my above export object. And the templates object is passed to kendoReactGrid where it contains all the strings for the columns and I need to add it inside my interface only and not the export object.

I have an interface as below

interface CarpProps {
    templates: Cars[]
}

Now I want to add an additional property tyreCount: string[] to my templates object. How can i do that in typescript interface? I tried during extends keyword but was not successfull. I am new to typescript any help would be appreciated.

1 Answer 1

1

You can use the extends keyword instead of implements and add the additional property by creating Cards as an interface too

export interface Cars extends Vehicales {
    color?: string;
    type?: string[];
    tyreCount: string[]
}

and use it like

interface CarpProps {
    templates: Cars[]
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your reply but due to some reason I cannot modify my export object. And the templates object is passed to kendoReactGrid where it contains all the strings for the columns and I need to add it inside my templates - interface only and not the export object. Is there any work around for this....to add new property to interface?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.