diff --git a/src/test/regression.spec.ts b/src/test/regression.spec.ts index ddcf179eb..c7e74c421 100644 --- a/src/test/regression.spec.ts +++ b/src/test/regression.spec.ts @@ -17,6 +17,17 @@ const exec = createExecTester({ }), }); +test('#2076 regression test', async () => { + const r = await exec({ + exec: createExec({ + cwd: join(TEST_DIR, '2076'), + }), + cmd: `${CMD_TS_NODE_WITHOUT_PROJECT_FLAG} --showConfig`, + }); + + exp(r.err).toBeNull(); +}); + test('#1488 regression test', async () => { // Scenario that caused the bug: // `allowJs` turned on diff --git a/src/ts-compiler-types.ts b/src/ts-compiler-types.ts index 9077d4f99..a69909fda 100644 --- a/src/ts-compiler-types.ts +++ b/src/ts-compiler-types.ts @@ -99,7 +99,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?: ( diff --git a/src/ts-internals.ts b/src/ts-internals.ts index e438c812c..88d9a9feb 100644 --- a/src/ts-internals.ts +++ b/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'; @@ -55,6 +55,7 @@ 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'), @@ -62,7 +63,8 @@ function createTsInternalsUncached(_ts: TSCommon) { 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; diff --git a/tests/2076/node_modules/custom-tsconfig/tsconfig.json b/tests/2076/node_modules/custom-tsconfig/tsconfig.json new file mode 100644 index 000000000..0c1a273fd --- /dev/null +++ b/tests/2076/node_modules/custom-tsconfig/tsconfig.json @@ -0,0 +1,3 @@ +{ + "ts-node": {} +} diff --git a/tests/2076/tsconfig.json b/tests/2076/tsconfig.json new file mode 100644 index 000000000..d64b3db67 --- /dev/null +++ b/tests/2076/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "custom-tsconfig/tsconfig.json" +}