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
Defer <T>() => {}
TSX error to Babel 8
#14367
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/51499/ |
So the correct configuration would be something like the following?
But it always gives me a feeling of redundancy. |
@liby Something like this is guaranteed to work: module.exports = {
overrides: [{
test: /\.(tsx|ts)$/,
presets: [["@babel/preset-typescript", { allowDeclareFields: true }]]
}, {
test: /\.(jsx|tsx)$/,
presets: ["@babel/preset-react"]
}]
}; |
babel/babel#14367 I'd be fine with upgrading to accommodate this breaking change, but Prettier can't figure out this out and tries to remove the trailing commas I add. We'll wait for the dust to settle.
It doesn't work for me. The error message is:
It works for me.
|
#14135 (which disallows
<T>() => {}
in TSX files, since it should be written as<T,>() => {}
) caused problems for multiple users (at least 5 already reported it).The reason is that most people enable the JSX and TS presets on all files, making also
.ts
be parsed as.tsx
. This is wrong in theory, but until Babel 7.17.0 it always worked since TSX was just a superset of TS (except for the legacy<T> v
type casts, but everyone usesv as T
now). Even if #14135 is technically correct, it introduced a new error for everyone using single type arguments without a trailing comma and with that misconfiguration.This error is correct so we should do it, but we could consider it as a breaking change and wait until Babel 8.