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...master
parent
a7793a66ee
commit
a6ec181566
|
@ -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,
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -9,3 +9,5 @@ function f(
|
|||
superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong,
|
||||
...args
|
||||
) {}
|
||||
|
||||
declare class C { f(...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong): void; }
|
||||
|
|
Loading…
Reference in New Issue