Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 13.7k
Mark file as skips typechecking if it contains ts-nocheck#58593
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
700c5b3
Skip typechecking before declaration file on js files with nocheck
sheetalkamat ca1ff15
Try adding ts-noCheck checks to skipTypeChecking
sheetalkamat 52326d5
Make internal
sheetalkamat f7dccc0
Merge branch 'main' into skipCheckIfNoJSCheck
sheetalkamat 661d4fd
Merge branch 'main' into skipCheckIfNoJSCheck
sheetalkamat 3d2a9fe
Handle noCheck for js Emit
sheetalkamat 3daa7c7
Fix incorrect check
sheetalkamat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -21,6 +21,7 @@ import { | ||
| CallExpression, | ||
| CallSignatureDeclaration, | ||
| canHaveLocals, | ||
| canIncludeBindAndCheckDiagnsotics, | ||
| CaseBlock, | ||
| CaseClause, | ||
| CaseOrDefaultClause, | ||
| @@ -800,9 +801,14 @@ export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFi | ||
| return; | ||
| } | ||
| if (compilerOptions.noCheck) { | ||
| (isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : filter(sourceFileOrBundle.sourceFiles, isSourceFileNotJson)).forEach(markLinkedReferences); | ||
| } | ||
| (isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : filter(sourceFileOrBundle.sourceFiles, isSourceFileNotJson)).forEach( | ||
| sourceFile => { | ||
| if ( | ||
| compilerOptions.noCheck || | ||
| !canIncludeBindAndCheckDiagnsotics(sourceFile, compilerOptions) | ||
| ) markLinkedReferences(sourceFile); | ||
| }, | ||
| ); | ||
| // Transform the source files | ||
| const transform = transformNodes(resolver, host, factory, compilerOptions, [sourceFileOrBundle], scriptTransformers, /*allowDtsFiles*/ false); | ||
| @@ -859,15 +865,19 @@ export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFi | ||
| const filesForEmit = forceDtsEmit ? sourceFiles : filter(sourceFiles, isSourceFileNotJson); | ||
| // Setup and perform the transformation to retrieve declarations from the input files | ||
| const inputListOrBundle = compilerOptions.outFile ? [factory.createBundle(filesForEmit)] : filesForEmit; | ||
| if ( | ||
| (emitOnly && !getEmitDeclarations(compilerOptions)) || | ||
| compilerOptions.noCheck || | ||
| emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit) | ||
| ) { | ||
| // Checker wont collect the linked aliases since thats only done when declaration is enabled and checking is performed. | ||
| // Do that here when emitting only dts files | ||
| filesForEmit.forEach(collectLinkedAliases); | ||
| } | ||
| // Checker wont collect the linked aliases since thats only done when declaration is enabled and checking is performed. | ||
| // Do that here when emitting only dts files | ||
| filesForEmit.forEach(sourceFile => { | ||
| if ( | ||
| (emitOnly && !getEmitDeclarations(compilerOptions)) || | ||
| compilerOptions.noCheck || | ||
| emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit) || | ||
sheetalkamat marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| !canIncludeBindAndCheckDiagnsotics(sourceFile, compilerOptions) | ||
| ) { | ||
| collectLinkedAliases(sourceFile); | ||
| } | ||
| }); | ||
| const declarationTransform = transformNodes(resolver, host, factory, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); | ||
| if (length(declarationTransform.diagnostics)) { | ||
| for (const diagnostic of declarationTransform.diagnostics!) { | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -10082,7 +10082,28 @@ export function skipTypeChecking(sourceFile: SourceFile, options: CompilerOption | ||
| return (options.skipLibCheck && sourceFile.isDeclarationFile || | ||
| options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || | ||
| options.noCheck || | ||
| host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); | ||
| host.isSourceOfProjectReferenceRedirect(sourceFile.fileName) || | ||
| !canIncludeBindAndCheckDiagnsotics(sourceFile, options); | ||
| } | ||
| /** @internal */ | ||
| export function canIncludeBindAndCheckDiagnsotics(sourceFile: SourceFile, options: CompilerOptions) { | ||
sheetalkamat marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if (!!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false) return false; | ||
| if ( | ||
| sourceFile.scriptKind === ScriptKind.TS || | ||
| sourceFile.scriptKind === ScriptKind.TSX || | ||
| sourceFile.scriptKind === ScriptKind.External | ||
| ) return true; | ||
| const isJs = sourceFile.scriptKind === ScriptKind.JS || sourceFile.scriptKind === ScriptKind.JSX; | ||
| const isCheckJs = isJs && isCheckJsEnabledForFile(sourceFile, options); | ||
| const isPlainJs = isPlainJsFile(sourceFile, options.checkJs); | ||
| // By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External | ||
| // - plain JS: .js files with no // ts-check and checkJs: undefined | ||
| // - check JS: .js files with either // ts-check or checkJs: true | ||
| // - external: files that are added by plugins | ||
| return isPlainJs || isCheckJs || sourceFile.scriptKind === ScriptKind.Deferred; | ||
| } | ||
| /** @internal */ | ||
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.
Uh oh!
There was an error while loading. Please reload this page.