forked from AssemblyScript/assemblyscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trailing commas are allowed in these situations in JS/TS: * Array literals * Argument lists * Parameter lists * Enums * Type parameter lists * Type argument lists (Technically filed as microsoft/TypeScript#21984 ) They're also allowed in these cases not (yet) supported by AssemblyScript: * Object literals * Array destructures * Object destructures All of these cases had similar-looking code, which needed to be tweaked to handle the possibility of a comma before the close-delimiter. Type arguments were a little different because they take a backtracking approach. I also fixed a missing case in the AST printer: `export function` wasn't being printed right.
- Loading branch information
1 parent
25a1f62
commit 3ee552c
Showing
4 changed files
with
144 additions
and
83 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,33 @@ | ||
enum Foo { | ||
A, | ||
B, | ||
} | ||
|
||
function add( | ||
x: i32, | ||
y: i32, | ||
): i32 { | ||
return x + y; | ||
} | ||
|
||
function parameterized< | ||
A, | ||
B, | ||
>(a: A, b: B): void { | ||
} | ||
|
||
export function compute(): i32 { | ||
const arr: Array<i8> = [ | ||
1, | ||
2, | ||
]; | ||
parameterized< | ||
i8, | ||
// @ts-ignore: Waiting on https://github.com/Microsoft/TypeScript/issues/21984 | ||
i32, | ||
>(0, 0); | ||
return add( | ||
1, | ||
2, | ||
); | ||
} |
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,13 @@ | ||
enum Foo { | ||
A, | ||
B | ||
} | ||
function add(x: i32, y: i32): i32 { | ||
return x + y; | ||
} | ||
function parameterized<A, B>(a: A, b: B): void {} | ||
export function compute(): i32 { | ||
const arr: Array<i8> = [1, 2]; | ||
parameterized<i8, i32>(0, 0); | ||
return add(1, 2); | ||
} |