@@ -22,8 +22,8 @@ test("Class decorator with no parameters", () => {
2222 }
2323
2424 return { decoratedClass: new TestClass(), context: {
25- kind: classDecoratorContext.kind,
26- name: classDecoratorContext.name,
25+ kind: classDecoratorContext! .kind,
26+ name: classDecoratorContext! .name,
2727 } };
2828 ` . expectToMatchJsResult ( ) ;
2929} ) ;
@@ -40,7 +40,7 @@ test("Class decorator with parameters", () => {
4040
4141 @setNum(420)
4242 class TestClass {
43- public decoratorNum;
43+ public decoratorNum?: number ;
4444 }
4545
4646 return new TestClass();
@@ -64,8 +64,8 @@ test("Multiple class decorators", () => {
6464 @setTen
6565 @setNum
6666 class TestClass {
67- public decoratorTen;
68- public decoratorNum;
67+ public decoratorTen?: number ;
68+ public decoratorNum?: number ;
6969 }
7070
7171 return new TestClass();
@@ -95,7 +95,7 @@ test("Class decorator with inheritance", () => {
9595
9696test ( "Class decorators are applied in order and executed in reverse order" , ( ) => {
9797 util . testFunction `
98- const order = [];
98+ const order: string[] = [];
9999
100100 function pushOrder(index: number) {
101101 order.push("eval " + index);
@@ -232,18 +232,18 @@ test("class method decorator", () => {
232232 }
233233
234234 return { result: new TestClass().myMethod(4), context: {
235- kind: methodDecoratorContext.kind,
236- name: methodDecoratorContext.name,
237- private: methodDecoratorContext.private,
238- static: methodDecoratorContext.static
235+ kind: methodDecoratorContext! .kind,
236+ name: methodDecoratorContext! .name,
237+ private: methodDecoratorContext! .private,
238+ static: methodDecoratorContext! .static
239239 } };
240240 ` . expectToMatchJsResult ( ) ;
241241} ) ;
242242
243243test ( "this in decorator points to class being decorated" , ( ) => {
244244 util . testFunction `
245245 function methodDecorator(method: (v: number) => number, context: ClassMethodDecoratorContext) {
246- return function() {
246+ return function(this: TestClass ) {
247247 const thisCallTime = this.myInstanceVariable;
248248 return thisCallTime;
249249 };
@@ -280,10 +280,10 @@ test("class getter decorator", () => {
280280 }
281281
282282 return { result: new TestClass().getterValue, context: {
283- kind: getterDecoratorContext.kind,
284- name: getterDecoratorContext.name,
285- private: getterDecoratorContext.private,
286- static: getterDecoratorContext.static
283+ kind: getterDecoratorContext! .kind,
284+ name: getterDecoratorContext! .name,
285+ private: getterDecoratorContext! .private,
286+ static: getterDecoratorContext! .static
287287 } };
288288 ` . expectToMatchJsResult ( ) ;
289289} ) ;
@@ -295,13 +295,13 @@ test("class setter decorator", () => {
295295 function setterDecorator(setter: (v: number) => void, context: ClassSetterDecoratorContext) {
296296 setterDecoratorContext = context;
297297
298- return function(v: number) {
298+ return function(this: TestClass, v: number) {
299299 setter.call(this, v + 15);
300300 };
301301 }
302302
303303 class TestClass {
304- public value: number;
304+ public value? : number;
305305
306306 @setterDecorator
307307 set valueSetter(v: number) { this.value = v; }
@@ -310,10 +310,10 @@ test("class setter decorator", () => {
310310 const instance = new TestClass();
311311 instance.valueSetter = 23;
312312 return { result: instance.value, context: {
313- kind: setterDecoratorContext.kind,
314- name: setterDecoratorContext.name,
315- private: setterDecoratorContext.private,
316- static: setterDecoratorContext.static
313+ kind: setterDecoratorContext! .kind,
314+ name: setterDecoratorContext! .name,
315+ private: setterDecoratorContext! .private,
316+ static: setterDecoratorContext! .static
317317 } };
318318 ` . expectToMatchJsResult ( ) ;
319319} ) ;
@@ -332,10 +332,10 @@ test("class field decorator", () => {
332332 }
333333
334334 return { result: new TestClass(), context: {
335- kind: fieldDecoratorContext.kind,
336- name: fieldDecoratorContext.name,
337- private: fieldDecoratorContext.private,
338- static: fieldDecoratorContext.static,
335+ kind: fieldDecoratorContext! .kind,
336+ name: fieldDecoratorContext! .name,
337+ private: fieldDecoratorContext! .private,
338+ static: fieldDecoratorContext! .static,
339339 } };
340340 ` . expectToEqual ( {
341341 result : {
@@ -399,7 +399,7 @@ describe("legacy experimentalDecorators", () => {
399399
400400 @setNum(420)
401401 class TestClass {
402- public decoratorNum;
402+ public decoratorNum?: number ;
403403 }
404404
405405 return new TestClass();
@@ -425,8 +425,8 @@ describe("legacy experimentalDecorators", () => {
425425 @setTen
426426 @setNum
427427 class TestClass {
428- public decoratorTen;
429- public decoratorNum;
428+ public decoratorTen?: number ;
429+ public decoratorNum?: number ;
430430 }
431431
432432 return new TestClass();
@@ -460,7 +460,7 @@ describe("legacy experimentalDecorators", () => {
460460
461461 test ( "Class decorators are applied in order and executed in reverse order" , ( ) => {
462462 util . testFunction `
463- const order = [];
463+ const order: string[] = [];
464464
465465 function pushOrder(index: number) {
466466 order.push("eval " + index);
@@ -509,25 +509,25 @@ describe("legacy experimentalDecorators", () => {
509509
510510 test . each ( [
511511 [ "@decorator method() {}" ] ,
512- [ "@decorator property;" ] ,
512+ [ "@decorator property: any ;" ] ,
513513 [ "@decorator propertyWithInitializer = () => {};" ] ,
514- [ "@decorator ['evaluated property'];" ] ,
514+ [ "@decorator ['evaluated property']: any ;" ] ,
515515 [ "@decorator get getter() { return 5 }" ] ,
516- [ "@decorator set setter(value) {}" ] ,
516+ [ "@decorator set setter(value: any ) {}" ] ,
517517 [ "@decorator static method() {}" ] ,
518- [ "@decorator static property;" ] ,
518+ [ "@decorator static property: any ;" ] ,
519519 [ "@decorator static propertyWithInitializer = () => {}" ] ,
520520 [ "@decorator static get getter() { return 5 }" ] ,
521- [ "@decorator static set setter(value) {}" ] ,
522- [ "@decorator static ['evaluated property'];" ] ,
523- [ "method(@decorator a) {}" ] ,
524- [ "static method(@decorator a) {}" ] ,
525- [ "constructor(@decorator a) {}" ] ,
521+ [ "@decorator static set setter(value: any ) {}" ] ,
522+ [ "@decorator static ['evaluated property']: any ;" ] ,
523+ [ "method(@decorator a: any ) {}" ] ,
524+ [ "static method(@decorator a: any ) {}" ] ,
525+ [ "constructor(@decorator a: any ) {}" ] ,
526526 ] ) ( "Decorate class member (%p)" , classMember => {
527527 util . testFunction `
528528 let decoratorParameters: any;
529529
530- const decorator = (target, key, index?) => {
530+ const decorator = (target: any , key: any , index?: any ) => {
531531 const targetKind = target === Foo ? "Foo" : target === Foo.prototype ? "Foo.prototype" : "unknown";
532532 decoratorParameters = { targetKind, key, index: typeof index };
533533 };
@@ -548,10 +548,10 @@ describe("legacy experimentalDecorators", () => {
548548 [ "desc.writable = true" , "return { configurable: true }" ] ,
549549 ] ) ( "Combine decorators (%p + %p)" , ( decorateA , decorateB ) => {
550550 util . testFunction `
551- const A = (target, key, desc): any => { ${ decorateA } };
552- const B = (target, key, desc): any => { ${ decorateB } };
551+ const A = (target: any , key: any , desc: any ): any => { ${ decorateA } };
552+ const B = (target: any , key: any , desc: any ): any => { ${ decorateB } };
553553 class Foo { @A @B static method() {} }
554- const { value, ...rest } = Object.getOwnPropertyDescriptor(Foo, "method");
554+ const { value, ...rest } = Object.getOwnPropertyDescriptor(Foo, "method")! ;
555555 return rest;
556556 `
557557 . setOptions ( { experimentalDecorators : true } )
@@ -562,7 +562,7 @@ describe("legacy experimentalDecorators", () => {
562562 "Use decorator to override method value %s" ,
563563 overrideStatement => {
564564 util . testFunction `
565- const decorator = (target, key, desc): any => { ${ overrideStatement } };
565+ const decorator = (target: any , key: any , desc: any ): any => { ${ overrideStatement } };
566566 class Foo { @decorator static method() {} }
567567 return Foo.method;
568568 `
0 commit comments