From d7757f6d0861ed1ff4cc2f34f463d83d43d3d294 Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Tue, 23 Apr 2019 09:47:23 -0500 Subject: [PATCH] Fix TypeScript readonly error location (#9887) --- packages/babel-parser/src/plugins/typescript.js | 2 +- .../fixtures/typescript/types/read-only-1/options.json | 8 +++----- .../fixtures/typescript/types/read-only-2/options.json | 2 +- .../fixtures/typescript/types/read-only-3/options.json | 2 +- .../fixtures/typescript/types/read-only-4/options.json | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/babel-parser/src/plugins/typescript.js b/packages/babel-parser/src/plugins/typescript.js index e94617060b1e..c9e3d1fa0753 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -743,7 +743,7 @@ export default (superClass: Class): Class => return; default: this.raise( - node.operator, + node.start, "'readonly' type modifier is only permitted on array and tuple literal types.", ); } diff --git a/packages/babel-parser/test/fixtures/typescript/types/read-only-1/options.json b/packages/babel-parser/test/fixtures/typescript/types/read-only-1/options.json index f3875581a2de..0a91d0015278 100644 --- a/packages/babel-parser/test/fixtures/typescript/types/read-only-1/options.json +++ b/packages/babel-parser/test/fixtures/typescript/types/read-only-1/options.json @@ -1,7 +1,5 @@ { "sourceType": "module", - "plugins": [ - "typescript" - ], - "throws": "'readonly' type modifier is only permitted on array and tuple literal types. (1:NaN)" -} \ No newline at end of file + "plugins": ["typescript"], + "throws": "'readonly' type modifier is only permitted on array and tuple literal types. (1:11)" +} diff --git a/packages/babel-parser/test/fixtures/typescript/types/read-only-2/options.json b/packages/babel-parser/test/fixtures/typescript/types/read-only-2/options.json index f3875581a2de..cdb818eee9b2 100644 --- a/packages/babel-parser/test/fixtures/typescript/types/read-only-2/options.json +++ b/packages/babel-parser/test/fixtures/typescript/types/read-only-2/options.json @@ -3,5 +3,5 @@ "plugins": [ "typescript" ], - "throws": "'readonly' type modifier is only permitted on array and tuple literal types. (1:NaN)" + "throws": "'readonly' type modifier is only permitted on array and tuple literal types. (1:11)" } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/types/read-only-3/options.json b/packages/babel-parser/test/fixtures/typescript/types/read-only-3/options.json index f3875581a2de..cdb818eee9b2 100644 --- a/packages/babel-parser/test/fixtures/typescript/types/read-only-3/options.json +++ b/packages/babel-parser/test/fixtures/typescript/types/read-only-3/options.json @@ -3,5 +3,5 @@ "plugins": [ "typescript" ], - "throws": "'readonly' type modifier is only permitted on array and tuple literal types. (1:NaN)" + "throws": "'readonly' type modifier is only permitted on array and tuple literal types. (1:11)" } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/types/read-only-4/options.json b/packages/babel-parser/test/fixtures/typescript/types/read-only-4/options.json index f3875581a2de..cdb818eee9b2 100644 --- a/packages/babel-parser/test/fixtures/typescript/types/read-only-4/options.json +++ b/packages/babel-parser/test/fixtures/typescript/types/read-only-4/options.json @@ -3,5 +3,5 @@ "plugins": [ "typescript" ], - "throws": "'readonly' type modifier is only permitted on array and tuple literal types. (1:NaN)" + "throws": "'readonly' type modifier is only permitted on array and tuple literal types. (1:11)" } \ No newline at end of file