Closed svallory closed 3 years ago
I'm using the latest version of ts-morph, Node 16, and typescript 4.3.5
Here's the source code of the class file
import React from 'react'; export class ClassComp extends React.Component {}
And here's the test code:
let exportedClasses: ClassDeclaration[] = project .getSourceFiles() .flatMap((file) => file.getClasses()) .filter((c) => c.isExported()); console.log(`Found ${exportedClasses.length} exported classes`); exportedClasses.forEach((c) => { console.log( ` Checking class ${c.getName()} base types count: ${c.getBaseTypes().length} Base class: ${c.getBaseClass()} Extends: ${c.getExtends().getText()}`, ); });
Output:
Found 1 exported classes Checking class ClassComp base types count: 0 Base class: undefined Extends: React.Component
@svallory I think you accidentally logged an issue in the wrong repository.
Try checking project.getPreEmitDiagnostics() for any compile errors.
project.getPreEmitDiagnostics()
😂 Yep! Wrong repo indeed! But thanks for the answer anyways!
I'm using the latest version of ts-morph, Node 16, and typescript 4.3.5
Here's the source code of the class file
And here's the test code:
Output: