Closed mmorton closed 6 years ago
thanks for the pull request! to understand this right, is the preserve flag treating simple arrow functions that do not return jsx as react stateless components?
It's treating the generic type expression <T>
as the start of a JSX element.
To use those in a .tsx
file, you have to either have multiple generic parameters, or use qualifiers. But since this is in a normal .ts
file, it should not matter (and does not matter when using tsc
to build everything). The only issue is here, that transpileModule
doesn't have that same information about file extensions that is there when building normally.
ok, I think this fix will work fine for 99% of typescript user. If for some reason someone is writing jsx in .ts files this will be an issue but there is still the possibility to write your own preprocessor if you want a custom typescript processing behavior. so I merged this an it is now online in 2.4.3, thanks!
When calling
transpileModule
on a plain.ts
file, with certain generic expressions and whenjsx
is set tots.JsxEmit.Preserve
, incorrect JS will be emitted. For example:will emit:
Which will cause errors when Babylon tries to parse it.