-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/transforms/proposal): Fix type detection (#2431)
swc_ecma_transforms_proposal: - Try the type of the LHS of an assignment pattern. (#2428)
- Loading branch information
Showing
7 changed files
with
125 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"tsx": false, | ||
"decorators": true, | ||
"dynamicImport": false | ||
}, | ||
"transform": { | ||
"legacyDecorator": true, | ||
"decoratorMetadata": true | ||
}, | ||
"target": "es2016" | ||
}, | ||
"module": { | ||
"type": "commonjs", | ||
"strict": false, | ||
"strictMode": true, | ||
"lazy": false, | ||
"noInterop": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
class Foo { | ||
async fnName1( | ||
@Arg('GraphQLArgName', { nullable: true }) argName: boolean, | ||
): Promise<number> { } | ||
|
||
async fnName2( | ||
@Arg('GraphQLArgName', { nullable: true }) argName: boolean = false, | ||
): Promise<number> { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
"use strict"; | ||
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { | ||
var desc = { | ||
}; | ||
Object.keys(descriptor).forEach(function(key) { | ||
desc[key] = descriptor[key]; | ||
}); | ||
desc.enumerable = !!desc.enumerable; | ||
desc.configurable = !!desc.configurable; | ||
if ("value" in desc || desc.initializer) { | ||
desc.writable = true; | ||
} | ||
desc = decorators.slice().reverse().reduce(function(desc, decorator) { | ||
return decorator ? decorator(target, property, desc) || desc : desc; | ||
}, desc); | ||
if (context && desc.initializer !== void 0) { | ||
desc.value = desc.initializer ? desc.initializer.call(context) : void 0; | ||
desc.initializer = undefined; | ||
} | ||
if (desc.initializer === void 0) { | ||
Object.defineProperty(target, property, desc); | ||
desc = null; | ||
} | ||
return desc; | ||
} | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _asyncToGenerator(fn) { | ||
return function() { | ||
var self = this, args = arguments; | ||
return new Promise(function(resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(undefined); | ||
}); | ||
}; | ||
} | ||
var _class, _dec, _dec1, _dec2, _dec3, _dec4, _dec5; | ||
let Foo1 = ((_class = class Foo { | ||
fnName1(argName) { | ||
return _asyncToGenerator(function*() { | ||
})(); | ||
} | ||
fnName2(argName = false) { | ||
return _asyncToGenerator(function*() { | ||
})(); | ||
} | ||
}) || _class, _dec = function(target, key) { | ||
return Arg('GraphQLArgName', { | ||
nullable: true | ||
})(target, key, 0); | ||
}, _dec1 = typeof Reflect !== "undefined" && typeof Reflect.metadata === "function" && Reflect.metadata("design:type", Function), _dec2 = typeof Reflect !== "undefined" && typeof Reflect.metadata === "function" && Reflect.metadata("design:paramtypes", [ | ||
Boolean | ||
]), _applyDecoratedDescriptor(_class.prototype, "fnName1", [ | ||
_dec, | ||
_dec1, | ||
_dec2 | ||
], Object.getOwnPropertyDescriptor(_class.prototype, "fnName1"), _class.prototype), _dec3 = function(target, key) { | ||
return Arg('GraphQLArgName', { | ||
nullable: true | ||
})(target, key, 0); | ||
}, _dec4 = typeof Reflect !== "undefined" && typeof Reflect.metadata === "function" && Reflect.metadata("design:type", Function), _dec5 = typeof Reflect !== "undefined" && typeof Reflect.metadata === "function" && Reflect.metadata("design:paramtypes", [ | ||
Boolean | ||
]), _applyDecoratedDescriptor(_class.prototype, "fnName2", [ | ||
_dec3, | ||
_dec4, | ||
_dec5 | ||
], Object.getOwnPropertyDescriptor(_class.prototype, "fnName2"), _class.prototype), _class); |