Typescript function destructured params (#9431)
* fix typescript funtion destructured params for array * update type name
This commit is contained in:
committed by
Nicolò Ribaudo
parent
fdb65ab8b1
commit
d1514f57bd
@@ -342,17 +342,18 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
tsParseBindingListForSignature(): $ReadOnlyArray<
|
||||
N.Identifier | N.RestElement | N.ObjectPattern,
|
||||
N.Identifier | N.RestElement | N.ObjectPattern | N.ArrayPattern,
|
||||
> {
|
||||
return this.parseBindingList(tt.parenR).map(pattern => {
|
||||
if (
|
||||
pattern.type !== "Identifier" &&
|
||||
pattern.type !== "RestElement" &&
|
||||
pattern.type !== "ObjectPattern"
|
||||
pattern.type !== "ObjectPattern" &&
|
||||
pattern.type !== "ArrayPattern"
|
||||
) {
|
||||
throw this.unexpected(
|
||||
pattern.start,
|
||||
`Name in a signature must be an Identifier or ObjectPattern, instead got ${
|
||||
`Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${
|
||||
pattern.type
|
||||
}`,
|
||||
);
|
||||
@@ -794,6 +795,21 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.match(tt.bracketL)) {
|
||||
let braceStackCounter = 1;
|
||||
this.next();
|
||||
|
||||
while (braceStackCounter > 0) {
|
||||
if (this.match(tt.bracketL)) {
|
||||
++braceStackCounter;
|
||||
} else if (this.match(tt.bracketR)) {
|
||||
--braceStackCounter;
|
||||
}
|
||||
this.next();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1076,7 +1076,9 @@ export type TsSignatureDeclaration =
|
||||
|
||||
export type TsSignatureDeclarationOrIndexSignatureBase = NodeBase & {
|
||||
// Not using TypeScript's "ParameterDeclaration" here, since it's inconsistent with regular functions.
|
||||
parameters: $ReadOnlyArray<Identifier | RestElement | ObjectPattern>,
|
||||
parameters: $ReadOnlyArray<
|
||||
Identifier | RestElement | ObjectPattern | ArrayPattern,
|
||||
>,
|
||||
typeAnnotation: ?TsTypeAnnotation,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user