Skip to content

Commit

Permalink
fix: tsconfig not found with TS >= 5.3
Browse files Browse the repository at this point in the history
Fixes 2076
  • Loading branch information
edosrecki committed Nov 23, 2023
1 parent c06cbe7 commit 57d186c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/ts-compiler-types.ts
Expand Up @@ -90,7 +90,8 @@ export interface TSInternal {
host: _ts.ModuleResolutionHost,
cache?: _ts.ModuleResolutionCache,
redirectedReference?: _ts.ResolvedProjectReference,
lookupConfig?: boolean
conditionsOrIsConfigLookup?: string[] | boolean, // `conditions` parameter added in TS 5.3
isConfigLookup?: boolean
): _ts.ResolvedModuleWithFailedLookupLocations;
// Added in TS 4.7
getModeForFileReference?: (
Expand Down
6 changes: 4 additions & 2 deletions src/ts-internals.ts
@@ -1,5 +1,5 @@
import { isAbsolute, resolve } from 'path';
import { cachedLookup, normalizeSlashes } from './util';
import { cachedLookup, normalizeSlashes, versionGteLt } from './util';
import type * as _ts from 'typescript';
import type { TSCommon, TSInternal } from './ts-compiler-types';

Expand Down Expand Up @@ -40,14 +40,16 @@ function createTsInternalsUncached(_ts: TSCommon) {
return extendedConfigPath;
}
// If the path isn't a rooted or relative path, resolve like a module
const tsGte5_3_0 = versionGteLt(ts.version, '5.3.0');
const resolved = ts.nodeModuleNameResolver(
extendedConfig,
combinePaths(basePath, 'tsconfig.json'),
{ moduleResolution: ts.ModuleResolutionKind.NodeJs },
host,
/*cache*/ undefined,
/*projectRefs*/ undefined,
/*lookupConfig*/ true
/*conditionsOrIsConfigLookup*/ tsGte5_3_0 ? undefined : true,
/*isConfigLookup*/ tsGte5_3_0 ? true : undefined
);
if (resolved.resolvedModule) {
return resolved.resolvedModule.resolvedFileName;
Expand Down

0 comments on commit 57d186c

Please sign in to comment.