prefer-const

This commit is contained in:
Alexander T
2019-06-19 17:58:49 +03:00
parent 504b932f7b
commit 5ce8c831b4
16 changed files with 50 additions and 53 deletions
+3 -1
View File
@@ -1,8 +1,10 @@
/* @internal */
namespace ts {
export namespace Debug {
/* eslint-disable prefer-const */
export let currentAssertionLevel = AssertionLevel.None;
export let isDebugging = false;
/* eslint-enable prefer-const */
export function shouldAssert(level: AssertionLevel): boolean {
return currentAssertionLevel >= level;
@@ -258,4 +260,4 @@ namespace ts {
isDebugInfoEnabled = true;
}
}
}
}
+1 -2
View File
@@ -709,7 +709,6 @@ namespace ts {
const { rootNames, options, configFileParsingDiagnostics, projectReferences } = createProgramOptions;
let { oldProgram } = createProgramOptions;
let program: Program;
let processingDefaultLibFiles: SourceFile[] | undefined;
let processingOtherFiles: SourceFile[] | undefined;
let files: SourceFile[];
@@ -905,7 +904,7 @@ namespace ts {
// unconditionally set oldProgram to undefined to prevent it from being captured in closure
oldProgram = undefined;
program = {
const program: Program = {
getRootFileNames: () => rootNames,
getSourceFile,
getSourceFileByPath,
+1
View File
@@ -635,6 +635,7 @@ namespace ts {
};
// TODO: GH#18217 this is used as if it's certainly defined in many places.
// eslint-disable-next-line prefer-const
export let sys: System = (() => {
// NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual
// byte order mark from the specified encoding. Using any other byte order mark does
+1 -2
View File
@@ -1975,12 +1975,11 @@ namespace ts {
}
function cacheExpression(node: Expression): Identifier {
let temp: Identifier;
if (isGeneratedIdentifier(node) || getEmitFlags(node) & EmitFlags.HelperName) {
return <Identifier>node;
}
temp = createTempVariable(hoistVariableDeclaration);
const temp = createTempVariable(hoistVariableDeclaration);
emitAssignment(temp, node, /*location*/ node);
return temp;
}
+2 -1
View File
@@ -4724,7 +4724,7 @@ namespace ts {
return { span, newLength };
}
export let unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
export let unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const
/**
* Called to merge all the changes that occurred across several versions of a script snapshot
@@ -7025,6 +7025,7 @@ namespace ts {
this.skipTrivia = skipTrivia || (pos => pos);
}
// eslint-disable-next-line prefer-const
export let objectAllocator: ObjectAllocator = {
getNodeConstructor: () => <any>Node,
getTokenConstructor: () => <any>Node,
+2
View File
@@ -623,8 +623,10 @@ namespace Harness {
) => void;
// Settings
/* eslint-disable prefer-const */
export let userSpecifiedRoot = "";
export let lightMode = false;
/* eslint-enable prefer-const */
/** Functionality for compiling TypeScript code */
export namespace Compiler {
+3 -5
View File
@@ -594,15 +594,13 @@ namespace Harness.LanguageService {
getLanguageService(): ts.LanguageService { return new LanguageServiceShimProxy(this.factory.createLanguageServiceShim(this.host)); }
getClassifier(): ts.Classifier { return new ClassifierShimProxy(this.factory.createClassifierShim(this.host)); }
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo {
let shimResult: {
const coreServicesShim = this.factory.createCoreServicesShim(this.host);
const shimResult: {
referencedFiles: ts.ShimsFileReference[];
typeReferenceDirectives: ts.ShimsFileReference[];
importedFiles: ts.ShimsFileReference[];
isLibFile: boolean;
};
const coreServicesShim = this.factory.createCoreServicesShim(this.host);
shimResult = unwrapJSONCallResult(coreServicesShim.getPreProcessedFileInfo(fileName, ts.ScriptSnapshot.fromString(fileContents)));
} = unwrapJSONCallResult(coreServicesShim.getPreProcessedFileInfo(fileName, ts.ScriptSnapshot.fromString(fileContents)));
const convertResult: ts.PreProcessedFileInfo = {
referencedFiles: [],
+1 -1
View File
@@ -1012,7 +1012,7 @@ namespace ts {
return sourceFile;
}
export let disableIncrementalParsing = false;
export let disableIncrementalParsing = false; // eslint-disable-line prefer-const
export function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange | undefined, aggressiveChecks?: boolean): SourceFile {
// If we were given a text change range, and our version or open-ness changed, then
+1 -1
View File
@@ -14,7 +14,7 @@
//
/* @internal */
let debugObjectHost: { CollectGarbage(): void } = (function (this: any) { return this; })();
let debugObjectHost: { CollectGarbage(): void } = (function (this: any) { return this; })(); // eslint-disable-line prefer-const
// We need to use 'null' to interface with the managed side.
/* tslint:disable:no-null-keyword */
+3 -3
View File
@@ -1,5 +1,5 @@
let runners: RunnerBase[] = [];
let iterations = 1;
const runners: RunnerBase[] = [];
const iterations = 1;
function runTests(runners: RunnerBase[]) {
for (let i = iterations; i > 0; i--) {
@@ -50,7 +50,7 @@ const mytestconfigFileName = "mytest.config";
const testconfigFileName = "test.config";
const customConfig = tryGetConfig(Harness.IO.args());
let testConfigContent =
const testConfigContent =
customConfig && Harness.IO.fileExists(customConfig)
? Harness.IO.readFile(customConfig)!
: Harness.IO.fileExists(mytestconfigFileName)
@@ -7,15 +7,11 @@ namespace ts {
function transpilesCorrectly(name: string, input: string, testSettings: TranspileTestSettings) {
describe(name, () => {
let justName: string;
let transpileOptions: TranspileOptions;
let canUseOldTranspile: boolean;
let toBeCompiled: Harness.Compiler.TestFile[];
let transpileResult: TranspileOutput;
let oldTranspileResult: string;
let oldTranspileDiagnostics: Diagnostic[];
transpileOptions = testSettings.options || {};
const transpileOptions: TranspileOptions = testSettings.options || {};
if (!transpileOptions.compilerOptions) {
transpileOptions.compilerOptions = {};
}
@@ -33,13 +29,12 @@ namespace ts {
transpileOptions.reportDiagnostics = true;
justName = "transpile/" + name.replace(/[^a-z0-9\-. ]/ig, "") + (transpileOptions.compilerOptions.jsx ? Extension.Tsx : Extension.Ts);
toBeCompiled = [{
const justName = "transpile/" + name.replace(/[^a-z0-9\-. ]/ig, "") + (transpileOptions.compilerOptions.jsx ? Extension.Tsx : Extension.Ts);
const toBeCompiled: Harness.Compiler.TestFile[] = [{
unitName: transpileOptions.fileName,
content: input
}];
canUseOldTranspile = !transpileOptions.renamedDependencies;
const canUseOldTranspile = !transpileOptions.renamedDependencies;
before(() => {
transpileResult = transpileModule(input, transpileOptions);