Skip to content

repl: add experimental TypeScript support#64077

Draft
avivkeller wants to merge 1 commit into
nodejs:mainfrom
avivkeller:repl-ts
Draft

repl: add experimental TypeScript support#64077
avivkeller wants to merge 1 commit into
nodejs:mainfrom
avivkeller:repl-ts

Conversation

@avivkeller

Copy link
Copy Markdown
Member

Adds experimental TypeScript support to the REPL, opt-in-able via the --experimental-repl-typescript flag.

Adds experimental TypeScript support to
the REPL, opt-in-able via the
`--experimental-repl-typescript` flag.

Signed-off-by: avivkeller <me@aviv.sh>
@avivkeller avivkeller added repl Issues and PRs related to the REPL subsystem. experimental Issues and PRs related to experimental features. strip-types Issues or PRs related to strip-types support labels Jun 23, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/config
  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Jun 23, 2026
@avivkeller avivkeller marked this pull request as draft June 23, 2026 00:45
@avivkeller avivkeller added the blocked PRs that are blocked by other issues or PRs. label Jun 23, 2026
Comment thread doc/api/cli.md
assert.match(output.accumulator, /3\n> /);

// Transform TypeScript to JavaScript and evaluate it
input.emit('data', 'enum Color { Red, Green, Blue }\n');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for:
const foo = () => 'hello world'; foo<Object>();
If should return false. This basically makes sure valid js is evaluated before ts

Comment thread lib/repl.js
@Renegade334

Copy link
Copy Markdown
Member

This is going to cause problems with multiline, I suspect.

Concise example:

const regexps = new Set<
  RegExp
>();

If typed as multiline input to REPL, it's going to consider the statement complete after the second newline, as it's a valid JS statement, and evaluate new Set < RegExp, which evaluates to true. I don't know that there's any way around these sorts of parsing conflicts.

@marco-ippolito

Copy link
Copy Markdown
Member

It should be handled exactly like we handle the -e and -p. If it's valid js treat it as such otherwise fallback on TS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked PRs that are blocked by other issues or PRs. c++ Issues and PRs that require attention from people who are familiar with C++. experimental Issues and PRs related to experimental features. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. repl Issues and PRs related to the REPL subsystem. strip-types Issues or PRs related to strip-types support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants