(
program: ts.Program,
classDeclaration: ts.ClassDeclaration,
generate: (program: ts.Program, classDeclaration: ts.ClassDeclaration) => ts.SourceFile
)
| 60 | } |
| 61 | |
| 62 | export function generateClass( |
| 63 | program: ts.Program, |
| 64 | classDeclaration: ts.ClassDeclaration, |
| 65 | generate: (program: ts.Program, classDeclaration: ts.ClassDeclaration) => ts.SourceFile |
| 66 | ) { |
| 67 | const sourceFileName = path.relative( |
| 68 | path.join(path.dirname(program.getCompilerOptions().configFilePath as string), 'src'), |
| 69 | path.resolve(classDeclaration.getSourceFile().fileName) |
| 70 | ); |
| 71 | |
| 72 | const result = generate(program, classDeclaration); |
| 73 | const defaultClass = result.statements.find( |
| 74 | stmt => |
| 75 | (ts.isClassDeclaration(stmt) || ts.isInterfaceDeclaration(stmt)) && |
| 76 | stmt.modifiers!.find(m => m.kind === ts.SyntaxKind.ExportKeyword) |
| 77 | ) as ts.DeclarationStatement; |
| 78 | |
| 79 | const targetFileName = path.join(path.dirname(sourceFileName), `${defaultClass.name!.text}.ts`); |
| 80 | |
| 81 | generateFile(program, result, targetFileName); |
| 82 | } |
| 83 | |
| 84 | export default function createEmitter( |
| 85 | jsDocMarker: string, |
no test coverage detected