| 61 | |
| 62 | // tsc does not emit the hand-written declaration files |
| 63 | async function copyDeclarationFiles(project: string) { |
| 64 | // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion |
| 65 | const { include: projectFiles } = JSON5.parse( |
| 66 | readFileSync(resolvePath(project, "tsconfig.json"), "utf8") |
| 67 | ) as { include?: string[] }; |
| 68 | if (!projectFiles) return; |
| 69 | const globPatterns = projectFiles |
| 70 | .filter(file => file.endsWith("*.ts")) |
| 71 | .map( |
| 72 | file => `${project}/${file.slice(0, -3)}*.d.ts`.replace(/\\/g, "/") // glob doesn't support \ on Windows |
| 73 | ); |
| 74 | const files = glob(globPatterns); |
| 75 | for await (const file of files) { |
| 76 | const out = joinPath( |
| 77 | process.cwd(), |
| 78 | "dts", |
| 79 | relativePath(process.cwd(), file) |
| 80 | ); |
| 81 | mkdirSync(dirname(out), { recursive: true }); |
| 82 | copyFileSync(file, out); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | if (process.env.TSCHECK_EMIT_ONLY) { |
| 87 | // Without type checking, a single `tsc -b` that shares the parsed files |