Implemented a fix to initializers+class-properties
This commit is contained in:
parent
8e5f2dc929
commit
c8c6ff7c4c
3
Makefile
3
Makefile
@ -191,6 +191,9 @@ new-version:
|
||||
git pull --rebase
|
||||
yarn lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone"
|
||||
|
||||
publish-cerxes:
|
||||
yarn lerna publish from-package --registry npm.cerxes.net --no-git-tag-version --no-push --no-git-reset --allow-branch initializer-fix --no-verify-access
|
||||
|
||||
# NOTE: Run make new-version first
|
||||
publish: prepublish
|
||||
yarn lerna publish from-git
|
||||
|
||||
@ -4,10 +4,17 @@
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<span style="color:darkred">
|
||||
<b><i>WARNING</i> This is a fork of babel to test a fix for initializer-variables with class-properties (proposals-stuff)</b>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
The compiler for writing next generation JavaScript.
|
||||
</p>
|
||||
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/package/@babel/core"><img alt="v7 npm Downloads" src="https://img.shields.io/npm/dm/@babel/core.svg?maxAge=43200&label=v7%20downloads"></a>
|
||||
<a href="https://www.npmjs.com/package/babel-core"><img alt="v6 npm Downloads" src="https://img.shields.io/npm/dm/babel-core.svg?maxAge=43200&label=v6%20downloads"></a>
|
||||
|
||||
@ -1053,16 +1053,20 @@ helpers.initializerWarningHelper = helper("7.0.0-beta.0")`
|
||||
* Add a helper to call as a replacement for class property definition.
|
||||
*/
|
||||
helpers.initializerDefineProperty = helper("7.0.0-beta.0")`
|
||||
export default function _initializerDefineProperty(target, property, descriptor, context){
|
||||
if (!descriptor) return;
|
||||
export default function _initializerDefineProperty(target, property, descriptor, context) {
|
||||
if (!descriptor) return;
|
||||
|
||||
Object.defineProperty(target, property, {
|
||||
enumerable: descriptor.enumerable,
|
||||
configurable: descriptor.configurable,
|
||||
writable: descriptor.writable,
|
||||
value: descriptor.initializer ? descriptor.initializer.call(context) : void 0,
|
||||
});
|
||||
}
|
||||
if(descriptor.initializer){
|
||||
if(descriptor.set){
|
||||
descriptor.set.call(context, descriptor.initializer.call(context));
|
||||
}else{
|
||||
descriptor.value = descriptor.initializer.call(context);
|
||||
}
|
||||
delete descriptor.initializer;
|
||||
}
|
||||
|
||||
Object.defineProperty(target, property, descriptor);
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user