8000 fix(ts-estree): align typeArguments and typeParameters across nodes by armano2 · Pull Request #223 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

fix(ts-estree): align typeArguments and typeParameters across nodes #223

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

Merged
merged 1 commit into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,284 changes: 2,284 additions & 0 deletions packages/parser/tests/lib/__snapshots__/typescript.ts.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo<>();
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
new Foo<>()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function f1<>() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class foo {
constructor<>() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const foo = function<>() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface foo {
test<>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class foo {
test<>() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function f1<>() {}
22 changes: 11 additions & 11 deletions packages/typescript-estree/src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ export class Converter {
}

// Process typeParameters
if (node.typeParameters && node.typeParameters.length) {
if (node.typeParameters) {
result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
node.typeParameters
);
Expand Down Expand Up @@ -897,7 +897,7 @@ export class Converter {
}

// Process typeParameters
if (node.typeParameters && node.typeParameters.length) {
if (node.typeParameters) {
method.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
node.typeParameters
);
Expand Down Expand Up @@ -1003,7 +1003,7 @@ export class Converter {
});

// Process typeParameters
if (node.typeParameters && node.typeParameters.length) {
if (node.typeParameters) {
constructor.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
node.typeParameters
);
Expand Down Expand Up @@ -1060,7 +1060,7 @@ export class Converter {
}

// Process typeParameters
if (node.typeParameters && node.typeParameters.length) {
if (node.typeParameters) {
result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
node.typeParameters
);
Expand Down Expand Up @@ -1159,7 +1159,7 @@ export class Converter {
}

// Process typeParameters
if (node.typeParameters && node.typeParameters.length) {
if (node.typeParameters) {
result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
node.typeParameters
);
Expand Down Expand Up @@ -1368,7 +1368,7 @@ export class Converter {
}
}

if (node.typeParameters && node.typeParameters.length) {
if (node.typeParameters) {
result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
node.typeParameters
);
Expand Down Expand Up @@ -1640,7 +1640,7 @@ export class Converter {
callee: this.convertChild(node.expression),
arguments: node.arguments.map(el => this.convertChild(el))
});
if (node.typeArguments && node.typeArguments.length) {
if (node.typeArguments) {
result.typeParameters = this.convertTypeArgumentsToTypeParameters(
node.typeArguments
);
Expand All @@ -1656,7 +1656,7 @@ export class Converter {
? node.arguments.map(el => this.convertChild(el))
: []
});
if (node.typeArguments && node.typeArguments.length) {
if (node.typeArguments) {
result.typeParameters = this.convertTypeArgumentsToTypeParameters(
node.typeArguments
);
Expand Down Expand Up @@ -2060,7 +2060,7 @@ export class Converter {
}

// Process typeParameters
if (node.typeParameters && node.typeParameters.length) {
if (node.typeParameters) {
result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
node.typeParameters
);
Expand Down Expand Up @@ -2216,7 +2216,7 @@ export class Converter {
expression: this.convertChild(node.expression)
});

if (node.typeArguments && node.typeArguments.length) {
if (node.typeArguments) {
result.typeParameters = this.convertTypeArgumentsToTypeParameters(
node.typeArguments
);
Expand All @@ -2236,7 +2236,7 @@ export class Converter {
id: this.convertChild(node.name)
});

if (node.typeParameters && node.typeParameters.length) {
if (node.typeParameters) {
result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration(
node.typeParameters
);
Expand Down
5 changes: 4 additions & 1 deletion packages/typescript-estree/tests/ast-alignment/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ export function preprocessBabylonAST(ast: any): any {
/**
* babel issue: ranges of typeParameters are not included in FunctionExpression range
*/
if (node.typeParameters) {
if (
node.typeParameters &&
node.typeParameters.range[0] < node.range[0]
) {
node.range[0] = node.typeParameters.range[0];
node.loc.start = Object.assign({}, node.typeParameters.loc.start);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,22 @@ Object {

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-arguments.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-arguments-in-call-expression.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-arguments-in-new-expression.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-arrow-function.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-constructor.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-function-expression.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-method.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-method-signature.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/enum-with-keywords.src 1`] = `
Object {
"column": 7,
Expand Down
Loading
0