diff --git a/src/compiler/core.ts b/src/compiler/core.ts
index c380a39611d..14aeb35dc89 100644
--- a/src/compiler/core.ts
+++ b/src/compiler/core.ts
@@ -1,4 +1,4 @@
-///
+///
///
namespace ts {
@@ -2360,4 +2360,8 @@ namespace ts {
return Extension.Jsx;
}
}
+
+ export function isCheckJsEnabledForFile(sourceFile: SourceFile, compilerOptions: CompilerOptions) {
+ return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs;
+ }
}
diff --git a/src/compiler/program.ts b/src/compiler/program.ts
index bdc8f76cf60..8f1bd4ba36e 100644
--- a/src/compiler/program.ts
+++ b/src/compiler/program.ts
@@ -1,4 +1,4 @@
-///
+///
///
///
@@ -918,8 +918,7 @@ namespace ts {
Debug.assert(!!sourceFile.bindDiagnostics);
const bindDiagnostics = sourceFile.bindDiagnostics;
// For JavaScript files, we don't want to report semantic errors unless explicitly requested.
- const includeCheckDiagnostics = !isSourceFileJavaScript(sourceFile) ||
- (sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : options.checkJs);
+ const includeCheckDiagnostics = !isSourceFileJavaScript(sourceFile) || isCheckJsEnabledForFile(sourceFile, options);
const checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : [];
const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
diff --git a/src/services/codefixes/disableJsDiagnostics.ts b/src/services/codefixes/disableJsDiagnostics.ts
index c18c0153a03..621555cf84b 100644
--- a/src/services/codefixes/disableJsDiagnostics.ts
+++ b/src/services/codefixes/disableJsDiagnostics.ts
@@ -1,4 +1,4 @@
-/* @internal */
+/* @internal */
namespace ts.codefix {
registerCodeFix({
errorCodes: getApplicableDiagnosticCodes(),
@@ -12,10 +12,6 @@ namespace ts.codefix {
.map(d => allDiagnostcs[d].code);
}
- function shouldCheckJsFile(sourceFile: SourceFile, compilerOptions: CompilerOptions) {
- return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs;
- }
-
function getSuppressCommentLocationForLocation(sourceFile: SourceFile, position: number, newLineCharacter: string) {
let { line } = getLineAndCharacterOfPosition(sourceFile, position);
const lineStartPosition = getStartPositionOfLine(line, sourceFile);
@@ -46,7 +42,7 @@ namespace ts.codefix {
function getDisableJsDiagnosticsCodeActions(context: CodeFixContext): CodeAction[] | undefined {
const { sourceFile, program, newLineCharacter, span } = context;
- if (!isInJavaScriptFile(sourceFile) || !shouldCheckJsFile(sourceFile, program.getCompilerOptions())) {
+ if (!isInJavaScriptFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {
return undefined;
}