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 f2d57da
Showing
48 changed files
with
349 additions
and
34 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
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
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 | ||
|
||
|
Oops, something went wrong.