MCPcopy Create free account
hub / github.com/babel/babel / copyDeclarationFiles

Function copyDeclarationFiles

scripts/parallel-tsc/tsc.ts:63–84  ·  view source on GitHub ↗
(project: string)

Source from the content-addressed store, hash-verified

61
62// tsc does not emit the hand-written declaration files
63async 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
86if (process.env.TSCHECK_EMIT_ONLY) {
87 // Without type checking, a single `tsc -b` that shares the parsed files

Callers

nothing calls this directly

Calls 4

mapMethod · 0.80
replaceMethod · 0.80
parseMethod · 0.45
endsWithMethod · 0.45

Tested by

no test coverage detected