-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Classify lintish diagnostics as warnings, add treatWarningsAsErrors #19126
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bd914bc
Classify lintish diagnostics as warnings, add treatWarningsAsErrors
weswigham d3ecbbc
Use categorycolor for pretty underline
weswigham 8678465
Warnings no longer block emit when noEmitOnError is set
weswigham 9529605
Option/global warnings no longer block semantic diagnostics for tsc.js
weswigham fefbbef
tsc exit code is conscious of warnings
weswigham 02366bf
Allow warnings in watch mode
weswigham b23a0e3
Merge branch 'master' into diagnostic-serverities
weswigham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
39 changes: 39 additions & 0 deletions
39
tests/baselines/reference/treatWarningsAsErrorsFalse.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,39 @@ | ||
tests/cases/compiler/treatWarningsAsErrorsFalse.ts(1,14): warning TS6133: 'p' is declared but its value is never read. | ||
tests/cases/compiler/treatWarningsAsErrorsFalse.ts(2,5): warning TS7028: Unused label. | ||
tests/cases/compiler/treatWarningsAsErrorsFalse.ts(5,11): warning TS6133: 'y' is declared but its value is never read. | ||
tests/cases/compiler/treatWarningsAsErrorsFalse.ts(7,9): warning TS7029: Fallthrough case in switch. | ||
tests/cases/compiler/treatWarningsAsErrorsFalse.ts(9,14): error TS2678: Type '"b"' is not comparable to type '"a"'. | ||
tests/cases/compiler/treatWarningsAsErrorsFalse.ts(10,13): warning TS7030: Not all code paths return a value. | ||
tests/cases/compiler/treatWarningsAsErrorsFalse.ts(11,13): warning TS7027: Unreachable code detected. | ||
|
||
|
||
==== tests/cases/compiler/treatWarningsAsErrorsFalse.ts (7 errors) ==== | ||
function foo(p: any): string { // unused parameter | ||
~ | ||
!!! warning TS6133: 'p' is declared but its value is never read. | ||
foo: while (false) {} // unused label | ||
~~~ | ||
!!! warning TS7028: Unused label. | ||
|
||
const x: { kind: "a" } | { kind: "b" } = { kind: "a" }; | ||
const y = "any"; // unused variable | ||
~ | ||
!!! warning TS6133: 'y' is declared but its value is never read. | ||
switch (x.kind) { | ||
case "a": | ||
~~~~ | ||
!!! warning TS7029: Fallthrough case in switch. | ||
void x; // implicit fallthrough | ||
case "b": | ||
~~~ | ||
!!! error TS2678: Type '"b"' is not comparable to type '"a"'. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't strictly related to the test, but when I went to remove it, I considered that it is useful in verifying that we're not reporting all errors as warnings. |
||
return; // implicit return | ||
~~~~~~~ | ||
!!! warning TS7030: Not all code paths return a value. | ||
if (x === x) { // unreachable code | ||
~~ | ||
!!! warning TS7027: Unreachable code detected. | ||
void x; | ||
} | ||
} | ||
} |
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,32 @@ | ||
//// [treatWarningsAsErrorsFalse.ts] | ||
function foo(p: any): string { // unused parameter | ||
foo: while (false) {} // unused label | ||
|
||
const x: { kind: "a" } | { kind: "b" } = { kind: "a" }; | ||
const y = "any"; // unused variable | ||
switch (x.kind) { | ||
case "a": | ||
void x; // implicit fallthrough | ||
case "b": | ||
return; // implicit return | ||
if (x === x) { // unreachable code | ||
void x; | ||
} | ||
} | ||
} | ||
|
||
//// [treatWarningsAsErrorsFalse.js] | ||
function foo(p) { | ||
foo: while (false) { } // unused label | ||
var x = { kind: "a" }; | ||
var y = "any"; // unused variable | ||
switch (x.kind) { | ||
case "a": | ||
void x; // implicit fallthrough | ||
case "b": | ||
return; // implicit return | ||
if (x === x) { | ||
void x; | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
tests/baselines/reference/treatWarningsAsErrorsFalse.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,36 @@ | ||
=== tests/cases/compiler/treatWarningsAsErrorsFalse.ts === | ||
function foo(p: any): string { // unused parameter | ||
>foo : Symbol(foo, Decl(treatWarningsAsErrorsFalse.ts, 0, 0)) | ||
>p : Symbol(p, Decl(treatWarningsAsErrorsFalse.ts, 0, 13)) | ||
|
||
foo: while (false) {} // unused label | ||
|
||
const x: { kind: "a" } | { kind: "b" } = { kind: "a" }; | ||
>x : Symbol(x, Decl(treatWarningsAsErrorsFalse.ts, 3, 9)) | ||
>kind : Symbol(kind, Decl(treatWarningsAsErrorsFalse.ts, 3, 14)) | ||
>kind : Symbol(kind, Decl(treatWarningsAsErrorsFalse.ts, 3, 30)) | ||
>kind : Symbol(kind, Decl(treatWarningsAsErrorsFalse.ts, 3, 46)) | ||
|
||
const y = "any"; // unused variable | ||
>y : Symbol(y, Decl(treatWarningsAsErrorsFalse.ts, 4, 9)) | ||
|
||
switch (x.kind) { | ||
>x.kind : Symbol(kind, Decl(treatWarningsAsErrorsFalse.ts, 3, 14)) | ||
>x : Symbol(x, Decl(treatWarningsAsErrorsFalse.ts, 3, 9)) | ||
>kind : Symbol(kind, Decl(treatWarningsAsErrorsFalse.ts, 3, 14)) | ||
|
||
case "a": | ||
void x; // implicit fallthrough | ||
>x : Symbol(x, Decl(treatWarningsAsErrorsFalse.ts, 3, 9)) | ||
|
||
case "b": | ||
return; // implicit return | ||
if (x === x) { // unreachable code | ||
>x : Symbol(x, Decl(treatWarningsAsErrorsFalse.ts, 3, 9)) | ||
>x : Symbol(x, Decl(treatWarningsAsErrorsFalse.ts, 3, 9)) | ||
|
||
void x; | ||
>x : Symbol(x, Decl(treatWarningsAsErrorsFalse.ts, 3, 9)) | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
tests/baselines/reference/treatWarningsAsErrorsFalse.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,48 @@ | ||
=== tests/cases/compiler/treatWarningsAsErrorsFalse.ts === | ||
function foo(p: any): string { // unused parameter | ||
>foo : (p: any) => string | ||
>p : any | ||
|
||
foo: while (false) {} // unused label | ||
>foo : any | ||
>false : false | ||
|
||
const x: { kind: "a" } | { kind: "b" } = { kind: "a" }; | ||
>x : { kind: "a"; } | { kind: "b"; } | ||
>kind : "a" | ||
>kind : "b" | ||
>{ kind: "a" } : { kind: "a"; } | ||
>kind : string | ||
>"a" : "a" | ||
|
||
const y = "any"; // unused variable | ||
>y : "any" | ||
>"any" : "any" | ||
|
||
switch (x.kind) { | ||
>x.kind : "a" | ||
>x : { kind: "a"; } | ||
>kind : "a" | ||
|
||
case "a": | ||
>"a" : "a" | ||
|
||
void x; // implicit fallthrough | ||
>void x : undefined | ||
>x : { kind: "a"; } | ||
|
||
case "b": | ||
>"b" : "b" | ||
|
||
return; // implicit return | ||
if (x === x) { // unreachable code | ||
>x === x : boolean | ||
>x : { kind: "a"; } | { kind: "b"; } | ||
>x : { kind: "a"; } | { kind: "b"; } | ||
|
||
void x; | ||
>void x : undefined | ||
>x : { kind: "a"; } | { kind: "b"; } | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
tests/baselines/reference/treatWarningsAsErrorsFalseNoEmitOnError.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,36 @@ | ||
tests/cases/compiler/treatWarningsAsErrorsFalseNoEmitOnError.ts(1,14): warning TS6133: 'p' is declared but its value is never read. | ||
tests/cases/compiler/treatWarningsAsErrorsFalseNoEmitOnError.ts(2,5): warning TS7028: Unused label. | ||
tests/cases/compiler/treatWarningsAsErrorsFalseNoEmitOnError.ts(5,11): warning TS6133: 'y' is declared but its value is never read. | ||
tests/cases/compiler/treatWarningsAsErrorsFalseNoEmitOnError.ts(7,9): warning TS7029: Fallthrough case in switch. | ||
tests/cases/compiler/treatWarningsAsErrorsFalseNoEmitOnError.ts(10,13): warning TS7030: Not all code paths return a value. | ||
tests/cases/compiler/treatWarningsAsErrorsFalseNoEmitOnError.ts(11,13): warning TS7027: Unreachable code detected. | ||
|
||
|
||
==== tests/cases/compiler/treatWarningsAsErrorsFalseNoEmitOnError.ts (6 errors) ==== | ||
function foo(p: any): string { // unused parameter | ||
~ | ||
!!! warning TS6133: 'p' is declared but its value is never read. | ||
foo: while (false) {} // unused label | ||
~~~ | ||
!!! warning TS7028: Unused label. | ||
|
||
const x: { kind: "a" } | { kind: "b" } = { kind: "a" }; | ||
const y = "any"; // unused variable | ||
~ | ||
!!! warning TS6133: 'y' is declared but its value is never read. | ||
switch (x.kind) { | ||
case "a": | ||
~~~~ | ||
!!! warning TS7029: Fallthrough case in switch. | ||
void x; // implicit fallthrough | ||
case "a": | ||
return; // implicit return | ||
~~~~~~~ | ||
!!! warning TS7030: Not all code paths return a value. | ||
if (x === x) { // unreachable code | ||
~~ | ||
!!! warning TS7027: Unreachable code detected. | ||
void x; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that it defaults to the safer setting (
true
); but how do you disable it via command-line arguments?--no-treatWarningsAsErrors
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--treatWarningsAsErrors false
, same as our other boolean flags.