diff --git a/packages/babel-parser/src/plugins/typescript/index.js b/packages/babel-parser/src/plugins/typescript/index.js index 94dad4c21fbf..9447dd03256e 100644 --- a/packages/babel-parser/src/plugins/typescript/index.js +++ b/packages/babel-parser/src/plugins/typescript/index.js @@ -1068,6 +1068,7 @@ export default (superClass: Class): Class => node.asserts = true; thisTypePredicate = this.finishNode(node, "TSTypePredicate"); } else { + this.resetStartLocationFromNode(thisTypePredicate, node); (thisTypePredicate: N.TsTypePredicate).asserts = true; } t.typeAnnotation = thisTypePredicate; diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/output.json b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/output.json index a98a1eefa26a..8a552c9028ad 100644 --- a/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/output.json +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/output.json @@ -40,7 +40,7 @@ "start":21,"end":42,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":30}}, "typeAnnotation": { "type": "TSTypePredicate", - "start":31,"end":42,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":30}}, + "start":23,"end":42,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":30}}, "parameterName": { "type": "TSThisType", "start":31,"end":35,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":23}} @@ -86,7 +86,7 @@ "start":58,"end":79,"loc":{"start":{"line":3,"column":12},"end":{"line":3,"column":33}}, "typeAnnotation": { "type": "TSTypePredicate", - "start":68,"end":79,"loc":{"start":{"line":3,"column":22},"end":{"line":3,"column":33}}, + "start":60,"end":79,"loc":{"start":{"line":3,"column":14},"end":{"line":3,"column":33}}, "parameterName": { "type": "TSThisType", "start":68,"end":72,"loc":{"start":{"line":3,"column":22},"end":{"line":3,"column":26}} @@ -125,4 +125,4 @@ ], "directives": [] } -} \ No newline at end of file +}