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.

[Bug]: Edge case in TSX: `<T,>(t: T) => t`

See original GitHub issue

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

const { transformSync } = require('@babel/core')

let result = transformSync(`
  const fn = <T,>(t: T) => t;
`, {
  babelrc: false,
  configFile: false,
  parserOpts: {
    plugins: [
      'jsx',
      'typescript',
    ]
  },
})

console.log(result.code)

Configuration file name

No response

Configuration

No response

Current and expected behavior

The current output:

const fn = <T>(t: T) => t;

This is valid in TS, but invalid in TSX, because <T> is treated as a tag in TSX context.

Expected output:

const fn = <T,>(t: T) => t;

Environment

  System:
    OS: macOS 11.5.2
  Binaries:
    Node: 16.9.1 - /usr/local/bin/node
    Yarn: 1.22.11 - /usr/local/bin/yarn
    npm: 7.23.0 - /usr/local/bin/npm

Possible solution

No response

Additional context

Original Issue: vitejs/vite#4949.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:19 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
ozanhonamlioglucommented, Jan 6, 2022

Yes, yarn jest generator works without problems on my machine 🤔

Okay, never mind then, probably it is related to my env. I actually started to dig in already, and it is going well and will update you soon I hope. Thanks

1reaction
nicolo-ribaudocommented, Jan 6, 2022

Yes, yarn jest generator works without problems on my machine 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Are Edge Cases in Software Testing? - 2022 Edition
Software testing edge cases are bugs that are uncommon for users to encounter. Edge cases can be minor - or as severe as...
Read more >
What Is an Edge Case? Definition and Examples in a Product
An edge case is a type of bug in software development that only occurs under uncommon circumstances. This means that most users won't...
Read more >
TSConfig Reference - Docs on every TSConfig option
From allowJs to useDefineForClassFields the TSConfig reference includes information about ... This means you won't accidentally ship a case fallthrough bug.
Read more >
Migrating to React Query 4 - TanStack
The codemod is a best efforts attempt to help you migrate the breaking change. Please review the generated code thoroughly! Also, there are...
Read more >
markdown-to-jsx - npm
options.overrides - Rendering Arbitrary React Components ... One of the most interesting use cases enabled by the HTML syntax processing in ...
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