-
-
Notifications
You must be signed in to change notification settings - Fork 670
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support rest params in function calls (#2905)
- Loading branch information
1 parent
cdd5e01
commit 6e151f8
Showing
11 changed files
with
11,397 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"asc_flags": [ | ||
], | ||
"stderr": [ | ||
"TS2322: Type '~lib/string/String' is not assignable to type 'i32'.", | ||
"sum('a', 'b')", | ||
"TS2322: Type '~lib/string/String' is not assignable to type 'i32'.", | ||
"sum('a', 'b')", | ||
"TS2322: Type '~lib/string/String' is not assignable to type 'i32'.", | ||
"count(1, 'a')", | ||
"TS1140: Type argument expected.", | ||
"count()" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function sum(...args: i32[]): i32 { | ||
let sum = 0; | ||
for (let i = 0, k = args.length; i < k; ++i) { | ||
sum += args[i]; | ||
} | ||
return sum; | ||
} | ||
|
||
function count<T>(...args: T[]): i32 { | ||
return args.length; | ||
} | ||
|
||
sum('a', 'b'); // expect a type mismatch error on each argument | ||
count(1, 'a'); // expect a type mismatch error on the second argument | ||
count(); // expect type inference error |
Oops, something went wrong.