Fix decorator metadata emit for rest arg with no type
This commit is contained in:
parent
8b093128b3
commit
c0c707c37f
|
@ -6133,10 +6133,10 @@ const _super = (function (geti, seti) {
|
|||
|
||||
if (parameters[i].dotDotDotToken) {
|
||||
let parameterType = parameters[i].type;
|
||||
if (parameterType.kind === SyntaxKind.ArrayType) {
|
||||
if (parameterType && parameterType.kind === SyntaxKind.ArrayType) {
|
||||
parameterType = (<ArrayTypeNode>parameterType).elementType;
|
||||
}
|
||||
else if (parameterType.kind === SyntaxKind.TypeReference && (<TypeReferenceNode>parameterType).typeArguments && (<TypeReferenceNode>parameterType).typeArguments.length === 1) {
|
||||
else if (parameterType && parameterType.kind === SyntaxKind.TypeReference && (<TypeReferenceNode>parameterType).typeArguments && (<TypeReferenceNode>parameterType).typeArguments.length === 1) {
|
||||
parameterType = (<TypeReferenceNode>parameterType).typeArguments[0];
|
||||
}
|
||||
else {
|
||||
|
|
80
tests/baselines/reference/emitDecoratorMetadata_restArgs.js
Normal file
80
tests/baselines/reference/emitDecoratorMetadata_restArgs.js
Normal file
|
@ -0,0 +1,80 @@
|
|||
//// [emitDecoratorMetadata_restArgs.ts]
|
||||
|
||||
declare const MyClassDecorator: ClassDecorator;
|
||||
declare const MyMethodDecorator: MethodDecorator;
|
||||
|
||||
@MyClassDecorator
|
||||
class A {
|
||||
constructor(...args) {}
|
||||
@MyMethodDecorator
|
||||
method(...args) {}
|
||||
}
|
||||
|
||||
@MyClassDecorator
|
||||
class B {
|
||||
constructor(...args: number[]) {}
|
||||
@MyMethodDecorator
|
||||
method(...args: string[]) {}
|
||||
}
|
||||
|
||||
|
||||
//// [emitDecoratorMetadata_restArgs.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var A = (function () {
|
||||
function A() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
A.prototype.method = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
MyMethodDecorator,
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', [Object]),
|
||||
__metadata('design:returntype', void 0)
|
||||
], A.prototype, "method", null);
|
||||
A = __decorate([
|
||||
MyClassDecorator,
|
||||
__metadata('design:paramtypes', [Object])
|
||||
], A);
|
||||
return A;
|
||||
}());
|
||||
var B = (function () {
|
||||
function B() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
B.prototype.method = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
MyMethodDecorator,
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', [String]),
|
||||
__metadata('design:returntype', void 0)
|
||||
], B.prototype, "method", null);
|
||||
B = __decorate([
|
||||
MyClassDecorator,
|
||||
__metadata('design:paramtypes', [Number])
|
||||
], B);
|
||||
return B;
|
||||
}());
|
|
@ -0,0 +1,44 @@
|
|||
=== tests/cases/compiler/emitDecoratorMetadata_restArgs.ts ===
|
||||
|
||||
declare const MyClassDecorator: ClassDecorator;
|
||||
>MyClassDecorator : Symbol(MyClassDecorator, Decl(emitDecoratorMetadata_restArgs.ts, 1, 13))
|
||||
>ClassDecorator : Symbol(ClassDecorator, Decl(lib.d.ts, --, --))
|
||||
|
||||
declare const MyMethodDecorator: MethodDecorator;
|
||||
>MyMethodDecorator : Symbol(MyMethodDecorator, Decl(emitDecoratorMetadata_restArgs.ts, 2, 13))
|
||||
>MethodDecorator : Symbol(MethodDecorator, Decl(lib.d.ts, --, --))
|
||||
|
||||
@MyClassDecorator
|
||||
>MyClassDecorator : Symbol(MyClassDecorator, Decl(emitDecoratorMetadata_restArgs.ts, 1, 13))
|
||||
|
||||
class A {
|
||||
>A : Symbol(A, Decl(emitDecoratorMetadata_restArgs.ts, 2, 49))
|
||||
|
||||
constructor(...args) {}
|
||||
>args : Symbol(args, Decl(emitDecoratorMetadata_restArgs.ts, 6, 16))
|
||||
|
||||
@MyMethodDecorator
|
||||
>MyMethodDecorator : Symbol(MyMethodDecorator, Decl(emitDecoratorMetadata_restArgs.ts, 2, 13))
|
||||
|
||||
method(...args) {}
|
||||
>method : Symbol(A.method, Decl(emitDecoratorMetadata_restArgs.ts, 6, 27))
|
||||
>args : Symbol(args, Decl(emitDecoratorMetadata_restArgs.ts, 8, 11))
|
||||
}
|
||||
|
||||
@MyClassDecorator
|
||||
>MyClassDecorator : Symbol(MyClassDecorator, Decl(emitDecoratorMetadata_restArgs.ts, 1, 13))
|
||||
|
||||
class B {
|
||||
>B : Symbol(B, Decl(emitDecoratorMetadata_restArgs.ts, 9, 1))
|
||||
|
||||
constructor(...args: number[]) {}
|
||||
>args : Symbol(args, Decl(emitDecoratorMetadata_restArgs.ts, 13, 16))
|
||||
|
||||
@MyMethodDecorator
|
||||
>MyMethodDecorator : Symbol(MyMethodDecorator, Decl(emitDecoratorMetadata_restArgs.ts, 2, 13))
|
||||
|
||||
method(...args: string[]) {}
|
||||
>method : Symbol(B.method, Decl(emitDecoratorMetadata_restArgs.ts, 13, 37))
|
||||
>args : Symbol(args, Decl(emitDecoratorMetadata_restArgs.ts, 15, 11))
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
=== tests/cases/compiler/emitDecoratorMetadata_restArgs.ts ===
|
||||
|
||||
declare const MyClassDecorator: ClassDecorator;
|
||||
>MyClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
>ClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
|
||||
declare const MyMethodDecorator: MethodDecorator;
|
||||
>MyMethodDecorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
|
||||
>MethodDecorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
|
||||
|
||||
@MyClassDecorator
|
||||
>MyClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
constructor(...args) {}
|
||||
>args : any[]
|
||||
|
||||
@MyMethodDecorator
|
||||
>MyMethodDecorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
|
||||
|
||||
method(...args) {}
|
||||
>method : (...args: any[]) => void
|
||||
>args : any[]
|
||||
}
|
||||
|
||||
@MyClassDecorator
|
||||
>MyClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
|
||||
class B {
|
||||
>B : B
|
||||
|
||||
constructor(...args: number[]) {}
|
||||
>args : number[]
|
||||
|
||||
@MyMethodDecorator
|
||||
>MyMethodDecorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
|
||||
|
||||
method(...args: string[]) {}
|
||||
>method : (...args: string[]) => void
|
||||
>args : string[]
|
||||
}
|
||||
|
20
tests/cases/compiler/emitDecoratorMetadata_restArgs.ts
Normal file
20
tests/cases/compiler/emitDecoratorMetadata_restArgs.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
// @target: ES5
|
||||
|
||||
declare const MyClassDecorator: ClassDecorator;
|
||||
declare const MyMethodDecorator: MethodDecorator;
|
||||
|
||||
@MyClassDecorator
|
||||
class A {
|
||||
constructor(...args) {}
|
||||
@MyMethodDecorator
|
||||
method(...args) {}
|
||||
}
|
||||
|
||||
@MyClassDecorator
|
||||
class B {
|
||||
constructor(...args: number[]) {}
|
||||
@MyMethodDecorator
|
||||
method(...args: string[]) {}
|
||||
}
|
Loading…
Reference in a new issue