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

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

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

Comments

Projects
None yet
4 participants
@marionebl

marionebl commented Oct 31, 2015

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

This comment has been minimized.

Show comment
Hide comment
@hzoo

hzoo Oct 31, 2015

Member

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

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

@kittens kittens closed this in cdeff2f Nov 3, 2015

@kittens kittens reopened this Nov 3, 2015

@kittens

This comment has been minimized.

Show comment
Hide comment
@kittens

kittens Nov 3, 2015

Member

Referenced the wrong issue in the commit message.

Member

kittens commented Nov 3, 2015

Referenced the wrong issue in the commit message.

@marionebl

This comment has been minimized.

Show comment
Hide comment
@marionebl

marionebl Nov 5, 2015

@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

marionebl commented Nov 5, 2015

@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

This comment has been minimized.

Show comment
Hide comment
@babel-bot

babel-bot Sep 7, 2016

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.

Collaborator

babel-bot commented Sep 7, 2016

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.

@babel-bot babel-bot closed this Sep 7, 2016

@lock lock bot added the outdated 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.