Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL patch affects scripts #202

Open
1 task
redstonekasi opened this issue Mar 17, 2023 · 4 comments
Open
1 task

REPL patch affects scripts #202

redstonekasi opened this issue Mar 17, 2023 · 4 comments
Labels
bug Something isn't working REPL

Comments

@redstonekasi
Copy link

Bug description

I was trying out making a custom REPL using Node's repl module when I came across this bug that was presumably introduced in #125. When running a file using tsx the patch affects the script that was run.

Screenshot of expected and actual behaviour (repl.ts is the reproduction code below)
image

Reproduction

import * as repl from "node:repl";

repl.start({
  eval: (cmd, ctx, file, cb) => cb(null, cmd),
});

Environment

System:
    OS: Linux 6.2 Arch Linux
    CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
    Memory: 9.35 GB / 15.54 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
Binaries:
    Node: 18.14.1 - ~/.local/share/pnpm/node
    npm: 9.3.1 - ~/.local/share/pnpm/npm

Sorry this didn't run correctly on my system because I use pnpm, here's `tsx -v` instead:
> tsx -v
tsx v3.12.3
node v18.14.1

Can you work on a fix?

  • I’m interested in opening a pull request to address this issue.
@privatenumber
Copy link
Owner

privatenumber commented Mar 20, 2023

This will mainly be fixed via #205

Currently, it seems the patch affects custom REPL instances. Do you think it's expected for them to get TypeScript when executed with tsx?

I'm thinking not, and that the patch should only be applied to the Node.js REPL.

@redstonekasi
Copy link
Author

I agree. While REPL instances are probably mainly going to be used for JS, they can also be used for other purposes when defining a custom evaluation function, which is why the patch should only be applied to the Node.js REPL.

@redstonekasi
Copy link
Author

Also even ignoring that, there should not be a noticeable difference between running code through tsx and running compiled code using node.

@andyfischer
Copy link

I just hit a similar bug using tsx version 4.11.0 .

The bug I'm seeing is that input from the repl is transformed.

If I use a very simple script to see the output:

const repl = require('repl');

repl.start({
    eval: line => {
        console.log('The line was: ' + line);
    }
});

And I try entering input with dashes like: some-command

I'm expecting it to print:

The line was: some-command

What I actually see when running this inside TSX:

The line was: some - command;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working REPL
Projects
None yet
Development

No branches or pull requests

3 participants