Skip to content

Commit

Permalink
fix: rename typeParameters to typeArguments where needed (#5384)
Browse files Browse the repository at this point in the history
* fix!: rename typeParameters to typeArguments where needed

* Fix type-utils > isUnsafeAssignment

* Ignore the tets, why not

* Corrected visitor-keys

* Got implements, extends, and instantiation expressions

* chore: check package.json existence in package-packages.ts

* Rename superTypeArguments/Parameters too

* Correct superTypeParameter/Argument(s)

* Added deprecated properties too
  • Loading branch information
JoshuaKGoldberg committed Feb 23, 2023
1 parent 217c710 commit 08d757b
Show file tree
Hide file tree
Showing 103 changed files with 6,063 additions and 236 deletions.
4 changes: 4 additions & 0 deletions packages/ast-spec/src/base/ClassBase.ts
Expand Up @@ -61,7 +61,11 @@ export interface ClassBase extends BaseNode {
* The generic type parameters passed to the superClass.
* This is `undefined` if there are no generic type parameters passed.
*/
superTypeArguments?: TSTypeParameterInstantiation;

/** @deprecated Use {@link `superTypeArguments`} instead. */
superTypeParameters?: TSTypeParameterInstantiation;

/**
* The generic type parameters declared for the class.
* This is `undefined` if there are no generic type parameters declared.
Expand Down
3 changes: 3 additions & 0 deletions packages/ast-spec/src/base/TSHeritageBase.ts
Expand Up @@ -5,5 +5,8 @@ import type { BaseNode } from './BaseNode';
export interface TSHeritageBase extends BaseNode {
// TODO(#1852) - this should be restricted to MemberExpression | Identifier
expression: Expression;
typeArguments?: TSTypeParameterInstantiation;

/** @deprecated Use {@link `typeArguments`} instead. */
typeParameters?: TSTypeParameterInstantiation;
}
Expand Up @@ -36,6 +36,26 @@ Program {
end: { column: 21, line: 1 },
},
},
superTypeArguments: TSTypeParameterInstantiation {
type: "TSTypeParameterInstantiation",
params: Array [
TSStringKeyword {
type: "TSStringKeyword",
range: [22, 28],
loc: {
start: { column: 22, line: 1 },
end: { column: 28, line: 1 },
},
},
],
range: [21, 29],
loc: {
start: { column: 21, line: 1 },
end: { column: 29, line: 1 },
},
},
superTypeParameters: TSTypeParameterInstantiation {
type: "TSTypeParameterInstantiation",
params: Array [
Expand Down
Expand Up @@ -2,5 +2,98 @@

exports[`AST Fixtures declaration ClassDeclaration extends-type-param AST Alignment - AST 1`] = `
"Snapshot Diff:
Compared values have no visual difference."
- TSESTree
+ Babel
Program {
type: 'Program',
body: Array [
ClassDeclaration {
type: 'ClassDeclaration',
body: ClassBody {
type: 'ClassBody',
body: Array [],
range: [30, 32],
loc: {
start: { column: 30, line: 1 },
end: { column: 32, line: 1 },
},
},
id: Identifier {
type: 'Identifier',
name: 'Foo',
range: [6, 9],
loc: {
start: { column: 6, line: 1 },
end: { column: 9, line: 1 },
},
},
superClass: Identifier {
type: 'Identifier',
name: 'Set',
range: [18, 21],
loc: {
start: { column: 18, line: 1 },
end: { column: 21, line: 1 },
},
},
- superTypeArguments: TSTypeParameterInstantiation {
- type: 'TSTypeParameterInstantiation',
- params: Array [
- TSStringKeyword {
- type: 'TSStringKeyword',
-
- range: [22, 28],
- loc: {
- start: { column: 22, line: 1 },
- end: { column: 28, line: 1 },
- },
- },
- ],
-
- range: [21, 29],
- loc: {
- start: { column: 21, line: 1 },
- end: { column: 29, line: 1 },
- },
- },
superTypeParameters: TSTypeParameterInstantiation {
type: 'TSTypeParameterInstantiation',
params: Array [
TSStringKeyword {
type: 'TSStringKeyword',
range: [22, 28],
loc: {
start: { column: 22, line: 1 },
end: { column: 28, line: 1 },
},
},
],
range: [21, 29],
loc: {
start: { column: 21, line: 1 },
end: { column: 29, line: 1 },
},
},
range: [0, 32],
loc: {
start: { column: 0, line: 1 },
end: { column: 32, line: 1 },
},
},
],
sourceType: 'script',
range: [0, 33],
loc: {
start: { column: 0, line: 1 },
end: { column: 0, line: 2 },
},
}"
`;
Expand Up @@ -36,6 +36,36 @@ Program {
end: { column: 24, line: 1 },
},
},
superTypeArguments: TSTypeParameterInstantiation {
type: "TSTypeParameterInstantiation",
params: Array [
TSTypeReference {
type: "TSTypeReference",
typeName: Identifier {
type: "Identifier",
name: "T",
range: [25, 26],
loc: {
start: { column: 25, line: 1 },
end: { column: 26, line: 1 },
},
},
range: [25, 26],
loc: {
start: { column: 25, line: 1 },
end: { column: 26, line: 1 },
},
},
],
range: [24, 27],
loc: {
start: { column: 24, line: 1 },
end: { column: 27, line: 1 },
},
},
superTypeParameters: TSTypeParameterInstantiation {
type: "TSTypeParameterInstantiation",
params: Array [
Expand Down
Expand Up @@ -40,6 +40,36 @@ exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-
end: { column: 24, line: 1 },
},
},
- superTypeArguments: TSTypeParameterInstantiation {
- type: 'TSTypeParameterInstantiation',
- params: Array [
- TSTypeReference {
- type: 'TSTypeReference',
- typeName: Identifier {
- type: 'Identifier',
- name: 'T',
-
- range: [25, 26],
- loc: {
- start: { column: 25, line: 1 },
- end: { column: 26, line: 1 },
- },
- },
-
- range: [25, 26],
- loc: {
- start: { column: 25, line: 1 },
- end: { column: 26, line: 1 },
- },
- },
- ],
-
- range: [24, 27],
- loc: {
- start: { column: 24, line: 1 },
- end: { column: 27, line: 1 },
- },
- },
superTypeParameters: TSTypeParameterInstantiation {
type: 'TSTypeParameterInstantiation',
params: Array [
Expand Down
4 changes: 4 additions & 0 deletions packages/ast-spec/src/expression/CallExpression/spec.ts
Expand Up @@ -8,6 +8,10 @@ export interface CallExpression extends BaseNode {
type: AST_NODE_TYPES.CallExpression;
callee: LeftHandSideExpression;
arguments: CallExpressionArgument[];
typeArguments?: TSTypeParameterInstantiation;

/** @deprecated Use {@link `typeArguments`} instead. */
typeParameters?: TSTypeParameterInstantiation;

optional: boolean;
}
3 changes: 3 additions & 0 deletions packages/ast-spec/src/expression/NewExpression/spec.ts
Expand Up @@ -8,5 +8,8 @@ export interface NewExpression extends BaseNode {
type: AST_NODE_TYPES.NewExpression;
callee: LeftHandSideExpression;
arguments: CallExpressionArgument[];
typeArguments?: TSTypeParameterInstantiation;

/** @deprecated Use {@link `typeArguments`} instead. */
typeParameters?: TSTypeParameterInstantiation;
}
Expand Up @@ -6,5 +6,8 @@ import type { Expression } from '../../unions/Expression';
export interface TSInstantiationExpression extends BaseNode {
type: AST_NODE_TYPES.TSInstantiationExpression;
expression: Expression;
typeParameters: TSTypeParameterInstantiation;
typeArguments: TSTypeParameterInstantiation;

/** @deprecated Use {@link `typeArguments`} instead. */
typeParameters?: TSTypeParameterInstantiation;
}
Expand Up @@ -6,7 +6,11 @@ import type { TemplateLiteral } from '../TemplateLiteral/spec';

export interface TaggedTemplateExpression extends BaseNode {
type: AST_NODE_TYPES.TaggedTemplateExpression;
typeArguments?: TSTypeParameterInstantiation;

/** @deprecated Use {@link `typeArguments`} instead. */
typeParameters?: TSTypeParameterInstantiation;

tag: LeftHandSideExpression;
quasi: TemplateLiteral;
}
4 changes: 4 additions & 0 deletions packages/ast-spec/src/jsx/JSXOpeningElement/spec.ts
Expand Up @@ -7,7 +7,11 @@ import type { JSXSpreadAttribute } from '../JSXSpreadAttribute/spec';

export interface JSXOpeningElement extends BaseNode {
type: AST_NODE_TYPES.JSXOpeningElement;
typeArguments?: TSTypeParameterInstantiation;

/** @deprecated Use {@link `typeArguments`} instead. */
typeParameters?: TSTypeParameterInstantiation;

selfClosing: boolean;
name: JSXTagNameExpression;
attributes: (JSXAttribute | JSXSpreadAttribute)[];
Expand Down
Expand Up @@ -41,6 +41,26 @@ Program {
type: "TSTypeAnnotation",
typeAnnotation: TSTypeReference {
type: "TSTypeReference",
typeArguments: TSTypeParameterInstantiation {
type: "TSTypeParameterInstantiation",
params: Array [
TSStringKeyword {
type: "TSStringKeyword",
range: [147, 153],
loc: {
start: { column: 35, line: 4 },
end: { column: 41, line: 4 },
},
},
],
range: [146, 154],
loc: {
start: { column: 34, line: 4 },
end: { column: 42, line: 4 },
},
},
typeName: Identifier {
type: "Identifier",
name: "Promise",
Expand Down
Expand Up @@ -50,6 +50,26 @@ exports[`AST Fixtures legacy-fixtures basics abstract-class-with-abstract-method
type: 'TSTypeAnnotation',
typeAnnotation: TSTypeReference {
type: 'TSTypeReference',
- typeArguments: TSTypeParameterInstantiation {
- type: 'TSTypeParameterInstantiation',
- params: Array [
- TSStringKeyword {
- type: 'TSStringKeyword',
-
- range: [147, 153],
- loc: {
- start: { column: 35, line: 4 },
- end: { column: 41, line: 4 },
- },
- },
- ],
-
- range: [146, 154],
- loc: {
- start: { column: 34, line: 4 },
- end: { column: 42, line: 4 },
- },
- },
typeName: Identifier {
type: 'Identifier',
name: 'Promise',
Expand Down
Expand Up @@ -42,6 +42,26 @@ Program {
type: "TSTypeAnnotation",
typeAnnotation: TSTypeReference {
type: "TSTypeReference",
typeArguments: TSTypeParameterInstantiation {
type: "TSTypeParameterInstantiation",
params: Array [
TSStringKeyword {
type: "TSStringKeyword",
range: [139, 145],
loc: {
start: { column: 27, line: 4 },
end: { column: 33, line: 4 },
},
},
],
range: [138, 146],
loc: {
start: { column: 26, line: 4 },
end: { column: 34, line: 4 },
},
},
typeName: Identifier {
type: "Identifier",
name: "Promise",
Expand Down
Expand Up @@ -48,6 +48,26 @@ exports[`AST Fixtures legacy-fixtures basics abstract-class-with-optional-method
type: 'TSTypeAnnotation',
typeAnnotation: TSTypeReference {
type: 'TSTypeReference',
- typeArguments: TSTypeParameterInstantiation {
- type: 'TSTypeParameterInstantiation',
- params: Array [
- TSStringKeyword {
- type: 'TSStringKeyword',
-
- range: [139, 145],
- loc: {
- start: { column: 27, line: 4 },
- end: { column: 33, line: 4 },
- },
- },
- ],
-
- range: [138, 146],
- loc: {
- start: { column: 26, line: 4 },
- end: { column: 34, line: 4 },
- },
- },
typeName: Identifier {
type: 'Identifier',
name: 'Promise',
Expand Down

0 comments on commit 08d757b

Please sign in to comment.