Skip to content

ResolveReplFn

reference
1 min readUpdated

Kind: Class

Source: packages/core/repl/native-functions/resolve-repl-fn.ts

Part of: Core

ResolveReplFn is a native REPL function that performs the resolve operation exposed by the interactive REPL environment. Its action() method executes the resolution workflow asynchronously and returns the resulting value to the REPL runtime.

Extends: ReplFunction

Methods

MethodSignatureReturns
action`action(token: stringsymbol

Properties

PropertyType
fnDefinitionReplFnDefinition

Diagram

mermaid
graph LR
  User[REPL user input] --> Repl[REPL runtime]
  Repl --> ResolveReplFn[ResolveReplFn]
  ResolveReplFn --> Action[action()]
  Action --> Resolver[Resolution workflow]
  Resolver --> Result[Promise result]
  Result --> Repl

Usage

ts
import { ResolveReplFn } from "./native-functions/resolve-repl-fn";

// ResolveReplFn is typically constructed and registered by the REPL runtime.
declare const resolveFn: ResolveReplFn;

async function runResolve(): Promise<void> {
  const result = await resolveFn.action();

  console.log("Resolve result:", result);
}

void runResolve();

AI Coding Instructions

  • Keep action() asynchronous and return the resolution result through its Promise.
  • Treat this class as a REPL integration point; ensure it is registered or instantiated through the same native-function flow as other REPL commands.
  • Preserve the result shape expected by the REPL renderer or caller when changing resolution behavior.
  • Handle resolution failures consistently with other native REPL functions so errors are surfaced clearly to interactive users.

How it works

ResolveReplFn

ResolveReplFn is a built-in REPL function class that extends ReplFunction. Its metadata registers the function under the name resolve, with the displayed signature (token: InjectionToken, contextId: any) => Promise<any>. [packages/core/repl/native-functions/resolve-repl-fn.ts:5-11]

ReplContext includes ResolveReplFn in its built-in function classes. During initialization, it constructs the class, stores it in nativeFunctions under its metadata name, and binds its action method into the REPL global scope as resolve. [packages/core/repl/repl-context.ts:168-184] [packages/core/repl/repl-context.ts:122-150] Thus a REPL user can invoke it as resolve(...). The bound function also has a non-enumerable help getter that writes a generated help message to standard output. [packages/core/repl/repl-context.ts:152-162] The help text is generated from this class’s description, name, and signature. [packages/core/repl/repl-function.ts:27-35]

Was this page helpful?

Download as PDF
ResolveReplFn — NestJS head-to-head