Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Token hints for missing closing braces: classes, enums, jsx, modules,…
… types This commit adds token hints for missing close braces in - Class definitions - Enum definitions - JSX expressions - Module definitions (this includes augmentations and namespaces) - Type member lists (this includes interfaces) The token hint refers to the opening brace for which the parser expected a corresponding closing brace. Note that this commit *does not* update all occurences of an expectation for a close brace to provide token hints. Constructs for which this token hint is not provided include: - Mapped types - Switch statements - Object binding patterns - JSX spread attributes (`<div {...props}></div>`) - JSDoc implements/augments tags (`/* @implements {SomeInterface} */`) Part of #35597.
- Loading branch information
Ayaz Hafiz
committed
Mar 20, 2020
1 parent
5e9c436
commit eb22100
Showing
48 changed files
with
9,541 additions
and
7,967 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
tests/baselines/reference/missingCloseBraceInClassDeclaration.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
tests/cases/compiler/missingCloseBraceInClassDeclaration.ts(7,1): error TS1005: '}' expected. | ||
|
||
|
||
==== tests/cases/compiler/missingCloseBraceInClassDeclaration.ts (1 errors) ==== | ||
class TestCls { | ||
prop = 0; | ||
method() { | ||
return this.prop; | ||
} | ||
|
||
|
||
|
||
!!! error TS1005: '}' expected. | ||
!!! related TS1007 tests/cases/compiler/missingCloseBraceInClassDeclaration.ts:1:15: The parser expected to find a '}' to match the '{' token here. |
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/missingCloseBraceInClassDeclaration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//// [missingCloseBraceInClassDeclaration.ts] | ||
class TestCls { | ||
prop = 0; | ||
method() { | ||
return this.prop; | ||
} | ||
|
||
|
||
|
||
//// [missingCloseBraceInClassDeclaration.js] | ||
var TestCls = /** @class */ (function () { | ||
function TestCls() { | ||
this.prop = 0; | ||
} | ||
TestCls.prototype.method = function () { | ||
return this.prop; | ||
}; | ||
return TestCls; | ||
}()); |
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/missingCloseBraceInClassDeclaration.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
=== tests/cases/compiler/missingCloseBraceInClassDeclaration.ts === | ||
class TestCls { | ||
>TestCls : Symbol(TestCls, Decl(missingCloseBraceInClassDeclaration.ts, 0, 0)) | ||
|
||
prop = 0; | ||
>prop : Symbol(TestCls.prop, Decl(missingCloseBraceInClassDeclaration.ts, 0, 15)) | ||
|
||
method() { | ||
>method : Symbol(TestCls.method, Decl(missingCloseBraceInClassDeclaration.ts, 1, 11)) | ||
|
||
return this.prop; | ||
>this.prop : Symbol(TestCls.prop, Decl(missingCloseBraceInClassDeclaration.ts, 0, 15)) | ||
>this : Symbol(TestCls, Decl(missingCloseBraceInClassDeclaration.ts, 0, 0)) | ||
>prop : Symbol(TestCls.prop, Decl(missingCloseBraceInClassDeclaration.ts, 0, 15)) | ||
} | ||
|
||
|
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/missingCloseBraceInClassDeclaration.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
=== tests/cases/compiler/missingCloseBraceInClassDeclaration.ts === | ||
class TestCls { | ||
>TestCls : TestCls | ||
|
||
prop = 0; | ||
>prop : number | ||
>0 : 0 | ||
|
||
method() { | ||
>method : () => number | ||
|
||
return this.prop; | ||
>this.prop : number | ||
>this : this | ||
>prop : number | ||
} | ||
|
||
|
13 changes: 13 additions & 0 deletions
13
tests/baselines/reference/missingCloseBraceInEnum.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
tests/cases/compiler/missingCloseBraceInEnum.ts(6,1): error TS1005: '}' expected. | ||
|
||
|
||
==== tests/cases/compiler/missingCloseBraceInEnum.ts (1 errors) ==== | ||
enum Colors { | ||
Red, | ||
Green, | ||
Blue, | ||
|
||
|
||
|
||
!!! error TS1005: '}' expected. | ||
!!! related TS1007 tests/cases/compiler/missingCloseBraceInEnum.ts:1:13: The parser expected to find a '}' to match the '{' token here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//// [missingCloseBraceInEnum.ts] | ||
enum Colors { | ||
Red, | ||
Green, | ||
Blue, | ||
|
||
|
||
|
||
//// [missingCloseBraceInEnum.js] | ||
var Colors; | ||
(function (Colors) { | ||
Colors[Colors["Red"] = 0] = "Red"; | ||
Colors[Colors["Green"] = 1] = "Green"; | ||
Colors[Colors["Blue"] = 2] = "Blue"; | ||
})(Colors || (Colors = {})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
=== tests/cases/compiler/missingCloseBraceInEnum.ts === | ||
enum Colors { | ||
>Colors : Symbol(Colors, Decl(missingCloseBraceInEnum.ts, 0, 0)) | ||
|
||
Red, | ||
>Red : Symbol(Colors.Red, Decl(missingCloseBraceInEnum.ts, 0, 13)) | ||
|
||
Green, | ||
>Green : Symbol(Colors.Green, Decl(missingCloseBraceInEnum.ts, 1, 6)) | ||
|
||
Blue, | ||
>Blue : Symbol(Colors.Blue, Decl(missingCloseBraceInEnum.ts, 2, 8)) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
=== tests/cases/compiler/missingCloseBraceInEnum.ts === | ||
enum Colors { | ||
>Colors : Colors | ||
|
||
Red, | ||
>Red : Colors.Red | ||
|
||
Green, | ||
>Green : Colors.Green | ||
|
||
Blue, | ||
>Blue : Colors.Blue | ||
|
||
|
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/missingCloseBraceInJsxAttributeExpression.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
tests/cases/compiler/missingCloseBraceInJsxAttributeExpression.tsx(1,23): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. | ||
tests/cases/compiler/missingCloseBraceInJsxAttributeExpression.tsx(1,30): error TS1109: Expression expected. | ||
tests/cases/compiler/missingCloseBraceInJsxAttributeExpression.tsx(1,31): error TS1109: Expression expected. | ||
tests/cases/compiler/missingCloseBraceInJsxAttributeExpression.tsx(2,1): error TS1005: '}' expected. | ||
|
||
|
||
==== tests/cases/compiler/missingCloseBraceInJsxAttributeExpression.tsx (4 errors) ==== | ||
let el = <input prop={'abc' /> | ||
~~~~~ | ||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. | ||
~ | ||
!!! error TS1109: Expression expected. | ||
|
||
!!! error TS1109: Expression expected. | ||
|
||
|
||
!!! error TS1005: '}' expected. | ||
!!! related TS1007 tests/cases/compiler/missingCloseBraceInJsxAttributeExpression.tsx:1:22: The parser expected to find a '}' to match the '{' token here. |
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/missingCloseBraceInJsxAttributeExpression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//// [missingCloseBraceInJsxAttributeExpression.tsx] | ||
let el = <input prop={'abc' /> | ||
|
||
|
||
//// [missingCloseBraceInJsxAttributeExpression.jsx] | ||
var el = <input prop={'abc' / > | ||
}/>; |
5 changes: 5 additions & 0 deletions
5
tests/baselines/reference/missingCloseBraceInJsxAttributeExpression.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
=== tests/cases/compiler/missingCloseBraceInJsxAttributeExpression.tsx === | ||
let el = <input prop={'abc' /> | ||
>el : Symbol(el, Decl(missingCloseBraceInJsxAttributeExpression.tsx, 0, 3)) | ||
>prop : Symbol(prop, Decl(missingCloseBraceInJsxAttributeExpression.tsx, 0, 15)) | ||
|
13 changes: 13 additions & 0 deletions
13
tests/baselines/reference/missingCloseBraceInJsxAttributeExpression.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
=== tests/cases/compiler/missingCloseBraceInJsxAttributeExpression.tsx === | ||
let el = <input prop={'abc' /> | ||
>el : any | ||
><input prop={'abc' /> : any | ||
>input : any | ||
>prop : boolean | ||
>'abc' /> : boolean | ||
>'abc' / : number | ||
>'abc' : "abc" | ||
> : any | ||
|
||
> : any | ||
|
9 changes: 9 additions & 0 deletions
9
tests/baselines/reference/missingCloseBraceInJsxExpression.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tests/cases/compiler/missingCloseBraceInJsxExpression.tsx(1,23): error TS1005: '}' expected. | ||
|
||
|
||
==== tests/cases/compiler/missingCloseBraceInJsxExpression.tsx (1 errors) ==== | ||
let el = <div>{'hello'</div> | ||
~~ | ||
!!! error TS1005: '}' expected. | ||
!!! related TS1007 tests/cases/compiler/missingCloseBraceInJsxExpression.tsx:1:15: The parser expected to find a '}' to match the '{' token here. | ||
|
6 changes: 6 additions & 0 deletions
6
tests/baselines/reference/missingCloseBraceInJsxExpression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//// [missingCloseBraceInJsxExpression.tsx] | ||
let el = <div>{'hello'</div> | ||
|
||
|
||
//// [missingCloseBraceInJsxExpression.jsx] | ||
var el = <div>{'hello'}</div>; |
4 changes: 4 additions & 0 deletions
4
tests/baselines/reference/missingCloseBraceInJsxExpression.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
=== tests/cases/compiler/missingCloseBraceInJsxExpression.tsx === | ||
let el = <div>{'hello'</div> | ||
>el : Symbol(el, Decl(missingCloseBraceInJsxExpression.tsx, 0, 3)) | ||
|
8 changes: 8 additions & 0 deletions
8
tests/baselines/reference/missingCloseBraceInJsxExpression.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
=== tests/cases/compiler/missingCloseBraceInJsxExpression.tsx === | ||
let el = <div>{'hello'</div> | ||
>el : any | ||
><div>{'hello'</div> : any | ||
>div : any | ||
>'hello' : "hello" | ||
>div : any | ||
|
11 changes: 11 additions & 0 deletions
11
tests/baselines/reference/missingCloseBraceInModuleBlock.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
tests/cases/compiler/missingCloseBraceInModuleBlock.ts(4,1): error TS1005: '}' expected. | ||
|
||
|
||
==== tests/cases/compiler/missingCloseBraceInModuleBlock.ts (1 errors) ==== | ||
module "dummy" { | ||
interface Dummy {} | ||
|
||
|
||
|
||
!!! error TS1005: '}' expected. | ||
!!! related TS1007 tests/cases/compiler/missingCloseBraceInModuleBlock.ts:1:16: The parser expected to find a '}' to match the '{' token here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//// [missingCloseBraceInModuleBlock.ts] | ||
module "dummy" { | ||
interface Dummy {} | ||
|
||
|
||
|
||
//// [missingCloseBraceInModuleBlock.js] |
8 changes: 8 additions & 0 deletions
8
tests/baselines/reference/missingCloseBraceInModuleBlock.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
=== tests/cases/compiler/missingCloseBraceInModuleBlock.ts === | ||
module "dummy" { | ||
>"dummy" : Symbol("dummy", Decl(missingCloseBraceInModuleBlock.ts, 0, 0)) | ||
|
||
interface Dummy {} | ||
>Dummy : Symbol(Dummy, Decl(missingCloseBraceInModuleBlock.ts, 0, 16)) | ||
|
||
|
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/missingCloseBraceInModuleBlock.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
=== tests/cases/compiler/missingCloseBraceInModuleBlock.ts === | ||
module "dummy" { | ||
>"dummy" : typeof import("dummy") | ||
|
||
interface Dummy {} | ||
|
||
|
11 changes: 11 additions & 0 deletions
11
tests/baselines/reference/missingCloseBraceInTypeMemberList.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
tests/cases/compiler/missingCloseBraceInTypeMemberList.ts(4,1): error TS1005: '}' expected. | ||
|
||
|
||
==== tests/cases/compiler/missingCloseBraceInTypeMemberList.ts (1 errors) ==== | ||
type ITest = { | ||
num: number; | ||
|
||
|
||
|
||
!!! error TS1005: '}' expected. | ||
!!! related TS1007 tests/cases/compiler/missingCloseBraceInTypeMemberList.ts:1:14: The parser expected to find a '}' to match the '{' token here. |
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/missingCloseBraceInTypeMemberList.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//// [missingCloseBraceInTypeMemberList.ts] | ||
type ITest = { | ||
num: number; | ||
|
||
|
||
|
||
//// [missingCloseBraceInTypeMemberList.js] |
8 changes: 8 additions & 0 deletions
8
tests/baselines/reference/missingCloseBraceInTypeMemberList.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
=== tests/cases/compiler/missingCloseBraceInTypeMemberList.ts === | ||
type ITest = { | ||
>ITest : Symbol(ITest, Decl(missingCloseBraceInTypeMemberList.ts, 0, 0)) | ||
|
||
num: number; | ||
>num : Symbol(num, Decl(missingCloseBraceInTypeMemberList.ts, 0, 14)) | ||
|
||
|
Oops, something went wrong.