Merge pull request #3249 from Microsoft/resolveDecoratorAsCall

Migrated decorator checks to call resolution
This commit is contained in:
Ron Buckton
2015-06-24 09:58:24 -07:00
51 changed files with 703 additions and 316 deletions

View File

@@ -1,7 +1,7 @@
//// [tests/cases/conformance/decorators/class/decoratedClassFromExternalModule.ts] ////
//// [decorated.ts]
function decorate() { }
function decorate(target: any) { }
@decorate
export default class Decorated { }
@@ -18,7 +18,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
}
};
function decorate() { }
function decorate(target) { }
let Decorated = class {
};
Decorated = __decorate([

View File

@@ -1,12 +1,13 @@
=== tests/cases/conformance/decorators/class/decorated.ts ===
function decorate() { }
function decorate(target: any) { }
>decorate : Symbol(decorate, Decl(decorated.ts, 0, 0))
>target : Symbol(target, Decl(decorated.ts, 0, 18))
@decorate
>decorate : Symbol(decorate, Decl(decorated.ts, 0, 0))
export default class Decorated { }
>Decorated : Symbol(Decorated, Decl(decorated.ts, 0, 23))
>Decorated : Symbol(Decorated, Decl(decorated.ts, 0, 34))
=== tests/cases/conformance/decorators/class/undecorated.ts ===
import Decorated from 'decorated';

View File

@@ -1,9 +1,10 @@
=== tests/cases/conformance/decorators/class/decorated.ts ===
function decorate() { }
>decorate : () => void
function decorate(target: any) { }
>decorate : (target: any) => void
>target : any
@decorate
>decorate : () => void
>decorate : (target: any) => void
export default class Decorated { }
>Decorated : Decorated

View File

@@ -8,7 +8,7 @@ tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts(9,14):
}
class A {
@(x => {
@((x, p) => {
var a = 3;
func(a);
~

View File

@@ -5,7 +5,7 @@ function func(s: string): void {
}
class A {
@(x => {
@((x, p) => {
var a = 3;
func(a);
return x;
@@ -34,7 +34,7 @@ var A = (function () {
};
Object.defineProperty(A.prototype, "m",
__decorate([
(function (x) {
(function (x, p) {
var a = 3;
func(a);
return x;

View File

@@ -9,7 +9,7 @@ export var test = 'abc';
import { test } from './a';
function filter(handler: any) {
return function (target: any) {
return function (target: any, propertyKey: string) {
// ...
};
}
@@ -35,7 +35,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
};
var a_1 = require('./a');
function filter(handler) {
return function (target) {
return function (target, propertyKey) {
// ...
};
}

View File

@@ -12,8 +12,9 @@ function filter(handler: any) {
>filter : Symbol(filter, Decl(b.ts, 0, 27))
>handler : Symbol(handler, Decl(b.ts, 2, 16))
return function (target: any) {
return function (target: any, propertyKey: string) {
>target : Symbol(target, Decl(b.ts, 3, 21))
>propertyKey : Symbol(propertyKey, Decl(b.ts, 3, 33))
// ...
};

View File

@@ -10,12 +10,13 @@ import { test } from './a';
>test : string
function filter(handler: any) {
>filter : (handler: any) => (target: any) => void
>filter : (handler: any) => (target: any, propertyKey: string) => void
>handler : any
return function (target: any) {
>function (target: any) { // ... } : (target: any) => void
return function (target: any, propertyKey: string) {
>function (target: any, propertyKey: string) { // ... } : (target: any, propertyKey: string) => void
>target : any
>propertyKey : string
// ...
};
@@ -25,8 +26,8 @@ class Wat {
>Wat : Wat
@filter(() => test == 'abc')
>filter(() => test == 'abc') : (target: any) => void
>filter : (handler: any) => (target: any) => void
>filter(() => test == 'abc') : (target: any, propertyKey: string) => void
>filter : (handler: any) => (target: any, propertyKey: string) => void
>() => test == 'abc' : () => boolean
>test == 'abc' : boolean
>test : string

View File

@@ -1,4 +1,5 @@
tests/cases/conformance/decorators/class/decoratorOnClass8.ts(3,1): error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: typeof C) => void | typeof C'.
tests/cases/conformance/decorators/class/decoratorOnClass8.ts(3,1): error TS1238: Unable to resolve signature of class decorator when called as an expression.
Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/decorators/class/decoratorOnClass8.ts (1 errors) ====
@@ -6,6 +7,7 @@ tests/cases/conformance/decorators/class/decoratorOnClass8.ts(3,1): error TS2322
@dec()
~~~~~~
!!! error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: typeof C) => void | typeof C'.
!!! error TS1238: Unable to resolve signature of class decorator when called as an expression.
!!! error TS1238: Supplied parameters do not match any signature of call target.
class C {
}

View File

@@ -1,7 +1,5 @@
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts(4,5): error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<() => void>) => void | TypedPropertyDescriptor<() => void>'.
Types of parameters 'paramIndex' and 'propertyKey' are incompatible.
Type 'number' is not assignable to type 'string | symbol'.
Type 'number' is not assignable to type 'symbol'.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts(4,6): error TS2345: Argument of type 'C' is not assignable to parameter of type 'Function'.
Property 'apply' is missing in type 'C'.
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts (1 errors) ====
@@ -9,9 +7,7 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts(4,5)
class C {
@dec method() {}
~~~~
!!! error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<() => void>) => void | TypedPropertyDescriptor<() => void>'.
!!! error TS2322: Types of parameters 'paramIndex' and 'propertyKey' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string | symbol'.
!!! error TS2322: Type 'number' is not assignable to type 'symbol'.
~~~
!!! error TS2345: Argument of type 'C' is not assignable to parameter of type 'Function'.
!!! error TS2345: Property 'apply' is missing in type 'C'.
}

View File

@@ -1,5 +1,5 @@
//// [decoratorOnClassMethod13.ts]
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec ["1"]() { }

View File

@@ -1,17 +1,17 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.ts ===
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
>dec : Symbol(dec, Decl(decoratorOnClassMethod13.ts, 0, 0))
>T : Symbol(T, Decl(decoratorOnClassMethod13.ts, 0, 25))
>target : Symbol(target, Decl(decoratorOnClassMethod13.ts, 0, 28))
>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethod13.ts, 0, 40))
>descriptor : Symbol(descriptor, Decl(decoratorOnClassMethod13.ts, 0, 61))
>T : Symbol(T, Decl(decoratorOnClassMethod13.ts, 0, 21))
>target : Symbol(target, Decl(decoratorOnClassMethod13.ts, 0, 24))
>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethod13.ts, 0, 36))
>descriptor : Symbol(descriptor, Decl(decoratorOnClassMethod13.ts, 0, 57))
>TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, 1171, 36))
>T : Symbol(T, Decl(decoratorOnClassMethod13.ts, 0, 25))
>T : Symbol(T, Decl(decoratorOnClassMethod13.ts, 0, 21))
>TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, 1171, 36))
>T : Symbol(T, Decl(decoratorOnClassMethod13.ts, 0, 25))
>T : Symbol(T, Decl(decoratorOnClassMethod13.ts, 0, 21))
class C {
>C : Symbol(C, Decl(decoratorOnClassMethod13.ts, 0, 132))
>C : Symbol(C, Decl(decoratorOnClassMethod13.ts, 0, 126))
@dec ["1"]() { }
>dec : Symbol(dec, Decl(decoratorOnClassMethod13.ts, 0, 0))

View File

@@ -1,6 +1,6 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.ts ===
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>T : T
>target : any
>propertyKey : string
@@ -14,10 +14,10 @@ class C {
>C : C
@dec ["1"]() { }
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>"1" : string
@dec ["b"]() { }
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>"b" : string
}

View File

@@ -0,0 +1,13 @@
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts(4,5): error TS1241: Unable to resolve signature of method decorator when called as an expression.
Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts (1 errors) ====
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
class C {
@dec ["method"]() {}
~~~~
!!! error TS1241: Unable to resolve signature of method decorator when called as an expression.
!!! error TS1241: Supplied parameters do not match any signature of call target.
}

View File

@@ -1,18 +0,0 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts ===
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
>dec : Symbol(dec, Decl(decoratorOnClassMethod6.ts, 0, 0))
>T : Symbol(T, Decl(decoratorOnClassMethod6.ts, 0, 25))
>target : Symbol(target, Decl(decoratorOnClassMethod6.ts, 0, 28))
>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethod6.ts, 0, 40))
>descriptor : Symbol(descriptor, Decl(decoratorOnClassMethod6.ts, 0, 61))
>TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, 1171, 36))
>T : Symbol(T, Decl(decoratorOnClassMethod6.ts, 0, 25))
>TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, 1171, 36))
>T : Symbol(T, Decl(decoratorOnClassMethod6.ts, 0, 25))
class C {
>C : Symbol(C, Decl(decoratorOnClassMethod6.ts, 0, 132))
@dec ["method"]() {}
>dec : Symbol(dec, Decl(decoratorOnClassMethod6.ts, 0, 0))
}

View File

@@ -1,19 +0,0 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts ===
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>T : T
>target : any
>propertyKey : string
>descriptor : TypedPropertyDescriptor<T>
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
class C {
>C : C
@dec ["method"]() {}
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>"method" : string
}

View File

@@ -0,0 +1,13 @@
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts(4,5): error TS1241: Unable to resolve signature of method decorator when called as an expression.
Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts (1 errors) ====
declare function dec<T>(target: T): T;
class C {
@dec method() {}
~~~~
!!! error TS1241: Unable to resolve signature of method decorator when called as an expression.
!!! error TS1241: Supplied parameters do not match any signature of call target.
}

View File

@@ -1,15 +0,0 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts ===
declare function dec<T>(target: T): T;
>dec : Symbol(dec, Decl(decoratorOnClassMethod8.ts, 0, 0))
>T : Symbol(T, Decl(decoratorOnClassMethod8.ts, 0, 21))
>target : Symbol(target, Decl(decoratorOnClassMethod8.ts, 0, 24))
>T : Symbol(T, Decl(decoratorOnClassMethod8.ts, 0, 21))
>T : Symbol(T, Decl(decoratorOnClassMethod8.ts, 0, 21))
class C {
>C : Symbol(C, Decl(decoratorOnClassMethod8.ts, 0, 38))
@dec method() {}
>dec : Symbol(dec, Decl(decoratorOnClassMethod8.ts, 0, 0))
>method : Symbol(method, Decl(decoratorOnClassMethod8.ts, 2, 9))
}

View File

@@ -1,15 +0,0 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts ===
declare function dec<T>(target: T): T;
>dec : <T>(target: T) => T
>T : T
>target : T
>T : T
>T : T
class C {
>C : C
@dec method() {}
>dec : <T>(target: T) => T
>method : () => void
}

View File

@@ -1,5 +1,5 @@
//// [decoratorOnClassMethodParameter1.ts]
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void;
class C {
method(@dec p: number) {}

View File

@@ -1,13 +1,13 @@
=== tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts ===
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void;
>dec : Symbol(dec, Decl(decoratorOnClassMethodParameter1.ts, 0, 0))
>target : Symbol(target, Decl(decoratorOnClassMethodParameter1.ts, 0, 21))
>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11))
>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethodParameter1.ts, 0, 38))
>parameterIndex : Symbol(parameterIndex, Decl(decoratorOnClassMethodParameter1.ts, 0, 68))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethodParameter1.ts, 0, 36))
>parameterIndex : Symbol(parameterIndex, Decl(decoratorOnClassMethodParameter1.ts, 0, 66))
class C {
>C : Symbol(C, Decl(decoratorOnClassMethodParameter1.ts, 0, 99))
>C : Symbol(C, Decl(decoratorOnClassMethodParameter1.ts, 0, 97))
method(@dec p: number) {}
>method : Symbol(method, Decl(decoratorOnClassMethodParameter1.ts, 2, 9))

View File

@@ -1,8 +1,8 @@
=== tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts ===
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
>dec : (target: Function, propertyKey: string | symbol, parameterIndex: number) => void
>target : Function
>Function : Function
declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void;
>dec : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void
>target : Object
>Object : Object
>propertyKey : string | symbol
>parameterIndex : number
@@ -11,6 +11,6 @@ class C {
method(@dec p: number) {}
>method : (p: number) => void
>dec : (target: Function, propertyKey: string | symbol, parameterIndex: number) => void
>dec : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void
>p : number
}

View File

@@ -0,0 +1,13 @@
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts(4,5): error TS1240: Unable to resolve signature of property decorator when called as an expression.
Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts (1 errors) ====
declare function dec(): <T>(target: any, propertyKey: string) => void;
class C {
@dec prop;
~~~~
!!! error TS1240: Unable to resolve signature of property decorator when called as an expression.
!!! error TS1240: Supplied parameters do not match any signature of call target.
}

View File

@@ -1,14 +0,0 @@
=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts ===
declare function dec(): <T>(target: any, propertyKey: string) => void;
>dec : Symbol(dec, Decl(decoratorOnClassProperty11.ts, 0, 0))
>T : Symbol(T, Decl(decoratorOnClassProperty11.ts, 0, 25))
>target : Symbol(target, Decl(decoratorOnClassProperty11.ts, 0, 28))
>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassProperty11.ts, 0, 40))
class C {
>C : Symbol(C, Decl(decoratorOnClassProperty11.ts, 0, 70))
@dec prop;
>dec : Symbol(dec, Decl(decoratorOnClassProperty11.ts, 0, 0))
>prop : Symbol(prop, Decl(decoratorOnClassProperty11.ts, 2, 9))
}

View File

@@ -1,14 +0,0 @@
=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts ===
declare function dec(): <T>(target: any, propertyKey: string) => void;
>dec : () => <T>(target: any, propertyKey: string) => void
>T : T
>target : any
>propertyKey : string
class C {
>C : C
@dec prop;
>dec : () => <T>(target: any, propertyKey: string) => void
>prop : any
}

View File

@@ -0,0 +1,13 @@
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts(4,5): error TS1240: Unable to resolve signature of property decorator when called as an expression.
Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts (1 errors) ====
declare function dec(target: Function): void;
class C {
@dec prop;
~~~~
!!! error TS1240: Unable to resolve signature of property decorator when called as an expression.
!!! error TS1240: Supplied parameters do not match any signature of call target.
}

View File

@@ -1,13 +0,0 @@
=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts ===
declare function dec(target: Function): void;
>dec : Symbol(dec, Decl(decoratorOnClassProperty6.ts, 0, 0))
>target : Symbol(target, Decl(decoratorOnClassProperty6.ts, 0, 21))
>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11))
class C {
>C : Symbol(C, Decl(decoratorOnClassProperty6.ts, 0, 45))
@dec prop;
>dec : Symbol(dec, Decl(decoratorOnClassProperty6.ts, 0, 0))
>prop : Symbol(prop, Decl(decoratorOnClassProperty6.ts, 2, 9))
}

View File

@@ -1,13 +0,0 @@
=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts ===
declare function dec(target: Function): void;
>dec : (target: Function) => void
>target : Function
>Function : Function
class C {
>C : C
@dec prop;
>dec : (target: Function) => void
>prop : any
}

View File

@@ -1,4 +1,5 @@
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts(4,5): error TS2322: Type '(target: Function, propertyKey: string | symbol, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol) => void'.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts(4,5): error TS1240: Unable to resolve signature of property decorator when called as an expression.
Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts (1 errors) ====
@@ -7,5 +8,6 @@ tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts(4
class C {
@dec prop;
~~~~
!!! error TS2322: Type '(target: Function, propertyKey: string | symbol, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol) => void'.
!!! error TS1240: Unable to resolve signature of property decorator when called as an expression.
!!! error TS1240: Supplied parameters do not match any signature of call target.
}

View File

@@ -1,7 +1,7 @@
error TS2318: Cannot find global type 'ClassDecorator'.
error TS2318: Cannot find global type 'TypedPropertyDescriptor'.
!!! error TS2318: Cannot find global type 'ClassDecorator'.
!!! error TS2318: Cannot find global type 'TypedPropertyDescriptor'.
==== tests/cases/conformance/decorators/a.ts (0 errors) ====
interface Object { }
@@ -14,10 +14,11 @@ error TS2318: Cannot find global type 'ClassDecorator'.
interface IArguments { }
==== tests/cases/conformance/decorators/b.ts (0 errors) ====
declare var dec: any;
declare function dec(t, k, d);
@dec
class C {
@dec
method() {}
}

View File

@@ -12,10 +12,11 @@ interface RegExp { }
interface IArguments { }
//// [b.ts]
declare var dec: any;
declare function dec(t, k, d);
@dec
class C {
@dec
method() {}
}
@@ -33,8 +34,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
var C = (function () {
function C() {
}
C = __decorate([
dec
], C);
C.prototype.method = function () { };
Object.defineProperty(C.prototype, "method",
__decorate([
dec
], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method")));
return C;
})();

View File

@@ -1,6 +1,6 @@
//// [noEmitHelpers2.ts]
function decorator() { }
declare var decorator: any;
@decorator
class A {
@@ -9,7 +9,6 @@ class A {
}
//// [noEmitHelpers2.js]
function decorator() { }
var A = (function () {
function A(a, b) {
}

View File

@@ -1,17 +1,17 @@
=== tests/cases/compiler/noEmitHelpers2.ts ===
function decorator() { }
>decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 0, 0))
declare var decorator: any;
>decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 1, 11))
@decorator
>decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 0, 0))
>decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 1, 11))
class A {
>A : Symbol(A, Decl(noEmitHelpers2.ts, 1, 24))
>A : Symbol(A, Decl(noEmitHelpers2.ts, 1, 27))
constructor(a: number, @decorator b: string) {
>a : Symbol(a, Decl(noEmitHelpers2.ts, 5, 16))
>decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 0, 0))
>decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 1, 11))
>b : Symbol(b, Decl(noEmitHelpers2.ts, 5, 26))
}
}

