Fix crash for single rest on class declaration (#315)

I thought I didn't need to check the length but forgot that the rest argument is not in the list for class declaration. Now it doesn't crash anymore and there's a test...
This commit is contained in:
Christopher Chedeau authored and James Long committed 2017-01-19 10:01:31 -05:00
1 parent a7793a66ee
commit a6ec181566
3 files changed
+11 -1

No files matched your search

+1 -1
View File
@@ -1741,7 +1741,7 @@ function printFunctionParams(path, print, options) {
}
const lastParam = util.getLast(path.getValue().params);
const canHaveTrailingComma = lastParam.type !== "RestElement" && !fun.rest;
const canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
return concat([
"(",
@@ -10,6 +10,8 @@ function f(
superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong,
...args
) {}
declare class C { f(...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong): void; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
declare class C {
f(
@@ -23,5 +25,11 @@ function f(
...args
) {
}
declare class C {
f(
...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong
): void,
}
"
`;
+2
View File
@@ -9,3 +9,5 @@ function f(
superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong,
...args
) {}
declare class C { f(...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong): void; }