Defer <T>() => {} TSX error to Babel 8#14367
Merged
nicolo-ribaudo merged 1 commit intobabel:mainfrom Mar 18, 2022
Merged
Conversation
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/51499/ |
existentialism
approved these changes
Mar 17, 2022
So the correct configuration would be something like the following? But it always gives me a feeling of redundancy. |
JLHwung
approved these changes
Mar 18, 2022
Member
Author
|
@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"]
}]
}; |
CarsonF
added a commit
to SeedCompany/cord-field
that referenced
this pull request
Mar 19, 2022
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#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
.tsbe 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> vtype casts, but everyone usesv as Tnow). 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.