| 7 | |
| 8 | export type FileItem = AnyDeclarationBuilder | Export<any> | ExportFrom |
| 9 | export class File implements BasicBuilder { |
| 10 | private imports: Import[] = [] |
| 11 | private declarations: FileItem[] = [] |
| 12 | |
| 13 | addImport(moduleImport: Import) { |
| 14 | this.imports.push(moduleImport) |
| 15 | return this |
| 16 | } |
| 17 | add(declaration: FileItem) { |
| 18 | this.declarations.push(declaration) |
| 19 | } |
| 20 | |
| 21 | write(writer: Writer<undefined>): void { |
| 22 | for (const moduleImport of this.imports) { |
| 23 | writer.writeLine(moduleImport) |
| 24 | } |
| 25 | if (this.imports.length > 0) { |
| 26 | writer.newLine() |
| 27 | } |
| 28 | for (const [i, declaration] of this.declarations.entries()) { |
| 29 | writer.writeLine(declaration) |
| 30 | if (i < this.declarations.length - 1) { |
| 31 | writer.newLine() |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | export function file(): File { |
| 38 | return new File() |
nothing calls this directly
no outgoing calls
no test coverage detected