Skip to content

Commit

Permalink
refactor(paths): move var declaration to where its used
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Jun 23, 2024
1 parent d8056ec commit 232838b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/paths-matcher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ const parsePaths = (
export const createPathsMatcher = (
tsconfig: TsConfigResult,
) => {
if (!tsconfig.config.compilerOptions) {
const { compilerOptions } = tsconfig.config;
if (!compilerOptions) {
return null;
}

const { baseUrl, paths } = tsconfig.config.compilerOptions;
const implicitBaseUrl = (
implicitBaseUrlSymbol in tsconfig.config.compilerOptions
&& (tsconfig.config.compilerOptions[implicitBaseUrlSymbol] as string)
);
const { baseUrl, paths } = compilerOptions;
if (!baseUrl && !paths) {
return null;
}

const implicitBaseUrl = (
implicitBaseUrlSymbol in compilerOptions
&& (compilerOptions[implicitBaseUrlSymbol] as string)
);

const resolvedBaseUrl = path.resolve(
path.dirname(tsconfig.path),
baseUrl || implicitBaseUrl || '.',
Expand Down

0 comments on commit 232838b

Please sign in to comment.