Reputation: 220
export interface example {
book:{
first:number;
second:string;
}
}
interface table extends example{
book:{
third:null
}
}
Is it possible to extend same object in typescript ? in some case I only want to use example case without book third
Upvotes: 0
Views: 346
Reputation: 17400
Why not just make third
an optional property in the example
interface?
export interface example {
book:{
first:number;
second:string;
third?: null;
}
}
If you really need to extend example
interface, you have to make the types compatible, ie the extended book
needs at least all the properties, the base interface has ...
export interface example {
book:{
first:number;
second:string;
}
}
interface table extends example{
book:{
first: number;
second: string;
third:null
}
}
Upvotes: 2