Skip to content

Commit d9fc987

Browse files
authored
refactor: invert another if for readabilty -- in get-options (ezolenko#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
1 parent 4a0c297 commit d9fc987

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/get-options-overrides.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ export function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IO
2020
allowNonTsExtensions: true,
2121
};
2222

23-
if (preParsedTsconfig)
24-
{
25-
if (preParsedTsconfig.options.module === undefined)
26-
overrides.module = tsModule.ModuleKind.ES2015;
23+
if (!preParsedTsconfig)
24+
return overrides;
2725

28-
// only set declarationDir if useTsconfigDeclarationDir is enabled
29-
if (!useTsconfigDeclarationDir)
30-
overrides.declarationDir = undefined;
26+
if (preParsedTsconfig.options.module === undefined)
27+
overrides.module = tsModule.ModuleKind.ES2015;
3128

32-
// unsetting sourceRoot if sourceMap is not enabled (in case original tsconfig had inlineSourceMap set that is being unset and would cause TS5051)
33-
const sourceMap = preParsedTsconfig.options.sourceMap;
34-
if (!sourceMap)
35-
overrides.sourceRoot = undefined;
36-
}
29+
// only set declarationDir if useTsconfigDeclarationDir is enabled
30+
if (!useTsconfigDeclarationDir)
31+
overrides.declarationDir = undefined;
32+
33+
// unsetting sourceRoot if sourceMap is not enabled (in case original tsconfig had inlineSourceMap set that is being unset and would cause TS5051)
34+
const sourceMap = preParsedTsconfig.options.sourceMap;
35+
if (!sourceMap)
36+
overrides.sourceRoot = undefined;
3737

3838
return overrides;
3939
}

0 commit comments

Comments
 (0)