View File

@@ -1,17 +1,17 @@
=== tests/cases/compiler/noEmitHelpers2.ts ===
function decorator() { }
>decorator : () => void
declare var decorator: any;
>decorator : any
@decorator
>decorator : () => void
>decorator : any
class A {
>A : A
constructor(a: number, @decorator b: string) {
>a : number
>decorator : () => void
>decorator : any
>b : string
}
}

View File

@@ -3,8 +3,8 @@ declare function ClassDecorator1(target: Function): void;
declare function ClassDecorator2(x: number): (target: Function) => void;
declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void;
declare function PropertyDecorator2(x: number): (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void;
declare function ParameterDecorator1(target: Function, key: string | symbol, paramIndex: number): void;
declare function ParameterDecorator2(x: number): (target: Function, key: string | symbol, paramIndex: number) => void;
declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void;
declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void;
@ClassDecorator1
@ClassDecorator2(10)

View File

@@ -26,8 +26,8 @@ sourceFile:sourceMapValidationDecorators.ts
>declare function ClassDecorator2(x: number): (target: Function) => void;
>declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void;
>declare function PropertyDecorator2(x: number): (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void;
>declare function ParameterDecorator1(target: Function, key: string | symbol, paramIndex: number): void;
>declare function ParameterDecorator2(x: number): (target: Function, key: string | symbol, paramIndex: number) => void;
>declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void;
>declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void;
>
>
1 >Emitted(12, 1) Source(8, 1) + SourceIndex(0)

View File

@@ -27,20 +27,20 @@ declare function PropertyDecorator2(x: number): (target: Object, key: string | s
>descriptor : Symbol(descriptor, Decl(sourceMapValidationDecorators.ts, 3, 86))
>PropertyDescriptor : Symbol(PropertyDescriptor, Decl(lib.d.ts, 79, 66))
declare function ParameterDecorator1(target: Function, key: string | symbol, paramIndex: number): void;
declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void;
>ParameterDecorator1 : Symbol(ParameterDecorator1, Decl(sourceMapValidationDecorators.ts, 3, 128))
>target : Symbol(target, Decl(sourceMapValidationDecorators.ts, 4, 37))
>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11))
>key : Symbol(key, Decl(sourceMapValidationDecorators.ts, 4, 54))
>paramIndex : Symbol(paramIndex, Decl(sourceMapValidationDecorators.ts, 4, 76))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>key : Symbol(key, Decl(sourceMapValidationDecorators.ts, 4, 52))
>paramIndex : Symbol(paramIndex, Decl(sourceMapValidationDecorators.ts, 4, 74))
declare function ParameterDecorator2(x: number): (target: Function, key: string | symbol, paramIndex: number) => void;
>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 103))
declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void;
>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 101))
>x : Symbol(x, Decl(sourceMapValidationDecorators.ts, 5, 37))
>target : Symbol(target, Decl(sourceMapValidationDecorators.ts, 5, 50))
>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11))
>key : Symbol(key, Decl(sourceMapValidationDecorators.ts, 5, 67))
>paramIndex : Symbol(paramIndex, Decl(sourceMapValidationDecorators.ts, 5, 89))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>key : Symbol(key, Decl(sourceMapValidationDecorators.ts, 5, 65))
>paramIndex : Symbol(paramIndex, Decl(sourceMapValidationDecorators.ts, 5, 87))
@ClassDecorator1
>ClassDecorator1 : Symbol(ClassDecorator1, Decl(sourceMapValidationDecorators.ts, 0, 0))
@@ -49,14 +49,14 @@ declare function ParameterDecorator2(x: number): (target: Function, key: string
>ClassDecorator2 : Symbol(ClassDecorator2, Decl(sourceMapValidationDecorators.ts, 0, 57))
class Greeter {
>Greeter : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 118))
>Greeter : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 116))
constructor(
@ParameterDecorator1
>ParameterDecorator1 : Symbol(ParameterDecorator1, Decl(sourceMapValidationDecorators.ts, 3, 128))
@ParameterDecorator2(20)
>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 103))
>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 101))
public greeting: string,
>greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16))
@@ -65,7 +65,7 @@ class Greeter {
>ParameterDecorator1 : Symbol(ParameterDecorator1, Decl(sourceMapValidationDecorators.ts, 3, 128))
@ParameterDecorator2(30)
>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 103))
>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 101))
...b: string[]) {
>b : Symbol(b, Decl(sourceMapValidationDecorators.ts, 13, 30))
@@ -82,7 +82,7 @@ class Greeter {
return "<h1>" + this.greeting + "</h1>";
>this.greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16))
>this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 118))
>this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 116))
>greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16))
}
@@ -111,14 +111,14 @@ class Greeter {
>ParameterDecorator1 : Symbol(ParameterDecorator1, Decl(sourceMapValidationDecorators.ts, 3, 128))
@ParameterDecorator2(70)
>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 103))
>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 101))
x: number) {
>x : Symbol(x, Decl(sourceMapValidationDecorators.ts, 34, 15))
return this.greeting;
>this.greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16))
>this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 118))
>this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 116))
>greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16))
}
@@ -133,7 +133,7 @@ class Greeter {
return this.greeting;
>this.greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16))
>this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 118))
>this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 116))
>greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16))
}
@@ -144,14 +144,14 @@ class Greeter {
>ParameterDecorator1 : Symbol(ParameterDecorator1, Decl(sourceMapValidationDecorators.ts, 3, 128))
@ParameterDecorator2(90)
>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 103))
>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 101))
greetings: string) {
>greetings : Symbol(greetings, Decl(sourceMapValidationDecorators.ts, 47, 18))
this.greeting = greetings;
>this.greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16))
>this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 118))
>this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 116))
>greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16))
>greetings : Symbol(greetings, Decl(sourceMapValidationDecorators.ts, 47, 18))
}

