Skip to content

Commit

Permalink
added tests + fixed missing declarationDir in excludes
Browse files Browse the repository at this point in the history
  • Loading branch information
trikadin committed Sep 11, 2024
1 parent 774fc2f commit 29381de
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/parse-tsconfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,29 @@ const _parseTsconfig = (
}
}

let { outDir } = compilerOptions;
if (outDir) {
if (!Array.isArray(config.exclude)) {
config.exclude = [];
}
const outputFields = [
'outDir',
'declarationDir'
] as const satisfies Array<keyof NonNullable<TsConfigJson['compilerOptions']>>;

if (!config.exclude.includes(outDir)) {
config.exclude.push(outDir);
}
for (const outputField of outputFields) {
let outputPath = compilerOptions[outputField];

if (!outDir.startsWith(configDirPlaceholder)) {
outDir = normalizeRelativePath(outDir);
if (outputPath) {
if (!Array.isArray(config.exclude)) {
config.exclude = [];
}

if (!config.exclude.includes(outputPath)) {
config.exclude.push(outputPath);
}

if (!outputPath.startsWith(configDirPlaceholder)) {
outputPath = normalizeRelativePath(outputPath);
}

compilerOptions[outputField] = outputPath;
}
compilerOptions.outDir = outDir;
}
} else {
config.compilerOptions = {};
Expand Down
7 changes: 7 additions & 0 deletions tests/specs/parse-tsconfig/extends/merges.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,13 @@ export default testSuite(({ describe }) => {
'tsconfig.json': createTsconfigJson({
compilerOptions: {
outDir: '${configDir}-asdf/dist',
declarationDir: '${configDir}/dist/declaration',
outFile: '${configDir}/dist/outfile.js',
rootDir: '${configDir}/dist/src',
baseUrl: '${configDir}/dist/src',
tsBuildInfoFile: '${configDir}/dist/dist.tsbuildinfo',
rootDirs: ['${configDir}/src', '${configDir}/static'],
typeRoots: ['${configDir}/src/type', '${configDir}/types'],
paths: {
a: ['${configDir}_a/*'],
b: ['ignores/${configDir}/*'],
Expand Down

0 comments on commit 29381de

Please sign in to comment.