Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename typeParameters to typeArguments where needed #5384

Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ast-spec/src/expression/CallExpression/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export interface CallExpression extends BaseNode {
type: AST_NODE_TYPES.CallExpression;
callee: LeftHandSideExpression;
arguments: CallExpressionArgument[];
typeParameters?: TSTypeParameterInstantiation;
typeArguments?: TSTypeParameterInstantiation;
optional: boolean;
}
2 changes: 1 addition & 1 deletion packages/ast-spec/src/expression/NewExpression/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export interface NewExpression extends BaseNode {
type: AST_NODE_TYPES.NewExpression;
callee: LeftHandSideExpression;
arguments: CallExpressionArgument[];
typeParameters?: TSTypeParameterInstantiation;
typeArguments?: TSTypeParameterInstantiation;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { TemplateLiteral } from '../TemplateLiteral/spec';

export interface TaggedTemplateExpression extends BaseNode {
type: AST_NODE_TYPES.TaggedTemplateExpression;
typeParameters?: TSTypeParameterInstantiation;
typeArguments?: TSTypeParameterInstantiation;
tag: LeftHandSideExpression;
quasi: TemplateLiteral;
}
2 changes: 1 addition & 1 deletion packages/ast-spec/src/jsx/JSXOpeningElement/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { JSXSpreadAttribute } from '../JSXSpreadAttribute/spec';

export interface JSXOpeningElement extends BaseNode {
type: AST_NODE_TYPES.JSXOpeningElement;
typeParameters?: TSTypeParameterInstantiation;
typeArguments?: TSTypeParameterInstantiation;
selfClosing: boolean;
name: JSXTagNameExpression;
attributes: (JSXAttribute | JSXSpreadAttribute)[];
Expand Down
2 changes: 1 addition & 1 deletion packages/ast-spec/src/type/TSImportType/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export interface TSImportType extends BaseNode {
type: AST_NODE_TYPES.TSImportType;
argument: TypeNode;
qualifier: EntityName | null;
typeParameters: TSTypeParameterInstantiation | null;
typeArguments: TSTypeParameterInstantiation | null;
}
2 changes: 1 addition & 1 deletion packages/ast-spec/src/type/TSTypeQuery/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import type { TSImportType } from '../TSImportType/spec';
export interface TSTypeQuery extends BaseNode {
type: AST_NODE_TYPES.TSTypeQuery;
exprName: EntityName | TSImportType;
typeParameters?: TSTypeParameterInstantiation;
typeArguments?: TSTypeParameterInstantiation;
}
2 changes: 1 addition & 1 deletion packages/ast-spec/src/type/TSTypeReference/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import type { EntityName } from '../../unions/EntityName';

export interface TSTypeReference extends BaseNode {
type: AST_NODE_TYPES.TSTypeReference;
typeArguments?: TSTypeParameterInstantiation;
typeName: EntityName;
typeParameters?: TSTypeParameterInstantiation;
}
10 changes: 5 additions & 5 deletions packages/eslint-plugin/src/rules/array-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ function isSimpleType(node: TSESTree.Node): boolean {
node.typeName.type === AST_NODE_TYPES.Identifier &&
node.typeName.name === 'Array'
) {
if (!node.typeParameters) {
if (!node.typeArguments) {
return true;
}
if (node.typeParameters.params.length === 1) {
return isSimpleType(node.typeParameters.params[0]);
if (node.typeArguments.params.length === 1) {
return isSimpleType(node.typeArguments.params[0]);
}
} else {
if (node.typeParameters) {
if (node.typeArguments) {
return false;
}
return isSimpleType(node.typeName);
Expand Down Expand Up @@ -219,7 +219,7 @@ export default util.createRule<Options, MessageIds>({
}

const readonlyPrefix = isReadonlyArrayType ? 'readonly ' : '';
const typeParams = node.typeParameters?.params;
const typeParams = node.typeArguments?.params;
const messageId =
currentOption === 'array'
? 'errorStringArray'
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/ban-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export default util.createRule<Options, MessageIds>({
TSTypeReference(node): void {
checkBannedTypes(node.typeName);

if (node.typeParameters) {
if (node.typeArguments) {
checkBannedTypes(node);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ export default createRule<Options, MessageIds>({
return;
}
if (mode === 'type-annotation') {
if (!lhs && rhs.typeParameters) {
const { typeParameters, callee } = rhs;
if (!lhs && rhs.typeArguments) {
const { typeArguments, callee } = rhs;
const typeAnnotation =
sourceCode.getText(callee) + sourceCode.getText(typeParameters);
sourceCode.getText(callee) + sourceCode.getText(typeArguments);
context.report({
node,
messageId: 'preferTypeAnnotation',
Expand All @@ -80,7 +80,7 @@ export default createRule<Options, MessageIds>({
return sourceCode.getTokenAfter(node.key)!;
}
return [
fixer.remove(typeParameters),
fixer.remove(typeArguments),
fixer.insertTextAfter(
getIDToAttachAnnotation(),
': ' + typeAnnotation,
Expand All @@ -92,14 +92,14 @@ export default createRule<Options, MessageIds>({
return;
}
if (mode === 'constructor') {
if (lhs?.typeParameters && !rhs.typeParameters) {
if (lhs?.typeArguments && !rhs.typeArguments) {
const hasParens =
sourceCode.getTokenAfter(rhs.callee)?.value === '(';
const extraComments = new Set(
sourceCode.getCommentsInside(lhs.parent),
);
sourceCode
.getCommentsInside(lhs.typeParameters)
.getCommentsInside(lhs.typeArguments)
.forEach(c => extraComments.delete(c));
context.report({
node,
Expand All @@ -114,7 +114,7 @@ export default createRule<Options, MessageIds>({
}
yield fixer.insertTextAfter(
rhs.callee,
sourceCode.getText(lhs.typeParameters),
sourceCode.getText(lhs.typeArguments),
);
if (!hasParens) {
yield fixer.insertTextAfter(rhs.callee, '()');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default createRule<Options, MessageIds>({
return;
}

const params = node.typeParameters?.params;
const params = node.typeArguments?.params;
if (params?.length !== 2) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/func-call-spacing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default util.createRule<Options, MessageIds>({

const closingParenToken = sourceCode.getLastToken(node)!;
const lastCalleeTokenWithoutPossibleParens = sourceCode.getLastToken(
node.typeParameters ?? node.callee,
node.typeArguments ?? node.callee,
)!;
const openingParenToken = sourceCode.getFirstTokenBetween(
lastCalleeTokenWithoutPossibleParens,
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-array-constructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default util.createRule({
node.arguments.length !== 1 &&
node.callee.type === AST_NODE_TYPES.Identifier &&
node.callee.name === 'Array' &&
!node.typeParameters &&
!node.typeArguments &&
!util.isOptionalCallExpression(node)
) {
context.report({
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-extra-parens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default util.createRule<Options, MessageIds>({

if (
node.arguments.length === 1 &&
node.typeParameters?.params.some(
node.typeArguments?.params.some(
param =>
param.type === AST_NODE_TYPES.TSImportType ||
param.type === AST_NODE_TYPES.TSArrayType,
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/no-invalid-void-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ export default util.createRule<[Options], MessageIds>({
validUnionMembers.includes(member.type) ||
// allows any T<..., void, ...> here, checked by checkGenericTypeArgument
(member.type === AST_NODE_TYPES.TSTypeReference &&
member.typeParameters?.type ===
member.typeArguments?.type ===
AST_NODE_TYPES.TSTypeParameterInstantiation &&
member.typeParameters?.params
member.typeArguments?.params
.map(param => param.type)
.includes(AST_NODE_TYPES.TSVoidKeyword)),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-type-alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export default util.createRule<Options, MessageIds>({
const isValidGeneric = (type: TypeWithLabel): boolean => {
return (
type.node.type === AST_NODE_TYPES.TSTypeReference &&
type.node.typeParameters !== undefined
type.node.typeArguments !== undefined
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default util.createRule({
]),
];

if (!callee.parent.typeParameters) {
if (!callee.parent.typeArguments) {
fixes.push(
fixer.insertTextAfter(
callee,
Expand Down
4 changes: 2 additions & 2 deletions packages/scope-manager/src/referencer/ClassVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ class ClassVisitor extends Visitor {
this.#referencer.currentScope().referenceDualValueType(entityName);
}

if (node.typeAnnotation.typeParameters) {
this.visitType(node.typeAnnotation.typeParameters);
if (node.typeAnnotation.typeArguments) {
this.visitType(node.typeAnnotation.typeArguments);
}

// everything is handled now
Expand Down
12 changes: 6 additions & 6 deletions packages/scope-manager/src/referencer/Referencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ class Referencer extends Visitor {
}

protected CallExpression(node: TSESTree.CallExpression): void {
this.visitChildren(node, ['typeParameters']);
this.visitType(node.typeParameters);
this.visitChildren(node, ['typeArguments']);
this.visitType(node.typeArguments);
}

protected CatchClause(node: TSESTree.CatchClause): void {
Expand Down Expand Up @@ -540,7 +540,7 @@ class Referencer extends Visitor {
} else {
this.visit(node.name);
}
this.visitType(node.typeParameters);
this.visitType(node.typeArguments);
for (const attr of node.attributes) {
this.visit(attr);
}
Expand All @@ -562,8 +562,8 @@ class Referencer extends Visitor {
}

protected NewExpression(node: TSESTree.NewExpression): void {
this.visitChildren(node, ['typeParameters']);
this.visitType(node.typeParameters);
this.visitChildren(node, ['typeArguments']);
this.visitType(node.typeArguments);
}

protected PrivateIdentifier(): void {
Expand Down Expand Up @@ -613,7 +613,7 @@ class Referencer extends Visitor {
): void {
this.visit(node.tag);
this.visit(node.quasi);
this.visitType(node.typeParameters);
this.visitType(node.typeArguments);
}

protected TSAsExpression(node: TSESTree.TSAsExpression): void {
Expand Down
4 changes: 2 additions & 2 deletions packages/scope-manager/src/referencer/TypeVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class TypeVisitor extends Visitor {

protected TSImportType(node: TSESTree.TSImportType): void {
// the TS parser allows any type to be the parameter, but it's a syntax error - so we can ignore it
this.visit(node.typeParameters);
this.visit(node.typeArguments);
// the qualifier is just part of a standard EntityName, so it should not be visited
}

Expand Down Expand Up @@ -280,7 +280,7 @@ class TypeVisitor extends Visitor {
this.#referencer.currentScope().referenceValue(entityName);
}

this.visit(node.typeParameters);
this.visit(node.typeArguments);
}

protected TSTypeAnnotation(node: TSESTree.TSTypeAnnotation): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/type-utils/src/isUnsafeAssignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function isUnsafeAssignment(
senderNode.callee.type === AST_NODE_TYPES.Identifier &&
senderNode.callee.name === 'Map' &&
senderNode.arguments.length === 0 &&
senderNode.typeParameters == null
senderNode.typeArguments == null
) {
// special case to handle `new Map()`
// unfortunately Map's default empty constructor is typed to return `Map<any, any>` :(
Expand Down