View File

@@ -27,18 +27,18 @@ declare function PropertyDecorator2(x: number): (target: Object, key: string | s
>descriptor : PropertyDescriptor
>PropertyDescriptor : PropertyDescriptor
declare function ParameterDecorator1(target: Function, key: string | symbol, paramIndex: number): void;
>ParameterDecorator1 : (target: Function, key: string | symbol, paramIndex: number) => void
>target : Function
>Function : Function
declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void;
>ParameterDecorator1 : (target: Object, key: string | symbol, paramIndex: number) => void
>target : Object
>Object : Object
>key : string | symbol
>paramIndex : number
declare function ParameterDecorator2(x: number): (target: Function, key: string | symbol, paramIndex: number) => void;
>ParameterDecorator2 : (x: number) => (target: Function, key: string | symbol, paramIndex: number) => void
declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void;
>ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void
>x : number
>target : Function
>Function : Function
>target : Object
>Object : Object
>key : string | symbol
>paramIndex : number
@@ -55,22 +55,22 @@ class Greeter {
constructor(
@ParameterDecorator1
>ParameterDecorator1 : (target: Function, key: string | symbol, paramIndex: number) => void
>ParameterDecorator1 : (target: Object, key: string | symbol, paramIndex: number) => void
@ParameterDecorator2(20)
>ParameterDecorator2(20) : (target: Function, key: string | symbol, paramIndex: number) => void
>ParameterDecorator2 : (x: number) => (target: Function, key: string | symbol, paramIndex: number) => void
>ParameterDecorator2(20) : (target: Object, key: string | symbol, paramIndex: number) => void
>ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void
>20 : number
public greeting: string,
>greeting : string
@ParameterDecorator1
>ParameterDecorator1 : (target: Function, key: string | symbol, paramIndex: number) => void
>ParameterDecorator1 : (target: Object, key: string | symbol, paramIndex: number) => void
@ParameterDecorator2(30)
>ParameterDecorator2(30) : (target: Function, key: string | symbol, paramIndex: number) => void
>ParameterDecorator2 : (x: number) => (target: Function, key: string | symbol, paramIndex: number) => void
>ParameterDecorator2(30) : (target: Object, key: string | symbol, paramIndex: number) => void
>ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void
>30 : number
...b: string[]) {
@@ -125,11 +125,11 @@ class Greeter {
>fn : (x: number) => string
@ParameterDecorator1
>ParameterDecorator1 : (target: Function, key: string | symbol, paramIndex: number) => void
>ParameterDecorator1 : (target: Object, key: string | symbol, paramIndex: number) => void
@ParameterDecorator2(70)
>ParameterDecorator2(70) : (target: Function, key: string | symbol, paramIndex: number) => void
>ParameterDecorator2 : (x: number) => (target: Function, key: string | symbol, paramIndex: number) => void
>ParameterDecorator2(70) : (target: Object, key: string | symbol, paramIndex: number) => void
>ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void
>70 : number
x: number) {
@@ -162,11 +162,11 @@ class Greeter {
>greetings : string
@ParameterDecorator1
>ParameterDecorator1 : (target: Function, key: string | symbol, paramIndex: number) => void
>ParameterDecorator1 : (target: Object, key: string | symbol, paramIndex: number) => void
@ParameterDecorator2(90)
>ParameterDecorator2(90) : (target: Function, key: string | symbol, paramIndex: number) => void
>ParameterDecorator2 : (x: number) => (target: Function, key: string | symbol, paramIndex: number) => void
>ParameterDecorator2(90) : (target: Object, key: string | symbol, paramIndex: number) => void
>ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void
>90 : number
greetings: string) {

View File

@@ -3,7 +3,7 @@
// @emitdecoratormetadata: true
// @target: es5
function decorator() { }
declare var decorator: any;
@decorator
class A {

View File

@@ -5,8 +5,8 @@ declare function ClassDecorator1(target: Function): void;
declare function ClassDecorator2(x: number): (target: Function) => void;
declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void;
declare function PropertyDecorator2(x: number): (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void;
declare function ParameterDecorator1(target: Function, key: string | symbol, paramIndex: number): void;
declare function ParameterDecorator2(x: number): (target: Function, key: string | symbol, paramIndex: number) => void;
declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void;
declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void;
@ClassDecorator1
@ClassDecorator2(10)

View File

@@ -1,7 +1,7 @@
// @target: es6
// @experimentaldecorators: true
// @Filename: decorated.ts
function decorate() { }
function decorate(target: any) { }
@decorate
export default class Decorated { }

View File

@@ -6,7 +6,7 @@ function func(s: string): void {
}
class A {
@(x => {
@((x, p) => {
var a = 3;
func(a);
return x;

View File

@@ -10,7 +10,7 @@ export var test = 'abc';
import { test } from './a';
function filter(handler: any) {
return function (target: any) {
return function (target: any, propertyKey: string) {
// ...
};
}

View File

@@ -1,6 +1,6 @@
// @target: ES6
// @experimentaldecorators: true
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec ["1"]() { }

View File

@@ -1,6 +1,6 @@
// @target:es5
// @experimentaldecorators: true
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void;
class C {
method(@dec p: number) {}

View File

@@ -13,9 +13,10 @@ interface RegExp { }
interface IArguments { }
// @Filename: b.ts
declare var dec: any;
declare function dec(t, k, d);
@dec
class C {
@dec
method() {}
}