mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Fix let->var related errors, revert some lets
This commit is contained in:
parent
bb7cfd1b0f
commit
f33a2b06d4
@ -48,7 +48,6 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
|
||||
let units: Harness.TestCaseParser.TestUnitData[];
|
||||
let tcSettings: Harness.TestCaseParser.CompilerSetting[];
|
||||
let createNewInstance: boolean;
|
||||
|
||||
let lastUnit: Harness.TestCaseParser.TestUnitData;
|
||||
let rootDir: string;
|
||||
|
||||
@ -510,8 +510,9 @@ module FourSlash {
|
||||
let exists = false;
|
||||
|
||||
let startPos = startMarker.position;
|
||||
let endPos: number = undefined;
|
||||
if (endMarker !== undefined) {
|
||||
let endPos = endMarker.position;
|
||||
endPos = endMarker.position;
|
||||
}
|
||||
|
||||
errors.forEach(function (error: ts.Diagnostic) {
|
||||
@ -989,12 +990,12 @@ module FourSlash {
|
||||
ts.displayPartsToString(help.suffixDisplayParts), expected);
|
||||
}
|
||||
|
||||
public verifyCurrentParameterIsletiable(isletiable: boolean) {
|
||||
public verifyCurrentParameterIsletiable(isVariable: boolean) {
|
||||
this.taoInvalidReason = 'verifyCurrentParameterIsletiable NYI';
|
||||
|
||||
let signature = this.getActiveSignatureHelpItem();
|
||||
assert.isNotNull(signature);
|
||||
assert.equal(isletiable, signature.isletiadic);
|
||||
assert.equal(isVariable, signature.isVariadic);
|
||||
}
|
||||
|
||||
public verifyCurrentParameterHelpName(name: string) {
|
||||
@ -1511,7 +1512,7 @@ module FourSlash {
|
||||
}
|
||||
|
||||
let incrementalSourceFile = this.languageService.getSourceFile(this.activeFile.fileName);
|
||||
Utils.assertInletiants(incrementalSourceFile, /*parent:*/ undefined);
|
||||
Utils.assertInvariants(incrementalSourceFile, /*parent:*/ undefined);
|
||||
|
||||
let incrementalSyntaxDiagnostics = incrementalSourceFile.parseDiagnostics;
|
||||
|
||||
|
||||
@ -24,17 +24,15 @@
|
||||
/// <reference path='sourceMapRecorder.ts'/>
|
||||
/// <reference path='runnerbase.ts'/>
|
||||
|
||||
let Buffer: BufferConstructor = require('buffer').Buffer;
|
||||
var Buffer: BufferConstructor = require('buffer').Buffer;
|
||||
|
||||
// this will work in the browser via browserify
|
||||
let _chai: typeof chai = require('chai');
|
||||
let assert: typeof _chai.assert = _chai.assert;
|
||||
declare let __dirname: string; // Node-specific
|
||||
let global = <any>Function("return this").call(null);
|
||||
var _chai: typeof chai = require('chai');
|
||||
var assert: typeof _chai.assert = _chai.assert;
|
||||
declare var __dirname: string; // Node-specific
|
||||
var global = <any>Function("return this").call(null);
|
||||
|
||||
module Utils {
|
||||
let global = <any>Function("return this").call(null);
|
||||
|
||||
// Setup some globals based on the current environment
|
||||
export const enum ExecutionEnvironment {
|
||||
Node,
|
||||
@ -98,8 +96,9 @@ module Utils {
|
||||
path = "tests/" + path;
|
||||
}
|
||||
|
||||
let content = '';
|
||||
try {
|
||||
let content = ts.sys.readFile(Harness.userSpecifiedRoot + path);
|
||||
content = ts.sys.readFile(Harness.userSpecifiedRoot + path);
|
||||
}
|
||||
catch (err) {
|
||||
return undefined;
|
||||
@ -122,7 +121,7 @@ module Utils {
|
||||
});
|
||||
}
|
||||
|
||||
export function assertInletiants(node: ts.Node, parent: ts.Node): void {
|
||||
export function assertInvariants(node: ts.Node, parent: ts.Node): void {
|
||||
if (node) {
|
||||
assert.isFalse(node.pos < 0, "node.pos < 0");
|
||||
assert.isFalse(node.end < 0, "node.end < 0");
|
||||
@ -136,7 +135,7 @@ module Utils {
|
||||
}
|
||||
|
||||
ts.forEachChild(node, child => {
|
||||
assertInletiants(child, node);
|
||||
assertInvariants(child, node);
|
||||
});
|
||||
|
||||
// Make sure each of the children is in order.
|
||||
@ -606,8 +605,8 @@ module Harness {
|
||||
export function writeToServerSync(url: string, action: string, contents?: string): XHRResponse {
|
||||
let xhr = new XMLHttpRequest();
|
||||
try {
|
||||
let action = '?action=' + action;
|
||||
xhr.open('POST', url + action, false);
|
||||
let actionMsg = '?action=' + action;
|
||||
xhr.open('POST', url + actionMsg, false);
|
||||
xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
|
||||
xhr.send(contents);
|
||||
}
|
||||
@ -645,7 +644,7 @@ module Harness {
|
||||
if (dirPath.match(/.*\/$/)) {
|
||||
dirPath = dirPath.substring(0, dirPath.length - 2);
|
||||
}
|
||||
let dirPath = dirPath.substring(0, dirPath.lastIndexOf('/'));
|
||||
dirPath = dirPath.substring(0, dirPath.lastIndexOf('/'));
|
||||
}
|
||||
|
||||
return dirPath;
|
||||
@ -690,7 +689,7 @@ module Harness {
|
||||
}
|
||||
}
|
||||
|
||||
export let IO: IO;
|
||||
export var IO: IO;
|
||||
switch (Utils.getExecutionEnvironment()) {
|
||||
case Utils.ExecutionEnvironment.CScript:
|
||||
IO = IOImpl.CScript;
|
||||
@ -808,18 +807,18 @@ module Harness {
|
||||
}
|
||||
}
|
||||
|
||||
export function createSourceFileAndAssertInletiants(
|
||||
export function createSourceFileAndAssertInvariants(
|
||||
fileName: string,
|
||||
sourceText: string,
|
||||
languageVersion: ts.ScriptTarget) {
|
||||
// We'll only assert inletiants outside of light mode.
|
||||
const shouldAssertInletiants = !Harness.lightMode;
|
||||
const shouldassertInvariants = !Harness.lightMode;
|
||||
|
||||
// Only set the parent nodes if we're asserting inletiants. We don't need them otherwise.
|
||||
let result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInletiants);
|
||||
let result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldassertInvariants);
|
||||
|
||||
if (shouldAssertInletiants) {
|
||||
Utils.assertInletiants(result, /*parent:*/ undefined);
|
||||
if (shouldassertInvariants) {
|
||||
Utils.assertInvariants(result, /*parent:*/ undefined);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -829,8 +828,8 @@ module Harness {
|
||||
const lineFeed = "\n";
|
||||
|
||||
export let defaultLibFileName = 'lib.d.ts';
|
||||
export let defaultLibSourceFile = createSourceFileAndAssertInletiants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
export let defaultES6LibSourceFile = createSourceFileAndAssertInletiants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
export let defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
export let defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
|
||||
// Cache these between executions so we don't have to re-parse them for every test
|
||||
export let fourslashFileName = 'fourslash.ts';
|
||||
@ -861,7 +860,7 @@ module Harness {
|
||||
function register(file: { unitName: string; content: string; }) {
|
||||
if (file.content !== undefined) {
|
||||
let fileName = ts.normalizePath(file.unitName);
|
||||
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInletiants(fileName, file.content, scriptTarget);
|
||||
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
|
||||
}
|
||||
};
|
||||
inputFiles.forEach(register);
|
||||
@ -884,7 +883,7 @@ module Harness {
|
||||
}
|
||||
else if (fn === fourslashFileName) {
|
||||
let tsFn = 'tests/cases/fourslash/' + fourslashFileName;
|
||||
fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInletiants(tsFn, Harness.IO.readFile(tsFn), scriptTarget);
|
||||
fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget);
|
||||
return fourslashSourceFile;
|
||||
}
|
||||
else {
|
||||
@ -1192,12 +1191,12 @@ module Harness {
|
||||
throw new Error('There were no errors and declFiles generated did not match number of js files generated');
|
||||
}
|
||||
|
||||
let declInputFiles: { unitName: string; content: string }[] = [];
|
||||
let declOtherFiles: { unitName: string; content: string }[] = [];
|
||||
let declResult: Harness.Compiler.CompilerResult;
|
||||
|
||||
// if the .d.ts is non-empty, confirm it compiles correctly as well
|
||||
if (options.declaration && result.errors.length === 0 && result.declFilesCode.length > 0) {
|
||||
let declInputFiles: { unitName: string; content: string }[] = [];
|
||||
let declOtherFiles: { unitName: string; content: string }[] = [];
|
||||
let declResult: Harness.Compiler.CompilerResult;
|
||||
|
||||
ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles));
|
||||
ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles));
|
||||
this.compileFiles(declInputFiles, declOtherFiles, function (compileResult) { declResult = compileResult; },
|
||||
|
||||
@ -60,8 +60,9 @@ class ProjectRunner extends RunnerBase {
|
||||
private runProjectTestCase(testCaseFileName: string) {
|
||||
let testCase: ProjectRunnerTestCase;
|
||||
|
||||
let testFileText: string = null;
|
||||
try {
|
||||
let testFileText = ts.sys.readFile(testCaseFileName);
|
||||
testFileText = ts.sys.readFile(testCaseFileName);
|
||||
}
|
||||
catch (e) {
|
||||
assert(false, "Unable to open testcase file: " + testCaseFileName + ": " + e.message);
|
||||
@ -175,7 +176,7 @@ class ProjectRunner extends RunnerBase {
|
||||
else {
|
||||
let text = getSourceFileText(fileName);
|
||||
if (text !== undefined) {
|
||||
sourceFile = Harness.Compiler.createSourceFileAndAssertInletiants(fileName, text, languageVersion);
|
||||
sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,8 +212,9 @@ class ProjectRunner extends RunnerBase {
|
||||
};
|
||||
|
||||
function getSourceFileText(fileName: string): string {
|
||||
let text: string = undefined;
|
||||
try {
|
||||
let text = ts.sys.readFile(ts.isRootedDiskPath(fileName)
|
||||
text = ts.sys.readFile(ts.isRootedDiskPath(fileName)
|
||||
? fileName
|
||||
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName));
|
||||
}
|
||||
@ -281,13 +283,14 @@ class ProjectRunner extends RunnerBase {
|
||||
allInputFiles.unshift({ emittedFileName: sourceFile.fileName, code: sourceFile.text });
|
||||
}
|
||||
else if (ts.shouldEmitToOwnFile(sourceFile, compilerResult.program.getCompilerOptions())) {
|
||||
let emitOutputFilePathWithoutExtension: string = undefined;
|
||||
if (compilerOptions.outDir) {
|
||||
let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, compilerResult.program.getCurrentDirectory());
|
||||
sourceFilePath = sourceFilePath.replace(compilerResult.program.getCommonSourceDirectory(), "");
|
||||
let emitOutputFilePathWithoutExtension = ts.removeFileExtension(ts.combinePaths(compilerOptions.outDir, sourceFilePath));
|
||||
emitOutputFilePathWithoutExtension = ts.removeFileExtension(ts.combinePaths(compilerOptions.outDir, sourceFilePath));
|
||||
}
|
||||
else {
|
||||
let emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName);
|
||||
emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName);
|
||||
}
|
||||
|
||||
let outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts";
|
||||
|
||||
@ -76,7 +76,7 @@ module RWC {
|
||||
// Add files to compilation
|
||||
for (let fileRead of ioLog.filesRead) {
|
||||
// Check if the file is already added into the set of input files.
|
||||
let resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
|
||||
var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
|
||||
let inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath);
|
||||
|
||||
if (!Harness.isLibraryFile(fileRead.path)) {
|
||||
@ -118,8 +118,9 @@ module RWC {
|
||||
|
||||
function getHarnessCompilerInputUnit(fileName: string) {
|
||||
let unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName));
|
||||
let content: string = null;
|
||||
try {
|
||||
let content = ts.sys.readFile(unitName);
|
||||
content = ts.sys.readFile(unitName);
|
||||
}
|
||||
catch (e) {
|
||||
// Leave content undefined.
|
||||
|
||||
@ -81,7 +81,7 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
|
||||
it('satisfies inletiants', () => {
|
||||
let sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename));
|
||||
Utils.assertInletiants(sourceFile, /*parent:*/ undefined);
|
||||
Utils.assertInvariants(sourceFile, /*parent:*/ undefined);
|
||||
});
|
||||
|
||||
it('has the expected AST', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user