Comments (10)
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.
This seems like an issue with the typeorm
decorators, rather than an issue with this module?
from babel-plugin-transform-decorators-legacy.
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.
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.
why do you put "transform-class-properties"
before "transform-decorators-legacy"
?
from babel-plugin-transform-decorators-legacy.
Here is my configuration:
{
"presets": [
"es2015"
],
"plugins": [
"transform-decorators-legacy",
"transform-class-properties"
]
}
from babel-plugin-transform-decorators-legacy.
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.
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.
Any solutions?
from babel-plugin-transform-decorators-legacy.
Is this solved?
from babel-plugin-transform-decorators-legacy.
Related Issues (20)
- Error: Cannot read property of undefined. Static properties HOT 4
- @observable static has a Error
- Extract decorated functions as top level variables HOT 7
- Class property decorator hack. HOT 4
- What can be done to make decorators real in and move from stage-1 to stage-4? HOT 4
- [bug]Parameter Decorator does not work HOT 2
- About the parameter decorator support HOT 1
- Hook into initializer HOT 3
- Class property decorators gets applied before the class decorator itself HOT 4
- Issues with Electron HOT 19
- undefined is not a constructor (evaluating 'new u') HOT 2
- plugin not working HOT 4
- A issue in React-Native HOT 3
- Incorrect local name w/ native classes & babel-minify
- Maximum call stack size exceeded
- Clarify what babel's `legacy: true` is for exactly HOT 1
- Module build failed : Error:Cannot use the decorators and decorators-legacy plugin together
- Module parse failed: Unexpected character '@' (15:0)
- Audit vulnerabilities detected in the babelplugintransformdecoratorslegacy project on Tag: v1.3.5
- No lock file found in the babelplugintransformdecoratorslegacy project on Tag: v1.3.5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babel-plugin-transform-decorators-legacy.