Skip to content

Commit

Permalink
feat: unset declarationMap tsc option if present
Browse files Browse the repository at this point in the history
As reported in
#768 (comment),
declarationMap flag may cause the compilation to error out if
declaration is set to false. The rationale is that it would be a bad
experience if tsc succeeds but tscc fails for no apparent reason.
  • Loading branch information
theseanl committed Oct 20, 2022
1 parent d8669ba commit 61161c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/tscc/src/spec/TsccSpecWithTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@ export default class TsccSpecWithTS extends TsccSpec implements ITsccSpecWithTS
onWarning(`Incremental compilation is not supported. incremental flag is unset.`);
options.incremental = false;
}
if (options.declaration) {
// silently unset declaration flag
options.declaration = false;
}
// Silently unset flags related to declaration
options.declaration &&= false;
options.declarationMap &&= false;
}
private tsCompilerHost: ts.CompilerHost = ts.createCompilerHost(this.parsedConfig.options);
private constructor(
Expand Down
11 changes: 11 additions & 0 deletions packages/tscc/test/spec/TsccSpecWithTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ describe(`TsccSpecWithTS`, () => {
TsccSpecWithTS.pruneCompilerOptions(options2, noop);
expect(options2.target).toBeDefined();
}
});
test(`Unsets declaration and declarationMap`, () => {
{
const options: ts.CompilerOptions = {
declaration: true,
declarationMap: true
};
TsccSpecWithTS.pruneCompilerOptions(options, noop);
expect(options.declaration).toBeFalsy();
expect(options.declarationMap).toBeFalsy();
}
})
})
});
Expand Down

0 comments on commit 61161c7

Please sign in to comment.