Skip to content

Commit 57d186c

Browse files
committed
fix: tsconfig not found with TS >= 5.3
Fixes 2076
1 parent c06cbe7 commit 57d186c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/ts-compiler-types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ export interface TSInternal {
9090
host: _ts.ModuleResolutionHost,
9191
cache?: _ts.ModuleResolutionCache,
9292
redirectedReference?: _ts.ResolvedProjectReference,
93-
lookupConfig?: boolean
93+
conditionsOrIsConfigLookup?: string[] | boolean, // `conditions` parameter added in TS 5.3
94+
isConfigLookup?: boolean
9495
): _ts.ResolvedModuleWithFailedLookupLocations;
9596
// Added in TS 4.7
9697
getModeForFileReference?: (

src/ts-internals.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { isAbsolute, resolve } from 'path';
2-
import { cachedLookup, normalizeSlashes } from './util';
2+
import { cachedLookup, normalizeSlashes, versionGteLt } from './util';
33
import type * as _ts from 'typescript';
44
import type { TSCommon, TSInternal } from './ts-compiler-types';
55

@@ -40,14 +40,16 @@ function createTsInternalsUncached(_ts: TSCommon) {
4040
return extendedConfigPath;
4141
}
4242
// If the path isn't a rooted or relative path, resolve like a module
43+
const tsGte5_3_0 = versionGteLt(ts.version, '5.3.0');
4344
const resolved = ts.nodeModuleNameResolver(
4445
extendedConfig,
4546
combinePaths(basePath, 'tsconfig.json'),
4647
{ moduleResolution: ts.ModuleResolutionKind.NodeJs },
4748
host,
4849
/*cache*/ undefined,
4950
/*projectRefs*/ undefined,
50-
/*lookupConfig*/ true
51+
/*conditionsOrIsConfigLookup*/ tsGte5_3_0 ? undefined : true,
52+
/*isConfigLookup*/ tsGte5_3_0 ? true : undefined
5153
);
5254
if (resolved.resolvedModule) {
5355
return resolved.resolvedModule.resolvedFileName;

0 commit comments

Comments
 (0)