Only allow TSParameterProperty in ClassMethod parameters (#13349)
This commit is contained in:
parent
d6a5f6190d
commit
b1f57e5fb5
@ -481,7 +481,7 @@ export interface ForStatement extends BaseNode {
|
|||||||
export interface FunctionDeclaration extends BaseNode {
|
export interface FunctionDeclaration extends BaseNode {
|
||||||
type: "FunctionDeclaration";
|
type: "FunctionDeclaration";
|
||||||
id?: Identifier | null;
|
id?: Identifier | null;
|
||||||
params: Array<Identifier | Pattern | RestElement | TSParameterProperty>;
|
params: Array<Identifier | Pattern | RestElement>;
|
||||||
body: BlockStatement;
|
body: BlockStatement;
|
||||||
generator?: boolean;
|
generator?: boolean;
|
||||||
async?: boolean;
|
async?: boolean;
|
||||||
@ -497,7 +497,7 @@ export interface FunctionDeclaration extends BaseNode {
|
|||||||
export interface FunctionExpression extends BaseNode {
|
export interface FunctionExpression extends BaseNode {
|
||||||
type: "FunctionExpression";
|
type: "FunctionExpression";
|
||||||
id?: Identifier | null;
|
id?: Identifier | null;
|
||||||
params: Array<Identifier | Pattern | RestElement | TSParameterProperty>;
|
params: Array<Identifier | Pattern | RestElement>;
|
||||||
body: BlockStatement;
|
body: BlockStatement;
|
||||||
generator?: boolean;
|
generator?: boolean;
|
||||||
async?: boolean;
|
async?: boolean;
|
||||||
@ -616,7 +616,7 @@ export interface ObjectMethod extends BaseNode {
|
|||||||
type: "ObjectMethod";
|
type: "ObjectMethod";
|
||||||
kind: "method" | "get" | "set";
|
kind: "method" | "get" | "set";
|
||||||
key: Expression | Identifier | StringLiteral | NumericLiteral;
|
key: Expression | Identifier | StringLiteral | NumericLiteral;
|
||||||
params: Array<Identifier | Pattern | RestElement | TSParameterProperty>;
|
params: Array<Identifier | Pattern | RestElement>;
|
||||||
body: BlockStatement;
|
body: BlockStatement;
|
||||||
computed: boolean;
|
computed: boolean;
|
||||||
generator?: boolean;
|
generator?: boolean;
|
||||||
@ -756,7 +756,7 @@ export interface ArrayPattern extends BaseNode {
|
|||||||
|
|
||||||
export interface ArrowFunctionExpression extends BaseNode {
|
export interface ArrowFunctionExpression extends BaseNode {
|
||||||
type: "ArrowFunctionExpression";
|
type: "ArrowFunctionExpression";
|
||||||
params: Array<Identifier | Pattern | RestElement | TSParameterProperty>;
|
params: Array<Identifier | Pattern | RestElement>;
|
||||||
body: BlockStatement | Expression;
|
body: BlockStatement | Expression;
|
||||||
async?: boolean;
|
async?: boolean;
|
||||||
expression: boolean;
|
expression: boolean;
|
||||||
@ -1658,7 +1658,7 @@ export interface TSDeclareFunction extends BaseNode {
|
|||||||
type: "TSDeclareFunction";
|
type: "TSDeclareFunction";
|
||||||
id?: Identifier | null;
|
id?: Identifier | null;
|
||||||
typeParameters?: TSTypeParameterDeclaration | Noop | null;
|
typeParameters?: TSTypeParameterDeclaration | Noop | null;
|
||||||
params: Array<Identifier | Pattern | RestElement | TSParameterProperty>;
|
params: Array<Identifier | Pattern | RestElement>;
|
||||||
returnType?: TSTypeAnnotation | Noop | null;
|
returnType?: TSTypeAnnotation | Noop | null;
|
||||||
async?: boolean;
|
async?: boolean;
|
||||||
declare?: boolean | null;
|
declare?: boolean | null;
|
||||||
|
|||||||
@ -133,9 +133,7 @@ export function forStatement(
|
|||||||
}
|
}
|
||||||
export function functionDeclaration(
|
export function functionDeclaration(
|
||||||
id: t.Identifier | null | undefined,
|
id: t.Identifier | null | undefined,
|
||||||
params: Array<
|
params: Array<t.Identifier | t.Pattern | t.RestElement>,
|
||||||
t.Identifier | t.Pattern | t.RestElement | t.TSParameterProperty
|
|
||||||
>,
|
|
||||||
body: t.BlockStatement,
|
body: t.BlockStatement,
|
||||||
generator?: boolean,
|
generator?: boolean,
|
||||||
async?: boolean,
|
async?: boolean,
|
||||||
@ -144,9 +142,7 @@ export function functionDeclaration(
|
|||||||
}
|
}
|
||||||
export function functionExpression(
|
export function functionExpression(
|
||||||
id: t.Identifier | null | undefined,
|
id: t.Identifier | null | undefined,
|
||||||
params: Array<
|
params: Array<t.Identifier | t.Pattern | t.RestElement>,
|
||||||
t.Identifier | t.Pattern | t.RestElement | t.TSParameterProperty
|
|
||||||
>,
|
|
||||||
body: t.BlockStatement,
|
body: t.BlockStatement,
|
||||||
generator?: boolean,
|
generator?: boolean,
|
||||||
async?: boolean,
|
async?: boolean,
|
||||||
@ -226,9 +222,7 @@ export function objectExpression(
|
|||||||
export function objectMethod(
|
export function objectMethod(
|
||||||
kind: "method" | "get" | "set" | undefined,
|
kind: "method" | "get" | "set" | undefined,
|
||||||
key: t.Expression | t.Identifier | t.StringLiteral | t.NumericLiteral,
|
key: t.Expression | t.Identifier | t.StringLiteral | t.NumericLiteral,
|
||||||
params: Array<
|
params: Array<t.Identifier | t.Pattern | t.RestElement>,
|
||||||
t.Identifier | t.Pattern | t.RestElement | t.TSParameterProperty
|
|
||||||
>,
|
|
||||||
body: t.BlockStatement,
|
body: t.BlockStatement,
|
||||||
computed?: boolean,
|
computed?: boolean,
|
||||||
generator?: boolean,
|
generator?: boolean,
|
||||||
@ -338,9 +332,7 @@ export function arrayPattern(
|
|||||||
return builder("ArrayPattern", ...arguments);
|
return builder("ArrayPattern", ...arguments);
|
||||||
}
|
}
|
||||||
export function arrowFunctionExpression(
|
export function arrowFunctionExpression(
|
||||||
params: Array<
|
params: Array<t.Identifier | t.Pattern | t.RestElement>,
|
||||||
t.Identifier | t.Pattern | t.RestElement | t.TSParameterProperty
|
|
||||||
>,
|
|
||||||
body: t.BlockStatement | t.Expression,
|
body: t.BlockStatement | t.Expression,
|
||||||
async?: boolean,
|
async?: boolean,
|
||||||
): t.ArrowFunctionExpression {
|
): t.ArrowFunctionExpression {
|
||||||
@ -1093,9 +1085,7 @@ export { tsParameterProperty as tSParameterProperty };
|
|||||||
export function tsDeclareFunction(
|
export function tsDeclareFunction(
|
||||||
id: t.Identifier | null | undefined,
|
id: t.Identifier | null | undefined,
|
||||||
typeParameters: t.TSTypeParameterDeclaration | t.Noop | null | undefined,
|
typeParameters: t.TSTypeParameterDeclaration | t.Noop | null | undefined,
|
||||||
params: Array<
|
params: Array<t.Identifier | t.Pattern | t.RestElement>,
|
||||||
t.Identifier | t.Pattern | t.RestElement | t.TSParameterProperty
|
|
||||||
>,
|
|
||||||
returnType?: t.TSTypeAnnotation | t.Noop | null,
|
returnType?: t.TSTypeAnnotation | t.Noop | null,
|
||||||
): t.TSDeclareFunction {
|
): t.TSDeclareFunction {
|
||||||
return builder("TSDeclareFunction", ...arguments);
|
return builder("TSDeclareFunction", ...arguments);
|
||||||
|
|||||||
@ -353,14 +353,7 @@ export const functionCommon = {
|
|||||||
params: {
|
params: {
|
||||||
validate: chain(
|
validate: chain(
|
||||||
assertValueType("array"),
|
assertValueType("array"),
|
||||||
assertEach(
|
assertEach(assertNodeType("Identifier", "Pattern", "RestElement")),
|
||||||
assertNodeType(
|
|
||||||
"Identifier",
|
|
||||||
"Pattern",
|
|
||||||
"RestElement",
|
|
||||||
"TSParameterProperty",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
generator: {
|
generator: {
|
||||||
@ -1743,6 +1736,19 @@ export const classMethodOrPropertyCommon = {
|
|||||||
export const classMethodOrDeclareMethodCommon = {
|
export const classMethodOrDeclareMethodCommon = {
|
||||||
...functionCommon,
|
...functionCommon,
|
||||||
...classMethodOrPropertyCommon,
|
...classMethodOrPropertyCommon,
|
||||||
|
params: {
|
||||||
|
validate: chain(
|
||||||
|
assertValueType("array"),
|
||||||
|
assertEach(
|
||||||
|
assertNodeType(
|
||||||
|
"Identifier",
|
||||||
|
"Pattern",
|
||||||
|
"RestElement",
|
||||||
|
"TSParameterProperty",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
},
|
||||||
kind: {
|
kind: {
|
||||||
validate: assertOneOf("get", "set", "method", "constructor"),
|
validate: assertOneOf("get", "set", "method", "constructor"),
|
||||||
default: "method",
|
default: "method",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user