Let's say there is a class called X
:
class X {
constructor();
performAction(): void;
}
Now, we have another class named Y
where we want to include an object of class X
as a property:
class Y {
xProperty: X;
}
How do we go about defining TypeScript declarations (.d.ts
) for a class Z
with a property of class X
that also includes an additional function additionalAction(): void;
?
More details
In class Z
, the modified class X
looks like this:
class X {
constructor();
performAction(): void;
additionalAction(): void;
}
I attempted to define class Z
as shown below but encountered issues:
class Z {
xProperty: X | { additionalAction(): void; };
}