Skip to content

Commit 3306198

Browse files
armano2JamesHenry
authored andcommitted
fix(ts-estree): align typeArguments and typeParameters across nodes (#223)
1 parent 690bff3 commit 3306198

13 files changed

+4605
-12
lines changed

packages/parser/tests/lib/__snapshots__/typescript.ts.snap

Lines changed: 2284 additions & 0 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo<>();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
new Foo<>()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
function f1<>() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class foo {
2+
constructor<>() {}
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const foo = function<>() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
interface foo {
2+
test<>();
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class foo {
2+
test<>() {}
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
function f1<>() {}

packages/typescript-estree/src/convert.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ export class Converter {
690690
}
691691

692692
// Process typeParameters
693-
if (node.typeParameters && node.typeParameters.length) {
693+
if (node.typeParameters) {
694694
result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
695695
node.typeParameters
696696
);
@@ -897,7 +897,7 @@ export class Converter {
897897
}
898898

899899
// Process typeParameters
900-
if (node.typeParameters && node.typeParameters.length) {
900+
if (node.typeParameters) {
901901
method.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
902902
node.typeParameters
903903
);
@@ -1003,7 +1003,7 @@ export class Converter {
10031003
});
10041004

10051005
// Process typeParameters
1006-
if (node.typeParameters && node.typeParameters.length) {
1006+
if (node.typeParameters) {
10071007
constructor.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
10081008
node.typeParameters
10091009
);
@@ -1060,7 +1060,7 @@ export class Converter {
10601060
}
10611061

10621062
// Process typeParameters
1063-
if (node.typeParameters && node.typeParameters.length) {
1063+
if (node.typeParameters) {
10641064
result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
10651065
node.typeParameters
10661066
);
@@ -1159,7 +1159,7 @@ export class Converter {
11591159
}
11601160

11611161
// Process typeParameters
1162-
if (node.typeParameters && node.typeParameters.length) {
1162+
if (node.typeParameters) {
11631163
result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
11641164
node.typeParameters
11651165
);
@@ -1368,7 +1368,7 @@ export class Converter {
13681368
}
13691369
}
13701370

1371-
if (node.typeParameters && node.typeParameters.length) {
1371+
if (node.typeParameters) {
13721372
result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
13731373
node.typeParameters
13741374
);
@@ -1640,7 +1640,7 @@ export class Converter {
16401640
callee: this.convertChild(node.expression),
16411641
arguments: node.arguments.map(el => this.convertChild(el))
16421642
});
1643-
if (node.typeArguments && node.typeArguments.length) {
1643+
if (node.typeArguments) {
16441644
result.typeParameters = this.convertTypeArgumentsToTypeParameters(
16451645
node.typeArguments
16461646
);
@@ -1656,7 +1656,7 @@ export class Converter {
16561656
? node.arguments.map(el => this.convertChild(el))
16571657
: []
16581658
});
1659-
if (node.typeArguments && node.typeArguments.length) {
1659+
if (node.typeArguments) {
16601660
result.typeParameters = this.convertTypeArgumentsToTypeParameters(
16611661
node.typeArguments
16621662
);
@@ -2060,7 +2060,7 @@ export class Converter {
20602060
}
20612061

20622062
// Process typeParameters
2063-
if (node.typeParameters && node.typeParameters.length) {
2063+
if (node.typeParameters) {
20642064
result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
20652065
node.typeParameters
20662066
);
@@ -2216,7 +2216,7 @@ export class Converter {
22162216
expression: this.convertChild(node.expression)
22172217
});
22182218

2219-
if (node.typeArguments && node.typeArguments.length) {
2219+
if (node.typeArguments) {
22202220
result.typeParameters = this.convertTypeArgumentsToTypeParameters(
22212221
node.typeArguments
22222222
);
@@ -2236,7 +2236,7 @@ export class Converter {
22362236
id: this.convertChild(node.name)
22372237
});
22382238

2239-
if (node.typeParameters && node.typeParameters.length) {
2239+
if (node.typeParameters) {
22402240
result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
22412241
node.typeParameters
22422242
);

0 commit comments

Comments
 (0)