From cbb766cffbbcafdf8df7fd9ab8fa8d2d5f997e9a Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Mon, 22 Apr 2019 11:33:05 -0500 Subject: [PATCH] Fix TypeScript readonly error location --- 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 0940878ae206..4e5d237aacf0 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -773,7 +773,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