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

Wrong error when using no type while declaring constant in repl #1563

Closed
Dragonizedpizza opened this issue Dec 9, 2021 · 7 comments
Closed
Labels
user error Issues that were ultimately human error, not a bug nor a missing feature.

Comments

@Dragonizedpizza
Copy link

Search Terms

Expected Behavior

undefined/nothing.

Actual Behavior

/home/arch/Desktop/Hurricano/<repl>.ts:3
export {};
^^^^^^

Uncaught SyntaxError: Unexpected token 'export'

Steps to reproduce the problem

  1. Make a ts-node repl.
  2. Type in const h = {};

Minimal reproduction

image

Specifications

  • ts-node v10.4.0
  • node v16.13.0
  • compiler v4.5.2
    tsconfig.json, if you're using one:

https://srcb.in/ldUTwVZaod

  • Operating system and version:
  • Garuda Linux Soaring.
@cspotcode
Copy link
Collaborator

cspotcode commented Dec 10, 2021 via email

@Dragonizedpizza
Copy link
Author

Ok

@cspotcode
Copy link
Collaborator

I assume this has been resolved. If not, feel free to reply and we can re-open.

@cspotcode cspotcode added the user error Issues that were ultimately human error, not a bug nor a missing feature. label Jan 11, 2022
@Jamesernator
Copy link
Contributor

Looks like tsconfig "module: esnext" is the culprit.

I assume this has been resolved. If not, feel free to reply and we can re-open.

So this happens with "module": "NodeNext" as well, although I don't understand why this happens with either option.

Like shouldn't the repl mode always compile the code given as CommonJS/script regardless of the "module" field?

@cspotcode
Copy link
Collaborator

Yeah, I think the bug here is that we don't force the repl to be CJS even in ESM projects. I thought I already had a ticket for this; can you check for one and, if not found, file a new bug report?

@Jamesernator
Copy link
Contributor

Yeah, I think the bug here is that we don't force the repl to be CJS even in ESM projects. I thought I already had a ticket for this; can you check for one and, if not found, file a new bug report?

I think this is #1752

@cspotcode
Copy link
Collaborator

Thanks, I added a comment on that issue about a couple possible ways to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user error Issues that were ultimately human error, not a bug nor a missing feature.
Projects
None yet
Development

No branches or pull requests

3 participants