-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Respect //@ts-nocheck in TS files #33383
Merged
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//// [file.ts] | ||
// @ts-nocheck | ||
|
||
export const a = 1 + {}; // This is an error, ofc, `Operator '+' cannot be applied to types '1' and '{}'`, which will be suppressed by the `nocheck` comment | ||
|
||
export interface Aleph { | ||
q: number; | ||
} | ||
|
||
export class Bet implements Aleph { | ||
q: string = "lol" // And so will this implements error | ||
} | ||
|
||
|
||
//// [file.js] | ||
"use strict"; | ||
// @ts-nocheck | ||
exports.__esModule = true; | ||
exports.a = 1 + {}; // This is an error, ofc, `Operator '+' cannot be applied to types '1' and '{}'`, which will be suppressed by the `nocheck` comment | ||
var Bet = /** @class */ (function () { | ||
function Bet() { | ||
this.q = "lol"; // And so will this implements error | ||
} | ||
return Bet; | ||
}()); | ||
exports.Bet = Bet; | ||
|
||
|
||
//// [file.d.ts] | ||
export declare const a: any; | ||
export interface Aleph { | ||
q: number; | ||
} | ||
export declare class Bet implements Aleph { | ||
q: string; | ||
} | ||
|
||
|
||
//// [DtsFileErrors] | ||
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. I just decided to have declaration emit on to capture the true "garbage in, garbage out" aspect of error suppression. Again, this was already doable with multiple individual |
||
|
||
|
||
tests/cases/conformance/jsdoc/file.d.ts(6,5): error TS2416: Property 'q' in type 'Bet' is not assignable to the same property in base type 'Aleph'. | ||
Type 'string' is not assignable to type 'number'. | ||
|
||
|
||
==== tests/cases/conformance/jsdoc/file.d.ts (1 errors) ==== | ||
export declare const a: any; | ||
export interface Aleph { | ||
q: number; | ||
} | ||
export declare class Bet implements Aleph { | ||
q: string; | ||
~ | ||
!!! error TS2416: Property 'q' in type 'Bet' is not assignable to the same property in base type 'Aleph'. | ||
!!! error TS2416: Type 'string' is not assignable to type 'number'. | ||
} | ||
|
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,21 @@ | ||
=== tests/cases/conformance/jsdoc/file.ts === | ||
// @ts-nocheck | ||
|
||
export const a = 1 + {}; // This is an error, ofc, `Operator '+' cannot be applied to types '1' and '{}'`, which will be suppressed by the `nocheck` comment | ||
>a : Symbol(a, Decl(file.ts, 2, 12)) | ||
|
||
export interface Aleph { | ||
>Aleph : Symbol(Aleph, Decl(file.ts, 2, 24)) | ||
|
||
q: number; | ||
>q : Symbol(Aleph.q, Decl(file.ts, 4, 24)) | ||
} | ||
|
||
export class Bet implements Aleph { | ||
>Bet : Symbol(Bet, Decl(file.ts, 6, 1)) | ||
>Aleph : Symbol(Aleph, Decl(file.ts, 2, 24)) | ||
|
||
q: string = "lol" // And so will this implements error | ||
>q : Symbol(Bet.q, Decl(file.ts, 8, 35)) | ||
} | ||
|
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/jsdoc/file.ts === | ||
// @ts-nocheck | ||
|
||
export const a = 1 + {}; // This is an error, ofc, `Operator '+' cannot be applied to types '1' and '{}'`, which will be suppressed by the `nocheck` comment | ||
>a : any | ||
>1 + {} : any | ||
>1 : 1 | ||
>{} : {} | ||
|
||
export interface Aleph { | ||
q: number; | ||
>q : number | ||
} | ||
|
||
export class Bet implements Aleph { | ||
>Bet : Bet | ||
|
||
q: string = "lol" // And so will this implements error | ||
>q : string | ||
>"lol" : "lol" | ||
} | ||
|
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 @@ | ||
// @declaration: true | ||
// @filename: file.ts | ||
|
||
// @ts-nocheck | ||
|
||
export const a = 1 + {}; // This is an error, ofc, `Operator '+' cannot be applied to types '1' and '{}'`, which will be suppressed by the `nocheck` comment | ||
|
||
export interface Aleph { | ||
q: number; | ||
} | ||
|
||
export class Bet implements Aleph { | ||
q: string = "lol" // And so will this implements error | ||
} |
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.
Question, currently unchecked files have also some fuzzy completions (currently only in js files since those are the only ones) but would we want that? I think no but I am just pointing out one of the
checkJs
enabled and disabled difference.Similarly there is disableJsDiagnostics code fix, do we need similar one now for ts?
Handle report
reportImplicitAny
for early exit?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.
I don't think a
//@ts-nocheck
in a TS file should do anything other than suppress errors - everything else should be as-is.