From d9fc987044a7127cfc8ccff6d3290701717050d5 Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Mon, 6 Jun 2022 20:19:29 -0400 Subject: [PATCH] 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 --- src/get-options-overrides.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/get-options-overrides.ts b/src/get-options-overrides.ts index 5ce97798..9634122f 100644 --- a/src/get-options-overrides.ts +++ b/src/get-options-overrides.ts @@ -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; }