Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ReplService

Hierarchy

  • ReplService

Index

Properties

evalAwarePartialHost

evalAwarePartialHost: EvalAwarePartialHost

Readonly state

state: EvalState

Methods

evalCode

  • evalCode(code: string): any
  • Append code to the virtual source file, compile it to JavaScript, throw semantic errors if the typechecker is enabled, and execute it.

    Note: typically, you will want to call start() instead of using this method.

    Parameters

    • code: string

      string of TypeScript.

    Returns any

nodeEval

  • nodeEval(code: string, context: any, _filename: string, callback: (err: null | Error, result?: any) => any): void
  • eval implementation compatible with node's REPL API

    Can be used in advanced scenarios if you want to manually create your own node REPL instance and delegate eval to this ReplService.

    Example:

    import {start} from 'repl';
    const replService: tsNode.ReplService = ...; // assuming you have already created a ts-node ReplService
    const nodeRepl = start({eval: replService.eval});

    Parameters

    • code: string
    • context: any
    • _filename: string
    • callback: (err: null | Error, result?: any) => any
        • (err: null | Error, result?: any): any
        • Parameters

          • err: null | Error
          • Optional result: any

          Returns any

    Returns void

setService

  • Bind this REPL to a ts-node compiler service. A compiler service must be bound before eval-ing code or starting the REPL

    Parameters

    Returns void

start

  • start(): void
  • start(code: string): void
  • Start a node REPL

    Returns void

  • Start a node REPL, evaling a string of TypeScript before it starts.

    deprecated

    Parameters

    • code: string

    Returns void

Generated using TypeDoc