@@ -5,7 +5,7 @@ import { unsupportedForTarget } from "../../../src/transformation/utils/diagnost
55
66test ( "Arrow Function Expression" , ( ) => {
77 util . testFunction `
8- const add = (a, b) => a + b;
8+ const add = (a: number , b: number ) => a + b;
99 return add(1, 2);
1010 ` . expectToMatchJsResult ( ) ;
1111} ) ;
@@ -25,17 +25,22 @@ test.each(["i++", "i--", "++i", "--i"])("Arrow function unary expression (%p)",
2525 ` . expectToMatchJsResult ( ) ;
2626} ) ;
2727
28- test . each ( [ "b => a = b" , "b => a += b" , "b => a -= b" , "b => a *= b" , "b => a /= b" , "b => a **= b" , "b => a %= b" ] ) (
29- "Arrow function assignment (%p)" ,
30- lambda => {
31- util . testFunction `
28+ test . each ( [
29+ "(b: number) => a = b" ,
30+ "(b: number) => a += b" ,
31+ "(b: number) => a -= b" ,
32+ "(b: number) => a *= b" ,
33+ "(b: number) => a /= b" ,
34+ "(b: number) => a **= b" ,
35+ "(b: number) => a %= b" ,
36+ ] ) ( "Arrow function assignment (%p)" , lambda => {
37+ util . testFunction `
3238 let a = 10;
3339 let lambda = ${ lambda } ;
3440 lambda(5);
3541 return a;
3642 ` . expectToMatchJsResult ( ) ;
37- }
38- ) ;
43+ } ) ;
3944
4045test . each ( [ { args : [ ] } , { args : [ 1 ] } , { args : [ 1 , 2 ] } ] ) ( "Arrow default values (%p)" , ( { args } ) => {
4146 util . testFunction `
@@ -46,7 +51,7 @@ test.each([{ args: [] }, { args: [1] }, { args: [1, 2] }])("Arrow default values
4651
4752test ( "Function Expression" , ( ) => {
4853 util . testFunction `
49- let add = function(a, b) {return a+b};
54+ let add = function(a: number , b: number ) {return a+b};
5055 return add(1,2);
5156 ` . expectToMatchJsResult ( ) ;
5257} ) ;
@@ -251,13 +256,13 @@ test.each(functionTypeDeclarations)("Function call (%s)", (_, type) => {
251256} ) ;
252257
253258test . each ( [
254- "function fn() {}" ,
255- "function fn(x, y, z) {}" ,
256- "function fn(x, y, z, ...args) {}" ,
257- "function fn(...args) {}" ,
258- "function fn(this: void) {}" ,
259- "function fn(this: void, x, y, z) {}" ,
260- "function fnReference(x, y, z) {} const fn = fnReference;" ,
259+ "function fn(): void {}" ,
260+ "function fn(x: any , y: any , z: any): void {}" ,
261+ "function fn(x: any , y: any , z: any , ...args: any[]): void {}" ,
262+ "function fn(...args: any[]): void {}" ,
263+ "function fn(this: void): void {}" ,
264+ "function fn(this: void, x: any , y: any , z: any): void {}" ,
265+ "function fnReference(x: any , y: any , z: any): void {} const fn = fnReference;" ,
261266 "const wrap = (fn: (...args: any[]) => any) => (...args: any[]) => fn(...args); const fn = wrap((x, y, z) => {});" ,
262267] ) ( "function.length (%p)" , declaration => {
263268 util . testFunction `
@@ -432,7 +437,7 @@ test("Complex element access call no args", () => {
432437
433438test ( "Complex element access call statement" , ( ) => {
434439 util . testFunction `
435- let foo: string;
440+ let foo: string | undefined ;
436441 class C {
437442 prop = "bar";
438443 method(s: string) { foo = s + this.prop; }
0 commit comments