Skip to content

Commit f33a2b0

Browse files
committed
Fix let->var related errors, revert some lets
1 parent bb7cfd1 commit f33a2b0

File tree

6 files changed

+43
-40
lines changed

6 files changed

+43
-40
lines changed

src/harness/compilerRunner.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class CompilerBaselineRunner extends RunnerBase {
4848

4949
let units: Harness.TestCaseParser.TestUnitData[];
5050
let tcSettings: Harness.TestCaseParser.CompilerSetting[];
51-
let createNewInstance: boolean;
5251

5352
let lastUnit: Harness.TestCaseParser.TestUnitData;
5453
let rootDir: string;

src/harness/fourslash.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,9 @@ module FourSlash {
510510
let exists = false;
511511

512512
let startPos = startMarker.position;
513+
let endPos: number = undefined;
513514
if (endMarker !== undefined) {
514-
let endPos = endMarker.position;
515+
endPos = endMarker.position;
515516
}
516517

517518
errors.forEach(function (error: ts.Diagnostic) {
@@ -989,12 +990,12 @@ module FourSlash {
989990
ts.displayPartsToString(help.suffixDisplayParts), expected);
990991
}
991992

992-
public verifyCurrentParameterIsletiable(isletiable: boolean) {
993+
public verifyCurrentParameterIsletiable(isVariable: boolean) {
993994
this.taoInvalidReason = 'verifyCurrentParameterIsletiable NYI';
994995

995996
let signature = this.getActiveSignatureHelpItem();
996997
assert.isNotNull(signature);
997-
assert.equal(isletiable, signature.isletiadic);
998+
assert.equal(isVariable, signature.isVariadic);
998999
}
9991000

10001001
public verifyCurrentParameterHelpName(name: string) {
@@ -1511,7 +1512,7 @@ module FourSlash {
15111512
}
15121513

15131514
let incrementalSourceFile = this.languageService.getSourceFile(this.activeFile.fileName);
1514-
Utils.assertInletiants(incrementalSourceFile, /*parent:*/ undefined);
1515+
Utils.assertInvariants(incrementalSourceFile, /*parent:*/ undefined);
15151516

15161517
let incrementalSyntaxDiagnostics = incrementalSourceFile.parseDiagnostics;
15171518

src/harness/harness.ts

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@
2424
/// <reference path='sourceMapRecorder.ts'/>
2525
/// <reference path='runnerbase.ts'/>
2626

27-
let Buffer: BufferConstructor = require('buffer').Buffer;
27+
var Buffer: BufferConstructor = require('buffer').Buffer;
2828

2929
// this will work in the browser via browserify
30-
let _chai: typeof chai = require('chai');
31-
let assert: typeof _chai.assert = _chai.assert;
32-
declare let __dirname: string; // Node-specific
33-
let global = <any>Function("return this").call(null);
30+
var _chai: typeof chai = require('chai');
31+
var assert: typeof _chai.assert = _chai.assert;
32+
declare var __dirname: string; // Node-specific
33+
var global = <any>Function("return this").call(null);
3434

3535
module Utils {
36-
let global = <any>Function("return this").call(null);
37-
3836
// Setup some globals based on the current environment
3937
export const enum ExecutionEnvironment {
4038
Node,
@@ -98,8 +96,9 @@ module Utils {
9896
path = "tests/" + path;
9997
}
10098

99+
let content = '';
101100
try {
102-
let content = ts.sys.readFile(Harness.userSpecifiedRoot + path);
101+
content = ts.sys.readFile(Harness.userSpecifiedRoot + path);
103102
}
104103
catch (err) {
105104
return undefined;
@@ -122,7 +121,7 @@ module Utils {
122121
});
123122
}
124123

125-
export function assertInletiants(node: ts.Node, parent: ts.Node): void {
124+
export function assertInvariants(node: ts.Node, parent: ts.Node): void {
126125
if (node) {
127126
assert.isFalse(node.pos < 0, "node.pos < 0");
128127
assert.isFalse(node.end < 0, "node.end < 0");
@@ -136,7 +135,7 @@ module Utils {
136135
}
137136

138137
ts.forEachChild(node, child => {
139-
assertInletiants(child, node);
138+
assertInvariants(child, node);
140139
});
141140

142141
// Make sure each of the children is in order.
@@ -606,8 +605,8 @@ module Harness {
606605
export function writeToServerSync(url: string, action: string, contents?: string): XHRResponse {
607606
let xhr = new XMLHttpRequest();
608607
try {
609-
let action = '?action=' + action;
610-
xhr.open('POST', url + action, false);
608+
let actionMsg = '?action=' + action;
609+
xhr.open('POST', url + actionMsg, false);
611610
xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
612611
xhr.send(contents);
613612
}
@@ -645,7 +644,7 @@ module Harness {
645644
if (dirPath.match(/.*\/$/)) {
646645
dirPath = dirPath.substring(0, dirPath.length - 2);
647646
}
648-
let dirPath = dirPath.substring(0, dirPath.lastIndexOf('/'));
647+
dirPath = dirPath.substring(0, dirPath.lastIndexOf('/'));
649648
}
650649

651650
return dirPath;
@@ -690,7 +689,7 @@ module Harness {
690689
}
691690
}
692691

693-
export let IO: IO;
692+
export var IO: IO;
694693
switch (Utils.getExecutionEnvironment()) {
695694
case Utils.ExecutionEnvironment.CScript:
696695
IO = IOImpl.CScript;
@@ -808,18 +807,18 @@ module Harness {
808807
}
809808
}
810809

811-
export function createSourceFileAndAssertInletiants(
810+
export function createSourceFileAndAssertInvariants(
812811
fileName: string,
813812
sourceText: string,
814813
languageVersion: ts.ScriptTarget) {
815814
// We'll only assert inletiants outside of light mode.
816-
const shouldAssertInletiants = !Harness.lightMode;
815+
const shouldassertInvariants = !Harness.lightMode;
817816

818817
// Only set the parent nodes if we're asserting inletiants. We don't need them otherwise.
819-
let result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInletiants);
818+
let result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldassertInvariants);
820819

821-
if (shouldAssertInletiants) {
822-
Utils.assertInletiants(result, /*parent:*/ undefined);
820+
if (shouldassertInvariants) {
821+
Utils.assertInvariants(result, /*parent:*/ undefined);
823822
}
824823

825824
return result;
@@ -829,8 +828,8 @@ module Harness {
829828
const lineFeed = "\n";
830829

831830
export let defaultLibFileName = 'lib.d.ts';
832-
export let defaultLibSourceFile = createSourceFileAndAssertInletiants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
833-
export let defaultES6LibSourceFile = createSourceFileAndAssertInletiants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
831+
export let defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
832+
export let defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
834833

835834
// Cache these between executions so we don't have to re-parse them for every test
836835
export let fourslashFileName = 'fourslash.ts';
@@ -861,7 +860,7 @@ module Harness {
861860
function register(file: { unitName: string; content: string; }) {
862861
if (file.content !== undefined) {
863862
let fileName = ts.normalizePath(file.unitName);
864-
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInletiants(fileName, file.content, scriptTarget);
863+
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
865864
}
866865
};
867866
inputFiles.forEach(register);
@@ -884,7 +883,7 @@ module Harness {
884883
}
885884
else if (fn === fourslashFileName) {
886885
let tsFn = 'tests/cases/fourslash/' + fourslashFileName;
887-
fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInletiants(tsFn, Harness.IO.readFile(tsFn), scriptTarget);
886+
fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget);
888887
return fourslashSourceFile;
889888
}
890889
else {
@@ -1192,12 +1191,12 @@ module Harness {
11921191
throw new Error('There were no errors and declFiles generated did not match number of js files generated');
11931192
}
11941193

1194+
let declInputFiles: { unitName: string; content: string }[] = [];
1195+
let declOtherFiles: { unitName: string; content: string }[] = [];
1196+
let declResult: Harness.Compiler.CompilerResult;
1197+
11951198
// if the .d.ts is non-empty, confirm it compiles correctly as well
11961199
if (options.declaration && result.errors.length === 0 && result.declFilesCode.length > 0) {
1197-
let declInputFiles: { unitName: string; content: string }[] = [];
1198-
let declOtherFiles: { unitName: string; content: string }[] = [];
1199-
let declResult: Harness.Compiler.CompilerResult;
1200-
12011200
ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles));
12021201
ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles));
12031202
this.compileFiles(declInputFiles, declOtherFiles, function (compileResult) { declResult = compileResult; },

src/harness/projectsRunner.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ class ProjectRunner extends RunnerBase {
6060
private runProjectTestCase(testCaseFileName: string) {
6161
let testCase: ProjectRunnerTestCase;
6262

63+
let testFileText: string = null;
6364
try {
64-
let testFileText = ts.sys.readFile(testCaseFileName);
65+
testFileText = ts.sys.readFile(testCaseFileName);
6566
}
6667
catch (e) {
6768
assert(false, "Unable to open testcase file: " + testCaseFileName + ": " + e.message);
@@ -175,7 +176,7 @@ class ProjectRunner extends RunnerBase {
175176
else {
176177
let text = getSourceFileText(fileName);
177178
if (text !== undefined) {
178-
sourceFile = Harness.Compiler.createSourceFileAndAssertInletiants(fileName, text, languageVersion);
179+
sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion);
179180
}
180181
}
181182

@@ -211,8 +212,9 @@ class ProjectRunner extends RunnerBase {
211212
};
212213

213214
function getSourceFileText(fileName: string): string {
215+
let text: string = undefined;
214216
try {
215-
let text = ts.sys.readFile(ts.isRootedDiskPath(fileName)
217+
text = ts.sys.readFile(ts.isRootedDiskPath(fileName)
216218
? fileName
217219
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName));
218220
}
@@ -281,13 +283,14 @@ class ProjectRunner extends RunnerBase {
281283
allInputFiles.unshift({ emittedFileName: sourceFile.fileName, code: sourceFile.text });
282284
}
283285
else if (ts.shouldEmitToOwnFile(sourceFile, compilerResult.program.getCompilerOptions())) {
286+
let emitOutputFilePathWithoutExtension: string = undefined;
284287
if (compilerOptions.outDir) {
285288
let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, compilerResult.program.getCurrentDirectory());
286289
sourceFilePath = sourceFilePath.replace(compilerResult.program.getCommonSourceDirectory(), "");
287-
let emitOutputFilePathWithoutExtension = ts.removeFileExtension(ts.combinePaths(compilerOptions.outDir, sourceFilePath));
290+
emitOutputFilePathWithoutExtension = ts.removeFileExtension(ts.combinePaths(compilerOptions.outDir, sourceFilePath));
288291
}
289292
else {
290-
let emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName);
293+
emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName);
291294
}
292295

293296
let outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts";

src/harness/rwcRunner.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module RWC {
7676
// Add files to compilation
7777
for (let fileRead of ioLog.filesRead) {
7878
// Check if the file is already added into the set of input files.
79-
let resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
79+
var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
8080
let inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath);
8181

8282
if (!Harness.isLibraryFile(fileRead.path)) {
@@ -118,8 +118,9 @@ module RWC {
118118

119119
function getHarnessCompilerInputUnit(fileName: string) {
120120
let unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName));
121+
let content: string = null;
121122
try {
122-
let content = ts.sys.readFile(unitName);
123+
content = ts.sys.readFile(unitName);
123124
}
124125
catch (e) {
125126
// Leave content undefined.

src/harness/test262Runner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class Test262BaselineRunner extends RunnerBase {
8181

8282
it('satisfies inletiants', () => {
8383
let sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename));
84-
Utils.assertInletiants(sourceFile, /*parent:*/ undefined);
84+
Utils.assertInvariants(sourceFile, /*parent:*/ undefined);
8585
});
8686

8787
it('has the expected AST', () => {

0 commit comments

Comments
 (0)