Options
All
  • Public
  • Public/Protected
  • All
Menu

ts-node

Index

Basic

create

register

REPL

createRepl

  • Create a ts-node REPL instance.

    Pay close attention to the example below. Today, the API requires a few lines of boilerplate to correctly bind the ReplService to the ts-node Service and vice-versa.

    Usage example:

    const repl = tsNode.createRepl();
    const service = tsNode.create({...repl.evalAwarePartialHost});
    repl.setService(service);
    repl.start();

    Parameters

    Returns ReplService

Transpiler

TranspilerFactory

TranspilerFactory: (options: CreateTranspilerOptions) => Transpiler

Type declaration

ESM Loader

Const createEsmHooks

  • Create an implementation of node's ESM loader hooks.

    This may be useful if you want to wrap or compose the loader hooks to add additional functionality or combine with another loader.

    Node changed the hooks API, so there are two possible APIs. This function detects your node version and returns the appropriate API.

    Parameters

    Returns NodeLoaderHooksAPI1 | NodeLoaderHooksAPI2

Other

EvalAwarePartialHost

EvalAwarePartialHost: Pick<CreateOptions, "readFile" | "fileExists">

Filesystem host functions which are aware of the "virtual" [eval].ts, <repl>, or [stdin].ts file used to compile REPL inputs. Must be passed to create() to create a ts-node compiler service which can compile REPL inputs.

ExperimentalSpecifierResolution

ExperimentalSpecifierResolution: "node" | "explicit"

ModuleTypeOverride

ModuleTypeOverride: "cjs" | "esm" | "package"

ModuleTypes

ModuleTypes: Record<string, ModuleTypeOverride>

NodeLoaderHooksFormat

NodeLoaderHooksFormat: "builtin" | "commonjs" | "dynamic" | "json" | "module" | "wasm"

NodeModuleEmitKind

NodeModuleEmitKind: "nodeesm" | "nodecjs"

When using module: nodenext or module: node12, there are two possible styles of emit depending in file extension or package.json "type":

  • CommonJS with dynamic imports preserved (not transformed into require() calls)
  • ECMAScript modules with import foo = require() transformed into require = createRequire(); const foo = require()

Register

Register: Service

Re-export of Service interface for backwards-compatibility

deprecated

use Service instead

see

{Service}

REGISTER_INSTANCE

REGISTER_INSTANCE: typeof REGISTER_INSTANCE = ...

Registered ts-node instance information.

VERSION

VERSION: any = ...

Export the current version.

Generated using TypeDoc