function declaration
declaration(input: string): Declaration | null

What a line declares, or null where it declares nothing.

At a breakpoint the page is evaluated with Debugger.evaluateOnCallFrame, which runs each input in a scope of its own and throws that scope away afterwards. A let there answers undefined like a declaration should and then does not exist, which is the worst of both: it looks like it worked. Knowing the name and the value separately is what lets a caller keep the binding somewhere that lasts while evaluating the VALUE where it was typed — let doubled = answer * 2 has to see the frame's answer, and only the frame can.

Only a single name is read. A destructuring pattern or several declarators at once are left alone rather than half-understood, and behave as they did: for the length of one evaluation.

import { declaration } from './input.ts';

declaration("let me = { age: 32 }"); // { name: 'me', value: '{ age: 32 }', blockScoped: true }
declaration('var a = 1')?.blockScoped; // false — hoisted out of blocks, so it stays
declaration('me.age'); // null — nothing is being declared
declaration('let a = 1, b = 2'); // null — two at once is left alone rather than half-understood

Parameters

input: string

Return Type

Declaration | null

Usage

import { declaration } from "lib/repl/input.ts";