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

Import used by @jsx pragma is elided by typescript transform #8958

Open
Kovensky opened this Issue Nov 1, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@Kovensky
Member

Kovensky commented Nov 1, 2018

Bug Report

Current Behavior
When an imported value is used only implicitly via JSX, the typescript type import elision is incorrectly removing the "type-only" import.

Input Code

  • REPL or Repo link if applicable:
/* @jsx jsx */
import { jsx } from '@emotion/core'

import ReactDOM from 'react-dom'

ReactDOM.render(<div/>, document.appendChild(document.createElement('div')))

Expected behavior/code
The "jsx" import should still be present in the output

Babel Configuration

Literally create-react-app --typescript defaults.

Additional context/Screenshots

Output from webpack:

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js");
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_0__);
var _jsxFileName = "/Users/kovensky/src/statsim/src/index.tsx";

/* @jsx jsx */

react_dom__WEBPACK_IMPORTED_MODULE_0___default.a.render(jsx("div", {
  __source: {
    fileName: _jsxFileName,
    lineNumber: 6
  },
  __self: undefined
}), document.appendChild(document.createElement('div')));

Note how the @emotion/core import is missing entirely.

Adding an unused jsx reference anywhere to the file makes the build correct.

@Kovensky Kovensky referenced this issue Nov 2, 2018

Open

Emotion 10 #637

14 of 14 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment