From 2aa23e2f3c93339104433be272260314d162215c Mon Sep 17 00:00:00 2001 From: Ivo Stratev Date: Thu, 8 Sep 2016 19:10:56 +0300 Subject: [PATCH 1/7] Create autobind-decorator.d.ts --- autobind-decorator/autobind-decorator.d.ts | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 autobind-decorator/autobind-decorator.d.ts diff --git a/autobind-decorator/autobind-decorator.d.ts b/autobind-decorator/autobind-decorator.d.ts new file mode 100644 index 0000000000..a87c911ae5 --- /dev/null +++ b/autobind-decorator/autobind-decorator.d.ts @@ -0,0 +1,5 @@ +declare module 'autobind-decorator' { + function autobind(target: TFunction): TFunction | void; + function autobind(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void; + export = autobind; +} From 1e2fe02942c1f7ee1732fb5e725d3e2194e75e50 Mon Sep 17 00:00:00 2001 From: Ivo Stratev Date: Thu, 8 Sep 2016 19:18:35 +0300 Subject: [PATCH 2/7] Create autobind-decorator-tests.ts --- .../autobind-decorator-tests.ts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 autobind-decorator/autobind-decorator-tests.ts diff --git a/autobind-decorator/autobind-decorator-tests.ts b/autobind-decorator/autobind-decorator-tests.ts new file mode 100644 index 0000000000..7ee65a60b9 --- /dev/null +++ b/autobind-decorator/autobind-decorator-tests.ts @@ -0,0 +1,43 @@ +/// + +import autobind = require('autobind-decorator'); + +class Test { + public static what: string = 'static'; + + @bind + public static test(): void { + console.log(this.what); + } + + public constructor(public what: string) { + this.what = what; + } + + @bind + public test(): void { + console.warn(this.what); + } +} + +const tester: Test = new Test('bind'); +const { test } = tester; +tester.test(); // warns 'bind'. +test(); // warns 'bind'. +Test.test(); // logs 'static'. + +@autobind +class Component { + public constructor(private someMember: string) { + this.someMember = someMember; + } + + public somMethod(): void { + console.error(this.someMember); + } +} + +const component: Component = new Component('React vs Angular2'); +const { somMethod } = component; +component.someMethod(); // errors 'React vs Angular2' +somMethod(); // errors 'React vs Angular2' From 308869aa2e86c2ba3a21c4671277f19e1a2e6f6d Mon Sep 17 00:00:00 2001 From: Ivo Stratev Date: Thu, 8 Sep 2016 19:19:27 +0300 Subject: [PATCH 3/7] Fixing tests idntation --- autobind-decorator/autobind-decorator-tests.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/autobind-decorator/autobind-decorator-tests.ts b/autobind-decorator/autobind-decorator-tests.ts index 7ee65a60b9..7e784ce226 100644 --- a/autobind-decorator/autobind-decorator-tests.ts +++ b/autobind-decorator/autobind-decorator-tests.ts @@ -28,13 +28,13 @@ Test.test(); // logs 'static'. @autobind class Component { - public constructor(private someMember: string) { - this.someMember = someMember; - } + public constructor(private someMember: string) { + this.someMember = someMember; + } - public somMethod(): void { - console.error(this.someMember); - } + public somMethod(): void { + console.error(this.someMember); + } } const component: Component = new Component('React vs Angular2'); From 8bd86aa6824e2825e2c7d5d07ea7ad10019c4b71 Mon Sep 17 00:00:00 2001 From: Ivo Stratev Date: Thu, 8 Sep 2016 19:21:01 +0300 Subject: [PATCH 4/7] Create autobind-decorator.ts.tscparams --- autobind-decorator/autobind-decorator.ts.tscparams | 1 + 1 file changed, 1 insertion(+) create mode 100644 autobind-decorator/autobind-decorator.ts.tscparams diff --git a/autobind-decorator/autobind-decorator.ts.tscparams b/autobind-decorator/autobind-decorator.ts.tscparams new file mode 100644 index 0000000000..1ee3d05cb6 --- /dev/null +++ b/autobind-decorator/autobind-decorator.ts.tscparams @@ -0,0 +1 @@ +--experimentalDecorators From 9bac2b088a96bf2ef474f594ba5ca9e7d55076bf Mon Sep 17 00:00:00 2001 From: Ivo Stratev Date: Thu, 8 Sep 2016 19:21:51 +0300 Subject: [PATCH 5/7] Fixing decorating name --- autobind-decorator/autobind-decorator-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autobind-decorator/autobind-decorator-tests.ts b/autobind-decorator/autobind-decorator-tests.ts index 7e784ce226..693e070183 100644 --- a/autobind-decorator/autobind-decorator-tests.ts +++ b/autobind-decorator/autobind-decorator-tests.ts @@ -5,7 +5,7 @@ import autobind = require('autobind-decorator'); class Test { public static what: string = 'static'; - @bind + @autobind public static test(): void { console.log(this.what); } @@ -14,7 +14,7 @@ class Test { this.what = what; } - @bind + @autobind public test(): void { console.warn(this.what); } From ee881e7d74e267fca5975d62cb7e6befb6a91014 Mon Sep 17 00:00:00 2001 From: Ivo Stratev Date: Thu, 8 Sep 2016 19:25:17 +0300 Subject: [PATCH 6/7] Adding header --- autobind-decorator/autobind-decorator.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autobind-decorator/autobind-decorator.d.ts b/autobind-decorator/autobind-decorator.d.ts index a87c911ae5..51ba89c9bf 100644 --- a/autobind-decorator/autobind-decorator.d.ts +++ b/autobind-decorator/autobind-decorator.d.ts @@ -1,3 +1,8 @@ +// Type definitions for autobind-decorator v1.3.3 +// Project: https://github.com/andreypopp/autobind-decorator +// Definitions by: Ivo Stratev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + declare module 'autobind-decorator' { function autobind(target: TFunction): TFunction | void; function autobind(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void; From edf96fdd215887aef916644763b39db70965fda1 Mon Sep 17 00:00:00 2001 From: Ivo Stratev Date: Thu, 8 Sep 2016 19:29:39 +0300 Subject: [PATCH 7/7] Fixing method naming --- autobind-decorator/autobind-decorator-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autobind-decorator/autobind-decorator-tests.ts b/autobind-decorator/autobind-decorator-tests.ts index 693e070183..e428604802 100644 --- a/autobind-decorator/autobind-decorator-tests.ts +++ b/autobind-decorator/autobind-decorator-tests.ts @@ -32,12 +32,12 @@ class Component { this.someMember = someMember; } - public somMethod(): void { + public someMethod(): void { console.error(this.someMember); } } const component: Component = new Component('React vs Angular2'); -const { somMethod } = component; +const { someMethod } = component; component.someMethod(); // errors 'React vs Angular2' -somMethod(); // errors 'React vs Angular2' +someMethod(); // errors 'React vs Angular2'