-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added @ts-expect-error to @ts-ignore directives
Similar to `// @ts-ignore`, but will itself cause a new error diagnostic if it does not cause an existing diagnostic to be ignored. Technical summary: 1. The scanner will now keep track of `CommentDirective`s it comes across: both `@ts-expect-error` and `@ts-ignore` 2. During type checking, the program will turn those directives into a map keying them by line number 3. For each diagnostic, if it's preceded by a directive, that directive is marked as "used" 4. All `@ts-expect-error` directives not marked as used generate a new diagnostic error
- Loading branch information
1 parent
bb306a7
commit eb5610a
Showing
17 changed files
with
411 additions
and
41 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
tests/cases/conformance/directives/ts-expect-error.ts(4,1): error TS2578: Unused '@ts-expect-error' directive. | ||
tests/cases/conformance/directives/ts-expect-error.ts(10,1): error TS2578: Unused '@ts-expect-error' directive. | ||
tests/cases/conformance/directives/ts-expect-error.ts(13,5): error TS2322: Type '"nope"' is not assignable to type 'number'. | ||
|
||
|
||
==== tests/cases/conformance/directives/ts-expect-error.ts (3 errors) ==== | ||
// @ts-expect-error additional commenting | ||
var invalidCommentedFancy: number = 'nope'; | ||
|
||
// @ts-expect-error additional commenting | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2578: Unused '@ts-expect-error' directive. | ||
var validCommentedFancy: string = 'nope'; | ||
|
||
// @ts-expect-error | ||
var invalidCommentedPlain: number = 'nope'; | ||
|
||
// @ts-expect-error | ||
~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2578: Unused '@ts-expect-error' directive. | ||
var validCommentedPlain: string = 'nope'; | ||
|
||
var invalidPlain: number = 'nope'; | ||
~~~~~~~~~~~~ | ||
!!! error TS2322: Type '"nope"' is not assignable to type 'number'. | ||
|
||
var validPlain: string = 'nope'; | ||
|
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,29 @@ | ||
//// [ts-expect-error.ts] | ||
// @ts-expect-error additional commenting | ||
var invalidCommentedFancy: number = 'nope'; | ||
|
||
// @ts-expect-error additional commenting | ||
var validCommentedFancy: string = 'nope'; | ||
|
||
// @ts-expect-error | ||
var invalidCommentedPlain: number = 'nope'; | ||
|
||
// @ts-expect-error | ||
var validCommentedPlain: string = 'nope'; | ||
|
||
var invalidPlain: number = 'nope'; | ||
|
||
var validPlain: string = 'nope'; | ||
|
||
|
||
//// [ts-expect-error.js] | ||
// @ts-expect-error additional commenting | ||
var invalidCommentedFancy = 'nope'; | ||
// @ts-expect-error additional commenting | ||
var validCommentedFancy = 'nope'; | ||
// @ts-expect-error | ||
var invalidCommentedPlain = 'nope'; | ||
// @ts-expect-error | ||
var validCommentedPlain = 'nope'; | ||
var invalidPlain = 'nope'; | ||
var validPlain = 'nope'; |
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,23 @@ | ||
=== tests/cases/conformance/directives/ts-expect-error.ts === | ||
// @ts-expect-error additional commenting | ||
var invalidCommentedFancy: number = 'nope'; | ||
>invalidCommentedFancy : Symbol(invalidCommentedFancy, Decl(ts-expect-error.ts, 1, 3)) | ||
|
||
// @ts-expect-error additional commenting | ||
var validCommentedFancy: string = 'nope'; | ||
>validCommentedFancy : Symbol(validCommentedFancy, Decl(ts-expect-error.ts, 4, 3)) | ||
|
||
// @ts-expect-error | ||
var invalidCommentedPlain: number = 'nope'; | ||
>invalidCommentedPlain : Symbol(invalidCommentedPlain, Decl(ts-expect-error.ts, 7, 3)) | ||
|
||
// @ts-expect-error | ||
var validCommentedPlain: string = 'nope'; | ||
>validCommentedPlain : Symbol(validCommentedPlain, Decl(ts-expect-error.ts, 10, 3)) | ||
|
||
var invalidPlain: number = 'nope'; | ||
>invalidPlain : Symbol(invalidPlain, Decl(ts-expect-error.ts, 12, 3)) | ||
|
||
var validPlain: string = 'nope'; | ||
>validPlain : Symbol(validPlain, Decl(ts-expect-error.ts, 14, 3)) | ||
|
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,29 @@ | ||
=== tests/cases/conformance/directives/ts-expect-error.ts === | ||
// @ts-expect-error additional commenting | ||
var invalidCommentedFancy: number = 'nope'; | ||
>invalidCommentedFancy : number | ||
>'nope' : "nope" | ||
|
||
// @ts-expect-error additional commenting | ||
var validCommentedFancy: string = 'nope'; | ||
>validCommentedFancy : string | ||
>'nope' : "nope" | ||
|
||
// @ts-expect-error | ||
var invalidCommentedPlain: number = 'nope'; | ||
>invalidCommentedPlain : number | ||
>'nope' : "nope" | ||
|
||
// @ts-expect-error | ||
var validCommentedPlain: string = 'nope'; | ||
>validCommentedPlain : string | ||
>'nope' : "nope" | ||
|
||
var invalidPlain: number = 'nope'; | ||
>invalidPlain : number | ||
>'nope' : "nope" | ||
|
||
var validPlain: string = 'nope'; | ||
>validPlain : string | ||
>'nope' : "nope" | ||
|
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,22 @@ | ||
tests/cases/conformance/directives/ts-ignore.ts(13,5): error TS2322: Type '"nope"' is not assignable to type 'number'. | ||
|
||
|
||
==== tests/cases/conformance/directives/ts-ignore.ts (1 errors) ==== | ||
// @ts-ignore with additional commenting | ||
var invalidCommentedFancy: number = 'nope'; | ||
|
||
// @ts-ignore with additional commenting | ||
var validCommentedFancy: string = 'nope'; | ||
|
||
// @ts-ignore | ||
var invalidCommentedPlain: number = 'nope'; | ||
|
||
// @ts-ignore | ||
var validCommentedPlain: string = 'nope'; | ||
|
||
var invalidPlain: number = 'nope'; | ||
~~~~~~~~~~~~ | ||
!!! error TS2322: Type '"nope"' is not assignable to type 'number'. | ||
|
||
var validPlain: string = 'nope'; | ||
|
Oops, something went wrong.