I have an interface (in the example is called "Example") that includes a function type ("exampleFunction"), but this function takes a super class as an input parameter, and typescript reports an error stating that i can't use subtypes as input because they have some properties that are not present in the super type.
Here is an example:
interface SuperType {
propertyA: string
}
interface SubTypeA extends SuperType {
subPropertyA: number
}
interface SubTypeB extends SuperType {
subPropertyB: number
}
interface Example {
exampleFunction: (input: SuperType) => void
}
i have a problem if i write:
const example: Example = {
exampleFunction: (input: SubTypeA) => {console.log("nothing")}
}