Skip to content

Upgrading ts-node 9 to 10

Breaking9.1.1 → 10.9.2Breaking6Platform1Deprecated2New31Changed30Fixed55Other26

BreakingUpgrade verdict

6 breaking changes and a platform requirement change.

  • The option has a new name, so existing configurations using the old name must be updated.
  • ts-node now looks for tsconfig.json next to the script you run rather than in the current directory. Most projects see no difference.
  • The ignore patterns now resolve from where tsconfig.json lives, falling back to the current directory.
  • Some internal helpers are no longer exported in the type definitions; no features were removed.
Top 5 of 9 that need code or config changes

No longer states a Node.js requirement from 10.3.0 (was >=10.0.0).

Adds @cspotcode/source-map-support ^0.8.0, @tsconfig/node10 ^1.0.7, @tsconfig/node12 ^1.0.7, @tsconfig/node14 ^1.0.0, @tsconfig/node16 ^1.0.2, acorn ^8.4.1, acorn-walk ^8.1.1, v8-compile-cache-lib ^3.0.1.

Drops source-map-support.

Installs 16 packages in all (was 8).

Breaking6
Renames option experimentalResolverFeatures to experimentalResolver.
experimentalResolverFeaturesexperimentalResolver
Makes --script-mode the default, resolving tsconfig relative to the entrypoint script instead of cwd.
--script-mode
Evaluates ignore rules relative to the tsconfig.json directory, otherwise cwd.
ignore
Removes internal APIs DEFAULTS, normalizeSlashes, parse and split from type declarations.
DEFAULTSnormalizeSlashesparsesplit
Always throws ERR_REQUIRE_ESM when executing ESM as CJS, even without --loader ts-node/esm.
ERR_REQUIRE_ESM--loader ts-node/esm
Loads compiler relative to tsconfig.json instead of the entrypoint script.
compiler
Platform1
Removes support for node 10; minimum supported version is node 12.
Deprecated2
Deprecates TS_NODE_SCOPE.
TS_NODE_SCOPE
Deprecates --dir and TS_NODE_DIR.
--dirTS_NODE_DIR

