mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 12:03:44 -05:00
Refactor checking for checkJs value in a common helper
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/// <reference path="types.ts"/>
|
||||
/// <reference path="types.ts"/>
|
||||
/// <reference path="performance.ts" />
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="sys.ts" />
|
||||
/// <reference path="sys.ts" />
|
||||
/// <reference path="emitter.ts" />
|
||||
/// <reference path="core.ts" />
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user