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
I want to use Babel 7.11.5 only to strip TypeScript declarations, as fast alternative to running tsc. With X.ts:
classX{
#y(n: number){console.log(n+2);}}
This fails:
babel --presets @babel/preset-typescript --extensions '.ts' X.ts
SyntaxError: X.ts: Support for the experimental syntax 'classPrivateProperties' isn't currently enabled (2:5):
1 | class X {
> 2 | #y(n: number) {
| ^
3 | console.log( n + 2);
4 | }
5 | }
Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-class-properties (https://git.io/vb4yQ) to the 'plugins' section to enable parsing.
at Object._raise ...
loc: Position { line: 2, column: 4 },
pos: 14,
missingPlugin: [ 'classPrivateProperties', 'classPrivateMethods' ],
code: 'BABEL_PARSE_ERROR'
}
• Extend babel/cli --presets @babel/preset-typescript or @babel/plugin-transform-typescript to only strip the TypeScript declarations and leave the rest as it is, so that adding @babel/plugin-syntax-class-properties is not necessary for the stripping.
The text was updated successfully, but these errors were encountered:
Hey @dilyanpalauzov! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."
Do I see correctly, that #13232 enables @babel/plugin-syntax-class-properties by default (no-op), so that the typescript-preset can now be used just to strip the type annotations, and it understands this convoluted syntax?
I want to use Babel 7.11.5 only to strip TypeScript declarations, as fast alternative to running
tsc
. With X.ts:This fails:
This works:
babel --plugins @babel/plugin-syntax-class-properties --presets @babel/preset-typescript --extensions '.ts' X.ts
• Extend
babel/cli --presets @babel/preset-typescript
or @babel/plugin-transform-typescript to only strip the TypeScript declarations and leave the rest as it is, so that adding@babel/plugin-syntax-class-properties
is not necessary for the stripping.The text was updated successfully, but these errors were encountered: