Skip to content

Commit 9b07104

Browse files
committed
feat: warn if outDir or declarationDir are specified in tsconfig
1 parent 5b2503a commit 9b07104

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/targets/typescript.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,33 @@ export default async function build({ root, output, report }: Input) {
1313
report.info(`Generating type definitions with ${chalk.blue('tsc')}`);
1414

1515
const tsc = path.join(root, 'node_modules', '.bin', 'tsc');
16+
const tsconfig = path.join(root, 'tsconfig.json');
1617

1718
try {
19+
if (await fs.pathExists(tsconfig)) {
20+
const config = JSON.parse(await fs.readFile(tsconfig, 'utf-8'));
21+
22+
if (config.compilerOptions) {
23+
if (config.compilerOptions.outDir) {
24+
report.warn(
25+
`Found ${chalk.blue('compilerOptions.outDir')} in ${chalk.blue(
26+
'tsconfig.json'
27+
)} which can conflict with the CLI options. It's recommended to remove it from the config file.`
28+
);
29+
}
30+
31+
if (config.compilerOptions && config.compilerOptions.declarationDir) {
32+
report.warn(
33+
`Found ${chalk.blue(
34+
'compilerOptions.declarationDir'
35+
)} in ${chalk.blue(
36+
'tsconfig.json'
37+
)} which can conflict with the CLI options. It's recommended to remove it from the config file.`
38+
);
39+
}
40+
}
41+
}
42+
1843
if (await fs.pathExists(tsc)) {
1944
child_process.execFileSync(tsc, [
2045
'--declaration',

0 commit comments

Comments
 (0)