diff --git a/src/configuration.ts b/src/configuration.ts index fb1591b92..8acff0503 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -94,6 +94,7 @@ export function readConfig( readFile = ts.sys.readFile, skipProject = DEFAULTS.skipProject, project = DEFAULTS.project, + tsTrace = DEFAULTS.tsTrace, } = rawApiOptions; // Read project configuration when available. @@ -137,7 +138,7 @@ export function readConfig( readDirectory: ts.sys.readDirectory, readFile, useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames, - trace: rawApiOptions.trace, + trace: tsTrace, }, bp, errors, @@ -276,7 +277,6 @@ function filterRecognizedTsConfigTsNodeOptions( scopeDir, moduleTypes, experimentalReplAwait, - trace, swc, ...unrecognized } = jsonObject as TsConfigOptions; @@ -300,7 +300,6 @@ function filterRecognizedTsConfigTsNodeOptions( scope, scopeDir, moduleTypes, - trace, swc, }; // Use the typechecker to make sure this implementation has the correct set of properties diff --git a/src/index.ts b/src/index.ts index ec2122337..b3506a4cd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -354,11 +354,11 @@ export interface CreateOptions { */ optionBasePaths?: OptionBasePaths; /** - * A function to collect trace messages, for example when `traceResolution` is enabled. + * A function to collect trace messages from the TypeScript compiler, for example when `traceResolution` is enabled. * - * @default console.log.bind(console) + * @default console.log */ - trace?: (str: string) => void; + tsTrace?: (str: string) => void; } /** @internal */ @@ -395,6 +395,7 @@ export interface TsConfigOptions | 'cwd' | 'projectSearchDir' | 'optionBasePaths' + | 'tsTrace' > {} /** @@ -430,7 +431,7 @@ export const DEFAULTS: RegisterOptions = { compilerHost: yn(env.TS_NODE_COMPILER_HOST), logError: yn(env.TS_NODE_LOG_ERROR), experimentalReplAwait: yn(env.TS_NODE_EXPERIMENTAL_REPL_AWAIT) ?? undefined, - trace: console.log.bind(console), + tsTrace: console.log.bind(console), }; /** @@ -890,7 +891,7 @@ export function create(rawOptions: CreateOptions = {}): Service { getCompilationSettings: () => config.options, getDefaultLibFileName: () => ts.getDefaultLibFilePath(config.options), getCustomTransformers: getCustomTransformers, - trace: options.trace, + trace: options.tsTrace, }; const { resolveModuleNames, @@ -899,7 +900,7 @@ export function create(rawOptions: CreateOptions = {}): Service { isFileKnownToBeInternal, markBucketOfFilenameInternal, } = createResolverFunctions({ - serviceHost, + host: serviceHost, getCanonicalFileName, ts, cwd, @@ -1044,13 +1045,14 @@ export function create(rawOptions: CreateOptions = {}): Service { ), useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames, }; + host.trace = options.tsTrace; const { resolveModuleNames, resolveTypeReferenceDirectives, isFileKnownToBeInternal, markBucketOfFilenameInternal, } = createResolverFunctions({ - serviceHost: host, + host, cwd, configFilePath, config, @@ -1065,7 +1067,7 @@ export function create(rawOptions: CreateOptions = {}): Service { ? ts.createIncrementalProgram({ rootNames: Array.from(rootFileNames), options: config.options, - host: host, + host, configFileParsingDiagnostics: config.errors, projectReferences: config.projectReferences, }) diff --git a/src/resolver-functions.ts b/src/resolver-functions.ts index e76528155..df7db9aab 100644 --- a/src/resolver-functions.ts +++ b/src/resolver-functions.ts @@ -7,14 +7,14 @@ import type * as _ts from 'typescript'; */ export function createResolverFunctions(kwargs: { ts: typeof _ts; - serviceHost: _ts.ModuleResolutionHost; + host: _ts.ModuleResolutionHost; cwd: string; getCanonicalFileName: (filename: string) => string; config: _ts.ParsedCommandLine; configFilePath: string | undefined; }) { const { - serviceHost, + host, ts, config, cwd, @@ -93,7 +93,7 @@ export function createResolverFunctions(kwargs: { moduleName, containingFile, config.options, - serviceHost, + host, moduleResolutionCache, redirectedReference ); @@ -132,7 +132,7 @@ export function createResolverFunctions(kwargs: { typeDirectiveName, containingFile, config.options, - serviceHost, + host, redirectedReference ); if (typeDirectiveName === 'node' && !resolvedTypeReferenceDirective) { @@ -157,7 +157,7 @@ export function createResolverFunctions(kwargs: { ...config.options, typeRoots, }, - serviceHost, + host, redirectedReference )); } diff --git a/src/test/repl/helpers.ts b/src/test/repl/helpers.ts index a75159fcd..310b8e221 100644 --- a/src/test/repl/helpers.ts +++ b/src/test/repl/helpers.ts @@ -45,7 +45,7 @@ export async function contextReplHelpers( ...replService.evalAwarePartialHost, project: `${TEST_DIR}/tsconfig.json`, ...createServiceOpts, - trace: replService.console.log.bind(replService.console), + tsTrace: replService.console.log.bind(replService.console), }); replService.setService(service); t.teardown(async () => {