question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@babel/plugin-syntax-jsx and @babel/plugin-syntax-typescript on REPL does not respect tsx contents

See original GitHub issue

Bug Report

  • I would like to work on a fix!

Current behavior

/repl.js: Unexpected token, expected "," (4:14)

  2 | 
  3 | export function A() {
> 4 |   return <div />
    |               ^
  5 | }
  6 | 

Input Code

Minimum reproduction sample on REPL.

import React from "react"

export function A() {
  return <div />
}

Expected behavior Nothing happens.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
{
  "plugins": [
    "@babel/plugin-syntax-jsx",
    "@babel/plugin-syntax-typescript"
  ]
}

Environment

  • Babel version(s): 7.10.3
  • Node/npm version: N/A. Issue reproducible on REPL.
  • OS: N/A
  • Monorepo: no
  • How you are using Babel: N/A

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
JLHwungcommented, Jun 29, 2020

In Babel 7 you have to enable the isTSX option: https://babeljs.io/docs/en/babel-plugin-syntax-typescript#istsx

We acknowledge that

{
  "plugins": [
    "@babel/plugin-syntax-jsx",
    "@babel/plugin-syntax-typescript"
  ]
}

is more natural and it is now supported on Babel 8.

0reactions
alex-kinokoncommented, Jun 29, 2020

You can reproduce it even with filename set on Node.js. Please see this example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@babel/plugin-syntax-typescript | Yarn - Package Manager
Intro. Babel is a tool that helps you write code in the latest version of JavaScript. When your supported environments don't support certain...
Read more >
r console does not work? - Replit
The r console here on repl it does not seem to work. Just signed on to repl.it a half hour ago to try...
Read more >
My Repl does not seem to load. - Replit
The code loads in and all but the run button just keeps on showing that it is loading. I have tried connecting to...
Read more >
does not work inside a function - Replit
I have a piece of code designed to choose one to three that works outside of a function but inside it says it's...
Read more >
Terms of Service - Replit
If you disagree with any part of these Terms then you do not have permission to ... any users of the Service with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found