Here is an example code snippet:
class Animal {
name: string;
}
class Dog extends Animal {
breed: string;
}
interface DataProps {
color?: string;
}
interface DogProps extends DataProps {
type?: "Beagle" | "Sheepdog";
}
When using Class
extends, you can check the names like this:
const symbol = this.checker.getSymbolAtLocation((<ts.ClassDeclaration> node).name);
const extendsDocEntry = "declarations" in symbol? symbol.declarations.map((declaration: any) => (
"expression" in declaration && declaration.expression.text
)).filter((extendsName: any) => extendsName) : void 0;
I am not entirely sure if this code is correct, and I am also unsure how to retrieve Interface
extends.
If anyone can help me solve this problem, I would greatly appreciate it.