Code Monkey home page Code Monkey logo

Comments (10)

loganfsmyth avatar loganfsmyth commented on May 18, 2024 3

You are right, I tried both to make sure and then copy-pasted the wrong one.

I am able to reproduce with es2015. Thanks for the info.

from babel-plugin-transform-decorators-legacy.

loganfsmyth avatar loganfsmyth commented on May 18, 2024

This seems like an issue with the typeorm decorators, rather than an issue with this module?

from babel-plugin-transform-decorators-legacy.

pleerock avatar pleerock commented on May 18, 2024

No, I think its not. Simple example of reproduction without typeorm:

function dec(id) {
    return (target, property, descriptor) => console.log("executed", id);
}

export class Category {

    @dec()
    id = 0;

    @dec()
    name;

}

const category = new Category();
category.id = 1;
category.name = "hello";

produces:

/Users/pleerock/www/opensource/typeorm/babel-example/dist/index.js:79
category.name = "hello";
              ^

TypeError: Cannot assign to read only property 'name' of object '#<Category>'
    at Object.<anonymous> (/Users/pleerock/www/opensource/typeorm/babel-example/dist/index.js:79:15)

Note that category.id = 1 worked because id was initialized in the class.

from babel-plugin-transform-decorators-legacy.

loganfsmyth avatar loganfsmyth commented on May 18, 2024

Would you be able to put together a simple example repo? Dropping that into a repo with .babelrc

"transform-class-properties",
"transform-decorators-legacy",

logs

executed undefined
executed undefined

for me, so something else may be interfering?

from babel-plugin-transform-decorators-legacy.

pleerock avatar pleerock commented on May 18, 2024

why do you put "transform-class-properties" before "transform-decorators-legacy"?

from babel-plugin-transform-decorators-legacy.

pleerock avatar pleerock commented on May 18, 2024

Here is my configuration:

{
  "presets": [
    "es2015"
  ],
  "plugins": [
    "transform-decorators-legacy",
    "transform-class-properties"
  ]
}

from babel-plugin-transform-decorators-legacy.

hwaterke avatar hwaterke commented on May 18, 2024

The problem originates from this check: index.js (LINE 54)

I'm not familiar enough with the code to be sure if it can be safely removed.
Any opinion?

from babel-plugin-transform-decorators-legacy.

loganfsmyth avatar loganfsmyth commented on May 18, 2024

Yeah that's definitely the line. That was carried over from Babel 5.x here: https://github.com/babel/babel/blob/5.x/packages/babel/src/transformation/templates/helper-create-decorated-class.js#L15 and the same bug reproduces in Babel 5 too.

from babel-plugin-transform-decorators-legacy.

SPAHI4 avatar SPAHI4 commented on May 18, 2024

Any solutions?

from babel-plugin-transform-decorators-legacy.

chbdetta avatar chbdetta commented on May 18, 2024

Is this solved?

from babel-plugin-transform-decorators-legacy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.