8000 using decorators with preset-stage-1 throws cryptic error message · Issue #2711 · babel/babel · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

using decorators with preset-stage-1 throws cryptic error message #2711

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

Closed
marionebl opened this issue Oct 31, 2015 · 4 comments
Closed

using decorators with preset-stage-1 throws cryptic error message #2711

marionebl opened this issue Oct 31, 2015 · 4 comments
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@marionebl
Copy link

Given I use the following babel config ...

{
  "presets":
  [
    "stage-0",
    "stage-1",
    "stage-2",
    "stage-3",
    "es2015-without-regenerator"
  ],
  "plugins":
  [
    "transform-strict-mode",
    "transform-runtime",
    "transform-es2015-modules-commonjs"
  ],
  "sourceMaps": "inline"
}

... and use decorators on class methods like this ...

class PatternManifestError extends Error {
    @readonly;
    @stat('PatternManifestError');
    name() {}

    @readonly
    @namespace
    get message() {}

    @readonly
    @namespace
    get meta() {}
}

function patternManifestErrorFactory(...args) {
    return new PatternManifestError(...args);
}

export default patternManifestErrorFactory;
export {PatternManifestError};

... the following Error is thrown ...

events.js:141
      throw er; // Unhandled 'error' event
      ^
TypeError: ~source/library/manifest/error.js: Cannot read property 'body' of undefined
    at NodePath._getKey (~node_modules/babel-core/node_modules/babel-traverse/lib/path/family.js:113:23)
    at NodePath.get (~node_modules/babel-core/node_modules/babel-traverse/lib/path/family.js:100:17)
    at NodePath._getPattern (~node_modules/babel-core/node_modules/babel-traverse/lib/path/family.js:158:21)
    at NodePath.get (~node_modules/babel-core/node_modules/babel-traverse/lib/path/family.js:103:17)
    at transformClass (~node_modules/babel-preset-stage-1/node_modules/babel-plugin-transform-decorators/lib/index.js:63:32)
    at PluginPass.ClassExpression (~node_modules/babel-preset-stage-1/node_modules/babel-plugin-transform-decorators/lib/index.js:155:30)
    at newFn (~node_modules/babel-core/node_modules/babel-traverse/lib/visitors.js:233:27)
    at NodePath._call (~node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js:72:18)
    at NodePath.call (~node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js:44:17)
    at NodePath.visit (~node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js:102:12)
    at TraversalContext.visitQueue (~node_modules/babel-core/node_modules/babel-traverse/lib/context.js:151:16)
@hzoo
Copy link
Member
hzoo commented Oct 31, 2015

Just want to point out that the stage-0 preset includes stage-1 (and that includes stage-2), etc so you won't need to specify all of them. Also decorators aren't working currently so probably related to #2645

@sebmck sebmck closed this as completed in cdeff2f Nov 3, 2015
@sebmck sebmck reopened this Nov 3, 2015
@sebmck
Copy link
Contributor
sebmck commented Nov 3, 2015

Referenced the wrong issue in the commit message.

@marionebl
Copy link
Author

@hzoo: Thanks for the heads-up concerning the official presets. People should be aware of precedence issues when relying on it, most notably with ES7 property initializers in stage-1. See: #2729

@babel-bot
Copy link
Collaborator

Comment originally made by @loganfsmyth on 2015-11-29T20:18:05.000Z

Going to close this since the message has been changed and there isn't much actionable here.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 7, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

4 participants
0