Generated by DepDelta from published .d.ts files. Not mixed with prose notes.

  • added: const _process: EventEmitterInternals
  • added: const messageMatch: RegExp
  • added: function onWarning(this: any, warning: Error, ...rest: any[]): any
  • added: interface EventEmitterInternals
  • added: let originalOnWarning: Function | undefined
  • added: property EventEmitterInternals._events: Record<string, Function | Array<Function>>
  • removed: function registerAndCreateEsmHooks(opts?: RegisterOptions): { resolve: (specifier: string, context: { parentURL: string }, defaultResolve: any) => Promise<{ url: string }>; getFormat: (url: string, context: {}, defaultGetFormat: any) => Promise<{ format: 'module' | 'json' | 'builtin' | 'commonjs' | 'dynamic' | 'wasm' }>; transformSource: (source: string | Buffer, context: { url: string; format: '…
  • added: function createEsmHooks(tsNodeService: Service): NodeLoaderHooksAPI1 | NodeLoaderHooksAPI2
  • added: interface NodeImportAssertions
  • added: interface NodeLoaderHooksAPI1
  • added: interface NodeLoaderHooksAPI2
  • added: interface NodeLoaderHooksAPI2.NodeImportAssertions
  • added: namespace NodeLoaderHooksAPI1
  • added: namespace NodeLoaderHooksAPI2
  • added: property NodeImportAssertions.type?: 'json'
  • added: property NodeLoaderHooksAPI1.getFormat: NodeLoaderHooksAPI1.GetFormatHook
  • added: property NodeLoaderHooksAPI1.resolve: NodeLoaderHooksAPI1.ResolveHook
  • added: property NodeLoaderHooksAPI1.transformSource: NodeLoaderHooksAPI1.TransformSourceHook
  • added: property NodeLoaderHooksAPI2.NodeImportAssertions.type?: 'json'
  • added: property NodeLoaderHooksAPI2.load: NodeLoaderHooksAPI2.LoadHook
  • added: property NodeLoaderHooksAPI2.resolve: NodeLoaderHooksAPI2.ResolveHook
  • added: type NodeImportConditions = unknown
  • added: type NodeLoaderHooksAPI1.GetFormatHook = (url: string, context: {}, defaultGetFormat: GetFormatHook) => Promise<{ format: NodeLoaderHooksFormat }>
  • added: type NodeLoaderHooksAPI1.ResolveHook = NodeLoaderHooksAPI2.ResolveHook
  • added: type NodeLoaderHooksAPI1.TransformSourceHook = (source: string | Buffer, context: { url: string; format: NodeLoaderHooksFormat }, defaultTransformSource: NodeLoaderHooksAPI1.TransformSourceHook) => Promise<…
  • added: type NodeLoaderHooksAPI2.LoadHook = (url: string, context: { format: NodeLoaderHooksFormat | null | undefined; importAssertions?: NodeImportAssertions }, defaultLoad: NodeLoaderHooksAPI2['load'])…
  • added: type NodeLoaderHooksAPI2.NodeImportConditions = unknown
  • added: type NodeLoaderHooksAPI2.ResolveHook = (specifier: string, context: { conditions?: NodeImportConditions; importAssertions?: NodeImportAssertions; parentURL: string }, defaultResolve: ResolveHook) =>…
  • added: type NodeLoaderHooksFormat = 'builtin' | 'commonjs' | 'dynamic' | 'json' | 'module' | 'wasm'
  • removed: const DEFAULTS: RegisterOptions
  • removed: function normalizeSlashes(value: string): string
  • removed: function parse(value: string | undefined): object | undefined
  • removed: function split(value: string | undefined): string[] | undefined
  • removed: interface TSCommon
  • removed: property RegisterOptions.preferTsExts?: boolean
  • removed: property TSCommon.ModuleKind: typeof _ts.ModuleKind
  • removed: property TSCommon.ScriptSnapshot: typeof _ts.ScriptSnapshot
  • removed: property TSCommon.ScriptTarget: typeof _ts.ScriptTarget
  • removed: property TSCommon.createLanguageService: typeof _ts.createLanguageService
  • removed: property TSCommon.displayPartsToString: typeof _ts.displayPartsToString
  • removed: property TSCommon.findConfigFile: typeof _ts.findConfigFile
  • removed: property TSCommon.flattenDiagnosticMessageText: typeof _ts.flattenDiagnosticMessageText
  • removed: property TSCommon.formatDiagnostics: typeof _ts.formatDiagnostics
  • removed: property TSCommon.formatDiagnosticsWithColorAndContext: typeof _ts.formatDiagnosticsWithColorAndContext
  • removed: property TSCommon.getDefaultLibFilePath: typeof _ts.getDefaultLibFilePath
  • removed: property TSCommon.getPreEmitDiagnostics: typeof _ts.getPreEmitDiagnostics
  • removed: property TSCommon.parseJsonConfigFileContent: typeof _ts.parseJsonConfigFileContent
  • removed: property TSCommon.readConfigFile: typeof _ts.readConfigFile
  • removed: property TSCommon.sys: typeof _ts.sys
  • removed: property TSCommon.transpileModule: typeof _ts.transpileModule
  • removed: property TSCommon.version: typeof _ts.version
  • changed: constructor TSError(diagnosticText: string, diagnosticCodes: number[]) → constructor TSError(diagnosticText: string, diagnosticCodes: number[], diagnostics?: ReadonlyArray<_ts.Diagnostic>)
  • changed: interface TsConfigOptions extends Omit<RegisterOptions, 'transformers' | 'readFile' | 'fileExists' | 'skipProject' | 'project' | 'dir'> → interface TsConfigOptions extends Omit<RegisterOptions, 'transformers' | 'readFile' | 'fileExists' | 'skipProject' | 'project' | 'dir' | 'cwd' | 'projectSearchDir' | 'optionBasePaths' | 'tsTrace'>
  • added: const createEsmHooks: typeof createEsmHooksFn
  • added: export { CreateTranspilerOptions } from './transpilers/types'
  • added: export { EvalAwarePartialHost } from './repl'
  • added: export { NodeLoaderHooksAPI1 } from './esm'
  • added: export { NodeLoaderHooksAPI2 } from './esm'
  • added: export { NodeLoaderHooksFormat } from './esm'
  • added: export { TSCommon }
  • added: export { TranspileOptions } from './transpilers/types'
  • added: export { TranspileOutput } from './transpilers/types'
  • added: export { Transpiler } from './transpilers/types'
  • added: export { TranspilerFactory } from './transpilers/types'
  • added: export { TranspilerModule } from './transpilers/types'
  • added: function register(service: Service): Service
  • added: property CreateOptions.cwd?: string
  • added: property CreateOptions.esm?: boolean
  • added: property CreateOptions.experimentalReplAwait?: boolean
  • added: property CreateOptions.experimentalSpecifierResolution?: 'node' | 'explicit'
  • added: property CreateOptions.experimentalTsImportSpecifiers?: boolean
  • added: property CreateOptions.moduleTypes?: ModuleTypes
  • added: property CreateOptions.preferTsExts?: boolean
  • added: property CreateOptions.projectSearchDir?: string
  • added: property CreateOptions.scopeDir?: string
  • added: property CreateOptions.swc?: boolean
  • added: property CreateOptions.transpiler?: string | [string, object]
  • added: property CreateOptions.tsTrace?: (str: string) => void
  • added: property RegisterOptions.experimentalResolver?: boolean
  • added: property TSError.diagnostics: ReadonlyArray<_ts.Diagnostic>
  • added: type ExperimentalSpecifierResolution = 'node' | 'explicit'
  • added: type ModuleTypeOverride = 'cjs' | 'esm' | 'package'
  • added: type ModuleTypes = Record<string, ModuleTypeOverride>
  • added: type NodeModuleEmitKind = 'nodeesm' | 'nodecjs'
  • changed: function createEvalAwarePartialHost(state: EvalState): EvalAwarePartialHost → function createEvalAwarePartialHost(state: EvalState, composeWith?: EvalAwarePartialHost): EvalAwarePartialHost
  • changed: method ReplService.evalCode(code: string): void → method ReplService.evalCode(code: string): any
  • changed: method ReplService.nodeEval(code: string, _context: any, _filename: string, callback: (err: Error | null, result?: any) => any): void → method ReplService.nodeEval(code: string, context: any, _filename: string, callback: (err: Error | null, result?: any) => any): void
  • changed: method ReplService.start(code?: string): void → method ReplService.start(): void
  • added: method ReplService.start(code: string): void
  • added: function create(createOptions: SwcTranspilerOptions): Transpiler
  • added: interface SwcTranspilerOptions extends CreateTranspilerOptions
  • added: property SwcTranspilerOptions.swc?: string | typeof swcWasm
  • added: interface CreateTranspilerOptions
  • added: interface TranspileOptions
  • added: interface TranspileOutput
  • added: interface Transpiler
  • added: interface TranspilerModule
  • added: method Transpiler.transpile(input: string, options: TranspileOptions): TranspileOutput
  • added: property CreateTranspilerOptions.service: Pick<Service, Extract<'config' | 'options' | 'projectLocalResolveHelper', keyof Service>>
  • added: property TranspileOptions.fileName: string
  • added: property TranspileOutput.diagnostics?: ts.Diagnostic[]
  • added: property TranspileOutput.outputText: string
  • added: property TranspileOutput.sourceMapText?: string
  • added: property TranspilerModule.create: TranspilerFactory
  • added: type TranspilerFactory = (options: CreateTranspilerOptions) => Transpiler
  • added: interface TSCommon
  • added: interface TSCommon.LanguageServiceHost extends _ts.LanguageServiceHost
  • added: namespace TSCommon
  • added: namespace TSCommon.ModuleKind
  • added: property TSCommon.Extension: typeof _ts.Extension
  • added: property TSCommon.JsxEmit: typeof _ts.JsxEmit
  • added: property TSCommon.ModuleKind: TSCommon.ModuleKindEnum
  • added: property TSCommon.ModuleResolutionKind: typeof _ts.ModuleResolutionKind
  • added: property TSCommon.ScriptSnapshot: typeof _ts.ScriptSnapshot
  • added: property TSCommon.ScriptTarget: typeof _ts.ScriptTarget
  • added: property TSCommon.createDocumentRegistry: typeof _ts.createDocumentRegistry
  • added: property TSCommon.createEmitAndSemanticDiagnosticsBuilderProgram: typeof _ts.createEmitAndSemanticDiagnosticsBuilderProgram
  • added: property TSCommon.createIncrementalCompilerHost: typeof _ts.createIncrementalCompilerHost
  • added: property TSCommon.createIncrementalProgram: typeof _ts.createIncrementalProgram
  • added: property TSCommon.createLanguageService: typeof _ts.createLanguageService
  • added: property TSCommon.createModuleResolutionCache: typeof _ts.createModuleResolutionCache
  • added: property TSCommon.createSourceFile: typeof _ts.createSourceFile
  • added: property TSCommon.displayPartsToString: typeof _ts.displayPartsToString
  • added: property TSCommon.findConfigFile: typeof _ts.findConfigFile
  • added: property TSCommon.flattenDiagnosticMessageText: typeof _ts.flattenDiagnosticMessageText
  • added: property TSCommon.formatDiagnostics: typeof _ts.formatDiagnostics
  • added: property TSCommon.formatDiagnosticsWithColorAndContext: typeof _ts.formatDiagnosticsWithColorAndContext
  • added: property TSCommon.getDefaultLibFileName: typeof _ts.getDefaultLibFileName
  • added: property TSCommon.getDefaultLibFilePath: typeof _ts.getDefaultLibFilePath
  • added: property TSCommon.getPreEmitDiagnostics: typeof _ts.getPreEmitDiagnostics
  • added: property TSCommon.parseJsonConfigFileContent: typeof _ts.parseJsonConfigFileContent
  • added: property TSCommon.readConfigFile: typeof _ts.readConfigFile
  • added: property TSCommon.resolveModuleName: typeof _ts.resolveModuleName
  • added: property TSCommon.resolveModuleNameFromCache: typeof _ts.resolveModuleNameFromCache
  • added: property TSCommon.resolveTypeReferenceDirective: typeof _ts.resolveTypeReferenceDirective
  • added: property TSCommon.sys: typeof _ts.sys
  • added: property TSCommon.transpileModule: typeof _ts.transpileModule
  • added: property TSCommon.version: typeof _ts.version
  • added: type TSCommon.CompilerOptions = _ts.CompilerOptions
  • added: type TSCommon.FileReference = _ts.FileReference
  • added: type TSCommon.ModuleKind.CommonJS = _ts.ModuleKind.CommonJS
  • added: type TSCommon.ModuleKind.ESNext = _ts.ModuleKind.ESNext
  • added: type TSCommon.ModuleKindEnum = typeof _ts.ModuleKind & { Node16: typeof _ts.ModuleKind extends { Node16: any } ? typeof _ts.ModuleKind['Node16'] : 100 }
  • added: type TSCommon.ModuleResolutionHost = _ts.ModuleResolutionHost
  • added: type TSCommon.ParsedCommandLine = _ts.ParsedCommandLine
  • added: type TSCommon.ResolvedModule = _ts.ResolvedModule
  • added: type TSCommon.ResolvedModuleWithFailedLookupLocations = _ts.ResolvedModuleWithFailedLookupLocations
  • added: type TSCommon.ResolvedProjectReference = _ts.ResolvedProjectReference
  • added: type TSCommon.ResolvedTypeReferenceDirective = _ts.ResolvedTypeReferenceDirective
  • added: type TSCommon.SourceFile = _ts.SourceFile
  • added: function getEmitScriptTarget(compilerOptions: { module?: _ts.CompilerOptions['module']; target?: _ts.CompilerOptions['target'] }): _ts.ScriptTarget
  • added: function getUseDefineForClassFields(compilerOptions: _ts.CompilerOptions): boolean
  • added: function cachedLookup<T, R>(fn: (arg: T) => R): (arg: T) => R