Fix error for decorators not enabled (#9321)
* Fix error for decorators not enabled * Update error message
This commit is contained in:
parent
d6b4ab75ee
commit
a24206eb96
@ -39,9 +39,17 @@ export function isLoose(file, feature) {
|
||||
}
|
||||
|
||||
export function verifyUsedFeatures(path, file) {
|
||||
if (hasOwnDecorators(path)) {
|
||||
if (hasOwnDecorators(path.node)) {
|
||||
if (!hasFeature(file, FEATURES.decorators)) {
|
||||
throw path.buildCodeFrameError("Decorators are not enabled.");
|
||||
throw path.buildCodeFrameError(
|
||||
"Decorators are not enabled." +
|
||||
"\nIf you are using " +
|
||||
'["@babel/plugin-proposal-decorators", { "legacy": true }], ' +
|
||||
'make sure it comes *before* "@babel/plugin-proposal-class-properties" ' +
|
||||
"and enable loose mode, like so:\n" +
|
||||
'\t["@babel/plugin-proposal-decorators", { "legacy": true }]\n' +
|
||||
'\t["@babel/plugin-proposal-class-properties", { "loose": true }]',
|
||||
);
|
||||
}
|
||||
|
||||
if (path.isPrivate()) {
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
@deco
|
||||
class Foo {}
|
||||
@ -0,0 +1,7 @@
|
||||
{
|
||||
"plugins": [
|
||||
["proposal-class-properties", { "loose": true }],
|
||||
["proposal-decorators", { "legacy": true }]
|
||||
],
|
||||
"throws": "Decorators are not enabled."
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user