You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Import used by @jsx pragma is elided by typescript transform #8958
Current Behavior
When an imported value is used only implicitly via JSX, the typescript type import elision is incorrectly removing the "type-only" import.
Note how the @emotion/core import is missing entirely.
Adding an unused jsx reference anywhere to the file makes the build correct.
Reacted by Apostolos Tsakpinis, Calvin, Jaap Frolich, Renaud Chaput, Hidemi Yukita, Yusuke Fujiki, Aaron Jensen, Shu Uesugi, Reinis Ivanovs, Lee Reinhardt and 3 more
A fix is to not use the pragma parameter of the typescript plugin (keep the default react). Then use another babel plugin (order matters) to add the pragma. Not ideal. I think the typescript plugin shouldn't need to do anything with the pragma parameter. I think it needs to specify the pragma so it knows it needs to strip out type only imports. However these will be tree shaken out anyway I guess, so do we really need to have this option?
Activity
jfrolich commentedon Nov 27, 2018
This can be fixed by setting the jsxPragma option in the typescript transform. However now
Reactis removed when Fragments are used.jfrolich commentedon Nov 27, 2018
A fix is to not use the pragma parameter of the typescript plugin (keep the default react). Then use another babel plugin (order matters) to add the pragma. Not ideal. I think the typescript plugin shouldn't need to do anything with the pragma parameter. I think it needs to specify the pragma so it knows it needs to strip out type only imports. However these will be tree shaken out anyway I guess, so do we really need to have this option?
cameron-martin commentedon Jan 26, 2019
Surely there should be a similar option in the typescript preset that mirrors the
pragmaFragoption in the react preset.Alternatively you can not use the fragment shorthand and write it as
<React.Fragment>.I believe webpack errors if you try to import a binding that does not exist.