I am facing an issue with my interface named "Example" which has a function type called "exampleFunction". The problem arises when this function takes a super class as an input parameter because TypeScript is reporting an error. It states that I cannot use subtypes as inputs due to some properties that are not present in the superclass.
Here's an illustration:
interface SuperType {
propertyA: string
}
interface SubTypeA extends SuperType {
subPropertyA: number
}
interface SubTypeB extends SuperType {
subPropertyB: number
}
interface Example {
exampleFunction: (input: SuperType) => void
}
The issue occurs when I write:
const example: Example = {
exampleFunction: (input: SubTypeA) => {console.log("nothing")}
}