Skip to content

[bug report] - plugin-transform-typescript doesn't function correctly with 2 pragmas #9549

Closed

Description

@vidarc

Bug Report

Current Behavior
Using version 7.3.2 of plugin-transform-typescript results in unexpected behavior. Using /** @jsx jsx */ at the top of the file works for that one, but files that are just plain react will remove the import React from 'react'.

Versions of plugin-transform-typescript before 7.3.2 work as expected. I assume this PR: #9095 is the one that broke this.

Input Code

  • REPL or Repo link if applicable:

File A

/** @jsx jsx */
import { css, jsx } from '@emotion/core'

....code

File B

import React from 'react'

.....code

File A gets output as expected. File B gets output as expected, except for the React import being removed. Adding /** @jsx React.createElement */ at the top does not fix this. Produces same result.

Expected behavior/code
I expect /** @jsx jsx */ to only effect the file it is in

Babel Configuration (.babelrc, package.json, cli command)

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

Environment
"@babel/cli": "7.2.3",
"@babel/core": "7.3.3",
"@babel/plugin-syntax-jsx": "7.2.0",
"@babel/plugin-transform-react-jsx": "7.3.0",
"@babel/plugin-transform-typescript": "7.2.0",
"babel-loader": "8.0.5",

Activity

  1. babel-bot commented on Feb 20, 2019

    @babel-bot
    Collaborator

    Hey @vidarc! We really appreciate you taking the time to report an issue. The collaborators
    on this project attempt to help as many people as possible, but we're a limited number of volunteers,
    so it's possible this won't be addressed swiftly.

    If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
    community
    that typically always has someone willing to help. You can sign-up here
    for an invite.

  2. nicolo-ribaudo commented on Apr 15, 2019

    @nicolo-ribaudo
    Member

    Fixed by #9798

  3. added
    outdated
    on Jul 15, 2019
  4. locked as resolved and limited conversation to collaborators on Jul 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: needs triageoutdated

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions