Skip to content

Commit

Permalink
refactor: invert another if for readabilty -- in get-options (#348)
Browse files Browse the repository at this point in the history
- my previous commit was mostly focused on index.ts, this one is for
  get-options-overrides -- in general, I'm just trying to make old code
  more readable as I come across and then realize that the code can be
  re-written better, or, in this case, a conditional inverted
  • Loading branch information
agilgur5 committed Jun 7, 2022
1 parent 4a0c297 commit d9fc987
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/get-options-overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ export function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IO
allowNonTsExtensions: true,
};

if (preParsedTsconfig)
{
if (preParsedTsconfig.options.module === undefined)
overrides.module = tsModule.ModuleKind.ES2015;
if (!preParsedTsconfig)
return overrides;

// only set declarationDir if useTsconfigDeclarationDir is enabled
if (!useTsconfigDeclarationDir)
overrides.declarationDir = undefined;
if (preParsedTsconfig.options.module === undefined)
overrides.module = tsModule.ModuleKind.ES2015;

// unsetting sourceRoot if sourceMap is not enabled (in case original tsconfig had inlineSourceMap set that is being unset and would cause TS5051)
const sourceMap = preParsedTsconfig.options.sourceMap;
if (!sourceMap)
overrides.sourceRoot = undefined;
}
// only set declarationDir if useTsconfigDeclarationDir is enabled
if (!useTsconfigDeclarationDir)
overrides.declarationDir = undefined;

// unsetting sourceRoot if sourceMap is not enabled (in case original tsconfig had inlineSourceMap set that is being unset and would cause TS5051)
const sourceMap = preParsedTsconfig.options.sourceMap;
if (!sourceMap)
overrides.sourceRoot = undefined;

return overrides;
}
Expand Down

0 comments on commit d9fc987

Please sign in to comment.