Comments (6)
Unfortunately harmony classes are quite limited and there's actually no way to do it besides the ways that you found. Alternatively you can do:
class Blah {
constructor() {
console.log(this.foo)
}
get foo() {
return "bar";
}
}
but it's not very nice.
from babel.
Can you override the getter? I tried your example with:
class Blah {
constructor() {
console.log(this.foo)
}
get foo() {
return "bar";
}
}
B.prototype.foo = 'baz'
but foo
was still bar
.
from babel.
Unfortunately not.
from babel.
I appreciate the feedback. The classes end up looking gross when making a Backbone View:
class View extends Backbone.View {
constructor() {
super()
}
}
View.prototype.className = 'container top'
View.prototype.tagName = 'nav'
// etc...
Wish ECMAScript/TC39 would have allowed for class properties like CoffeeScript.
from babel.
Yeah I agree. ES6 classes are way less powerful than they could've been.
from babel.
class View {
static def() {
this.prototype.className = 'container top';
this.prototype.tagName = 'nav';
return this;
}
}
export default View.def();
from babel.
Related Issues (20)
- [Bug]: @babel/[email protected] failed to publish on npm HOT 4
- [Bug]: Failed to transpile arrow functions even I saw "transform-arrow-functions { ie } " from log and I have not exclude /node_modules/ HOT 29
- [Bug]: @babel/plugin-transform-class-properties interferes with @babel/preset-env transforming class static blocks HOT 2
- [Documentation-Bug]: Can @babel/plugin-transform-runtime be used together with useBuiltIns ? HOT 6
- [Bug]: Setting babelrc to false will skip the process of ignoreFile, is this a feature or bug? HOT 3
- [Bug]: SyntaxError: Unexpected token HOT 9
- [Bug]: @babel/transform-export-namespace-from is not included after v7.23.3 HOT 11
- [Bug]: Destructuring assignment transformed for chrome 49 HOT 7
- [Bug]: @babel/eslint-parser/experimental-worker hang when .babelrc located in directory HOT 4
- [Bug]: rangeError with retainLines and multi lines comments HOT 1
- [Bug]: @babel/helper-compilation-targets: 'opera_mobile' is not a valid target when upgrading babel/core to 7.23.6 HOT 10
- [Discussion] Set the default `noDocumentAll` to `true` in Babel 8 HOT 2
- [Bug]: `@babel/core` peer dependency of `@babel/[email protected]` produces warnings after install HOT 1
- [Bug]: Instance brand checks defined in static class elements do not work when the class is decorated HOT 1
- [Bug]: class decorator context.kind is 'field', should 'class' HOT 2
- [Bug]: Fails to parse Flow conditional type. HOT 3
- [Bug]: decorators 2023-05: `addInitializer` runs initializer at the wrong time HOT 2
- [Bug]: `path.remove`: crash when there is no `parentPath` HOT 1
- [Bug]: hasOwn is not handled properly HOT 3
- [Bug]: Transpilation Bug with Decorators - Incorrectly Passing 'type: parameter' Instead of 'type: class' HOT 3
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.