refactor: invert another if for readabilty -- in get-options (#348)

- 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
This commit is contained in:
Anton Gilgur 2022-06-06 20:19:29 -04:00 committed by GitHub
parent 4a0c2977f8
commit d9fc987044
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}