Merge branch 'transforms' into fix-transforms-empty-destructuring-assignment

This commit is contained in:
Nathan Shively-Sanders 2016-04-12 10:15:07 -07:00
commit 2578409b7d
35 changed files with 237 additions and 131 deletions

View File

@ -187,20 +187,20 @@ var harnessSources = harnessCoreSources.concat([
"protocol.d.ts",
"session.ts",
"client.ts",
"editorServices.ts",
"editorServices.ts"
].map(function (f) {
return path.join(serverDirectory, f);
}));
var librarySourceMap = [
{ target: "lib.core.d.ts", sources: ["header.d.ts", "core.d.ts"] },
{ target: "lib.dom.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "dom.generated.d.ts"], },
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "webworker.generated.d.ts"], },
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], },
{ target: "lib.d.ts", sources: ["header.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
{ target: "lib.core.es6.d.ts", sources: ["header.d.ts", "core.d.ts", "es6.d.ts"]},
{ target: "lib.dom.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "dom.generated.d.ts"] },
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "webworker.generated.d.ts"] },
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"] },
{ target: "lib.d.ts", sources: ["header.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] },
{ target: "lib.core.es6.d.ts", sources: ["header.d.ts", "core.d.ts", "es6.d.ts"] },
{ target: "lib.es6.d.ts", sources: ["header.d.ts", "es6.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] },
{ target: "lib.core.es7.d.ts", sources: ["header.d.ts", "core.d.ts", "es6.d.ts", "es7.d.ts"]},
{ target: "lib.core.es7.d.ts", sources: ["header.d.ts", "core.d.ts", "es6.d.ts", "es7.d.ts"] },
{ target: "lib.es7.d.ts", sources: ["header.d.ts", "es6.d.ts", "es7.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] }
];
@ -242,7 +242,7 @@ function concatenateFiles(destinationFile, sourceFiles) {
}
var useDebugMode = true;
var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node");
var host = process.env.host || process.env.TYPESCRIPT_HOST || "node";
var compilerFilename = "tsc.js";
var LKGCompiler = path.join(LKGDirectory, compilerFilename);
var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
@ -291,7 +291,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
options += " --out " + outFile;
}
else {
options += " --module commonjs"
options += " --module commonjs";
}
if(opts.noResolve) {
@ -306,7 +306,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
}
if (opts.stripInternal) {
options += " --stripInternal"
options += " --stripInternal";
}
if (useBuiltCompiler && !/^(no?|f(alse)?|0|-)$/i.test(process.env.USE_TRANSFORMS)) {
@ -448,9 +448,9 @@ file(scriptsTsdJson);
task("tsd-scripts", [scriptsTsdJson], function () {
var cmd = "tsd --config " + scriptsTsdJson + " install";
console.log(cmd)
console.log(cmd);
exec(cmd);
}, { async: true })
}, { async: true });
var importDefinitelyTypedTestsDirectory = path.join(scriptsDirectory, "importDefinitelyTypedTests");
var importDefinitelyTypedTestsJs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.js");
@ -617,7 +617,7 @@ directory(builtLocalDirectory);
var run = path.join(builtLocalDirectory, "run.js");
compileFile(run, harnessSources, [builtLocalDirectory, tscFile].concat(libraryTargets).concat(harnessSources), [], /*useBuiltCompiler:*/ true);
var internalTests = "internal/"
var internalTests = "internal/";
var localBaseline = "tests/baselines/local/";
var refBaseline = "tests/baselines/reference/";
@ -845,7 +845,7 @@ function runConsoleTests(defaultReporter, defaultSubsets) {
testTimeout = 100000;
}
colors = process.env.colors || process.env.color
colors = process.env.colors || process.env.color;
colors = colors ? ' --no-colors ' : ' --colors ';
reporter = process.env.reporter || process.env.r || defaultReporter;
@ -853,7 +853,7 @@ function runConsoleTests(defaultReporter, defaultSubsets) {
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
var subsetRegexes;
if(defaultSubsets.length === 0) {
subsetRegexes = [tests]
subsetRegexes = [tests];
}
else {
var subsets = tests ? tests.split("|") : defaultSubsets;
@ -903,8 +903,8 @@ task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
}, { async: true });
// Browser tests
var nodeServerOutFile = 'tests/webTestServer.js'
var nodeServerInFile = 'tests/webTestServer.ts'
var nodeServerOutFile = 'tests/webTestServer.js';
var nodeServerInFile = 'tests/webTestServer.ts';
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true });
desc("Runs browserify on run.js to produce a file suitable for running tests in the browser");
@ -916,7 +916,7 @@ task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function()
desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], port=, browser=[chrome|IE]");
task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function() {
cleanTestDirs();
host = "node"
host = "node";
port = process.env.port || process.env.p || '8888';
browser = process.env.browser || process.env.b || "IE";
tests = process.env.test || process.env.tests || process.env.t;
@ -930,13 +930,13 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFi
}
tests = tests ? tests : '';
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + tests
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + tests;
console.log(cmd);
exec(cmd);
}, {async: true});
function getDiffTool() {
var program = process.env['DIFF']
var program = process.env['DIFF'];
if (!program) {
fail("Add the 'DIFF' environment variable to the path of the program you want to use.");
}
@ -965,11 +965,11 @@ task("tests-debug", ["setDebugMode", "tests"]);
// Makes the test results the new baseline
desc("Makes the most recent test results the new baseline, overwriting the old baseline");
task("baseline-accept", function(hardOrSoft) {
if (!hardOrSoft || hardOrSoft == "hard") {
if (!hardOrSoft || hardOrSoft === "hard") {
jake.rmRf(refBaseline);
fs.renameSync(localBaseline, refBaseline);
}
else if (hardOrSoft == "soft") {
else if (hardOrSoft === "soft") {
var files = jake.readdirR(localBaseline);
for (var i in files) {
jake.cpR(files[i], refBaseline);
@ -1048,7 +1048,7 @@ task("update-sublime", ["local", serverFile], function() {
});
var tslintRuleDir = "scripts/tslint";
var tslintRules = ([
var tslintRules = [
"nextLineRule",
"noNullRule",
"preferConstRule",
@ -1056,7 +1056,7 @@ var tslintRules = ([
"typeOperatorSpacingRule",
"noInOperatorRule",
"noIncrementDecrementRule"
]);
];
var tslintRulesFiles = tslintRules.map(function(p) {
return path.join(tslintRuleDir, p + ".ts");
});
@ -1081,7 +1081,7 @@ function getLinterOptions() {
function lintFileContents(options, path, contents) {
var ll = new Linter(path, contents, options);
console.log("Linting '" + path + "'.")
console.log("Linting '" + path + "'.");
return ll.lint();
}

View File

@ -1163,11 +1163,11 @@ namespace ts {
let thisArg: Expression;
let target: LeftHandSideExpression;
if (isSuperProperty(callee)) {
thisArg = createThis(/*location*/ callee.expression);
thisArg = createThis();
target = callee;
}
else if (callee.kind === SyntaxKind.SuperKeyword) {
thisArg = createThis(/*location*/ callee);
thisArg = createThis();
target = languageVersion < ScriptTarget.ES6 ? createIdentifier("_super", /*location*/ callee) : <PrimaryExpression>callee;
}
else {
@ -1180,15 +1180,15 @@ namespace ts {
createAssignment(
thisArg,
(<PropertyAccessExpression>callee).expression,
/*location*/(<PropertyAccessExpression>callee).expression
/*location*/ (<PropertyAccessExpression>callee).expression
),
(<PropertyAccessExpression>callee).name,
/*location*/ callee
/*location*/ callee
);
}
else {
thisArg = (<PropertyAccessExpression>callee).expression;
target = <PropertyAccessExpression>callee;
target = <PropertyAccessExpression>callee;
}
break;
}
@ -1201,10 +1201,10 @@ namespace ts {
createAssignment(
thisArg,
(<ElementAccessExpression>callee).expression,
/*location*/(<ElementAccessExpression>callee).expression
/*location*/ (<ElementAccessExpression>callee).expression
),
(<ElementAccessExpression>callee).argumentExpression,
/*location*/ callee
/*location*/ callee
);
}
else {

View File

@ -735,7 +735,14 @@ namespace ts {
}
addRange(statements, endLexicalEnvironment());
return createBlock(statements, /*location*/ constructor && constructor.body, /*multiLine*/ true);
return createBlock(
createNodeArray(
statements,
/*location*/ constructor ? constructor.body.statements : undefined
),
/*location*/ constructor ? constructor.body : undefined,
/*multiLine*/ true
);
}
function transformConstructorBodyWithSynthesizedSuper(node: ConstructorDeclaration) {
@ -924,7 +931,7 @@ namespace ts {
* synthesized call to `super`
*/
function shouldAddRestParameter(node: ParameterDeclaration, inConstructorWithSynthesizedSuper: boolean) {
return node && node.dotDotDotToken && !inConstructorWithSynthesizedSuper;
return node && node.dotDotDotToken && node.name.kind === SyntaxKind.Identifier && !inConstructorWithSynthesizedSuper;
}
/**
@ -2746,4 +2753,4 @@ namespace ts {
return isIdentifier(expression) && expression === parameter.name;
}
}
}
}

View File

@ -23,6 +23,8 @@ namespace ts {
switch (node.kind) {
case SyntaxKind.ImportDeclaration:
return visitImportDeclaration(<ImportDeclaration>node);
case SyntaxKind.ImportEqualsDeclaration:
return visitImportEqualsDeclaration(<ImportEqualsDeclaration>node);
case SyntaxKind.ImportClause:
return visitImportClause(<ImportClause>node);
case SyntaxKind.NamedImports:
@ -30,11 +32,25 @@ namespace ts {
return visitNamedBindings(<NamedImportBindings>node);
case SyntaxKind.ImportSpecifier:
return visitImportSpecifier(<ImportSpecifier>node);
case SyntaxKind.ExportAssignment:
return visitExportAssignment(<ExportAssignment>node);
}
return node;
}
function visitExportAssignment(node: ExportAssignment): ExportDeclaration {
if (node.isExportEquals) {
return undefined; // do not emit export equals for ES6
}
const original = getOriginalNode(node);
return nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node: undefined;
}
function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): ImportEqualsDeclaration {
return !isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined;
}
function visitImportDeclaration(node: ImportDeclaration) {
if (node.importClause) {
const newImportClause = visitNode(node.importClause, visitor, isImportClause);

View File

@ -31,7 +31,7 @@ namespace ts {
let externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[];
let exportSpecifiers: Map<ExportSpecifier[]>;
let exportEquals: ExportAssignment;
let hasExportStars: boolean;
let hasExportStarsToExportValues: boolean;
return transformSourceFile;
@ -45,7 +45,7 @@ namespace ts {
currentSourceFile = node;
// Collect information about the external module.
({ externalImports, exportSpecifiers, exportEquals, hasExportStars } = collectExternalModuleInfo(node, resolver));
({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node, resolver));
// Perform the transformation.
const updated = transformModuleDelegates[moduleKind](node);
@ -55,7 +55,7 @@ namespace ts {
externalImports = undefined;
exportSpecifiers = undefined;
exportEquals = undefined;
hasExportStars = false;
hasExportStarsToExportValues = false;
return updated;
}
@ -77,7 +77,7 @@ namespace ts {
addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false);
const updated = updateSourceFile(node, statements);
if (hasExportStars) {
if (hasExportStarsToExportValues) {
setNodeEmitFlags(updated, NodeEmitFlags.EmitExportStar | getNodeEmitFlags(node));
}
@ -200,7 +200,7 @@ namespace ts {
addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true);
const body = createBlock(statements, /*location*/ undefined, /*multiLine*/ true);
if (hasExportStars) {
if (hasExportStarsToExportValues) {
// If we have any `export * from ...` declarations
// we need to inform the emitter to add the __export helper.
setNodeEmitFlags(body, NodeEmitFlags.EmitExportStar);
@ -442,7 +442,7 @@ namespace ts {
return singleOrMany(statements);
}
else {
else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) {
// export * from "mod";
return createStatement(
createCall(

View File

@ -37,7 +37,7 @@ namespace ts {
let externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[];
let exportSpecifiers: Map<ExportSpecifier[]>;
let exportEquals: ExportAssignment;
let hasExportStars: boolean;
let hasExportStarsToExportValues: boolean;
let exportFunctionForFile: Identifier;
let contextObjectForFile: Identifier;
let exportedLocalNames: Identifier[];
@ -62,7 +62,7 @@ namespace ts {
externalImports = undefined;
exportSpecifiers = undefined;
exportEquals = undefined;
hasExportStars = false;
hasExportStarsToExportValues = false;
exportFunctionForFile = undefined;
contextObjectForFile = undefined;
exportedLocalNames = undefined;
@ -89,7 +89,7 @@ namespace ts {
Debug.assert(!exportFunctionForFile);
// Collect information about the external module and dependency groups.
({ externalImports, exportSpecifiers, exportEquals, hasExportStars } = collectExternalModuleInfo(node, resolver));
({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node, resolver));
// Make sure that the name of the 'exports' function does not conflict with
// existing identifiers.
@ -253,7 +253,7 @@ namespace ts {
}
function addExportStarIfNeeded(statements: Statement[]) {
if (!hasExportStars) {
if (!hasExportStarsToExportValues) {
return;
}
// when resolving exports local exported entries/indirect exported entries in the module

View File

@ -829,7 +829,13 @@ namespace ts {
// End the lexical environment.
addNodes(statements, endLexicalEnvironment());
return setMultiLine(
createBlock(statements, constructor ? constructor.body : undefined),
createBlock(
createNodeArray(
statements,
/*location*/ constructor ? constructor.body.statements : undefined
),
/*location*/ constructor ? constructor.body : undefined
),
true
);
}

View File

@ -2984,7 +2984,7 @@ namespace ts {
const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = [];
const exportSpecifiers: Map<ExportSpecifier[]> = {};
let exportEquals: ExportAssignment = undefined;
let hasExportStars = false;
let hasExportStarsToExportValues = false;
for (const node of sourceFile.statements) {
switch (node.kind) {
case SyntaxKind.ImportDeclaration:
@ -3009,8 +3009,10 @@ namespace ts {
if ((<ExportDeclaration>node).moduleSpecifier) {
if (!(<ExportDeclaration>node).exportClause) {
// export * from "mod"
externalImports.push(<ExportDeclaration>node);
hasExportStars = true;
if (resolver.moduleExportsSomeValue((<ExportDeclaration>node).moduleSpecifier)) {
externalImports.push(<ExportDeclaration>node);
hasExportStarsToExportValues = true;
}
}
else if (resolver.isValueAliasDeclaration(getOriginalNode(node))) {
// export { x, y } from "mod" where at least one export is a value symbol
@ -3040,7 +3042,7 @@ namespace ts {
}
}
return { externalImports, exportSpecifiers, exportEquals, hasExportStars };
return { externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues };
}
export function getInitializedVariables(node: VariableDeclarationList) {

View File

@ -424,7 +424,7 @@ namespace Utils {
filtered.push(line);
}
(<any>error).stack = filtered.join(ts.sys.newLine);
(<any>error).stack = filtered.join(Harness.IO.newLine());
}
return error;
@ -751,7 +751,16 @@ namespace Harness {
return dirPath;
}
export let directoryName: typeof IO.directoryName = Utils.memoize(directoryNameImpl);
export const resolvePath = (path: string) => directoryName(path);
export function resolvePath(path: string) {
const response = Http.getFileFromServerSync(serverRoot + path + "?resolve=true");
if (response.status === 200) {
return response.responseText;
}
else {
return null;
}
}
export function fileExists(path: string): boolean {
const response = Http.getFileFromServerSync(serverRoot + path);

View File

@ -463,32 +463,39 @@ class ProjectRunner extends RunnerBase {
}
});
it("Baseline of emitted result (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
if (testCase.baselineCheck) {
var lastError: any = undefined;
ts.forEach(compilerResult.outputFiles, outputFile => {
Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
try {
return Harness.IO.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
}
catch (e) {
return undefined;
}
});
try {
Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
try {
return Harness.IO.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
}
catch (e) {
return undefined;
}
});
}
catch (e) {
lastError = e;
}
});
if (lastError) {
throw lastError;
}
}
});
it("SourceMapRecord for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
if (compilerResult.sourceMapData) {
Harness.Baseline.runBaseline("SourceMapRecord for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".sourcemap.txt", () => {
return Harness.SourceMapRecorder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program,
ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName)));
});
}
});
// it("SourceMapRecord for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
// if (compilerResult.sourceMapData) {
// Harness.Baseline.runBaseline("SourceMapRecord for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".sourcemap.txt", () => {
// return Harness.SourceMapRecorder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program,
// ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName)));
// });
// }
// });
// Verify that all the generated .d.ts files compile

View File

@ -40,8 +40,14 @@ let testConfigFile =
Harness.IO.fileExists(mytestconfig) ? Harness.IO.readFile(mytestconfig) :
(Harness.IO.fileExists(testconfig) ? Harness.IO.readFile(testconfig) : "");
type TestConfig = {
tests?: string[];
stackTraceLimit?: number | "full";
light?: boolean;
};
if (testConfigFile !== "") {
const testConfig = JSON.parse(testConfigFile);
const testConfig = <TestConfig>JSON.parse(testConfigFile);
if (testConfig.light) {
Harness.lightMode = true;
}
@ -49,12 +55,12 @@ if (testConfigFile !== "") {
if (testConfig.stackTraceLimit === "full") {
(<any>Error).stackTraceLimit = Infinity;
}
else if ((testConfig.stackTraceLimit | 0) > 0) {
else if ((+testConfig.stackTraceLimit | 0) > 0) {
(<any>Error).stackTraceLimit = testConfig.stackTraceLimit;
}
if (testConfig.test && testConfig.test.length > 0) {
for (const option of testConfig.test) {
if (testConfig.tests && testConfig.tests.length > 0) {
for (const option of testConfig.tests) {
if (!option) {
continue;
}

View File

@ -5,7 +5,7 @@ function* foo() {
}
//// [YieldExpression3_es6.js]
function foo() {
function* foo() {
yield;
yield;
}

View File

@ -5,7 +5,7 @@ function* foo() {
}
//// [YieldExpression4_es6.js]
function foo() {
function* foo() {
yield;
yield;
}

View File

@ -4,6 +4,6 @@ function* foo() {
}
//// [YieldExpression5_es6.js]
function foo() {
function* foo() {
yield* ;
}

View File

@ -4,6 +4,6 @@ function* foo() {
}
//// [YieldExpression6_es6.js]
function foo() {
function* foo() {
yield* foo;
}

View File

@ -4,6 +4,6 @@ function* foo() {
}
//// [YieldExpression7_es6.js]
function foo() {
function* foo() {
yield foo;
}

View File

@ -6,6 +6,6 @@ function* foo() {
//// [YieldExpression8_es6.js]
yield(foo);
function foo() {
function* foo() {
yield (foo);
}

View File

@ -4,6 +4,6 @@ var v = function*() {
}
//// [YieldExpression9_es6.js]
var v = function () {
var v = function* () {
yield (foo);
};

View File

@ -4,6 +4,6 @@ function *g() {
}
//// [YieldStarExpression3_es6.js]
function g() {
function* g() {
yield* ;
}

View File

@ -4,6 +4,6 @@ function *g() {
}
//// [YieldStarExpression4_es6.js]
function g() {
function* g() {
yield* [];
}

View File

@ -102,9 +102,10 @@ var __extends = (this && this.__extends) || function (d, b) {
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var _this = this;
// Arrow function used in with statement
with (window) {
var p = function () { return this; };
var p = function () { return _this; };
}
// Arrow function as argument to super call
var Base = (function () {
@ -130,6 +131,7 @@ var arr; // Incorrect error here (bug 829597)
// Arrow function as enum value
var E;
(function (E) {
var _this = this;
E[E["x"] = function () { return 4; }] = "x";
E[E["y"] = (function () { return _this; }).length] = "y"; // error, can't use this in enum
})(E || (E = {}));
@ -142,9 +144,10 @@ var M;
// Repeat above for module members that are functions? (necessary to redo all of them?)
var M2;
(function (M2) {
var _this = this;
// Arrow function used in with statement
with (window) {
var p = function () { return this; };
var p = function () { return _this; };
}
// Arrow function as argument to super call
var Base = (function () {
@ -170,6 +173,7 @@ var M2;
// Arrow function as enum value
var E;
(function (E) {
var _this = this;
E[E["x"] = function () { return 4; }] = "x";
E[E["y"] = (function () { return _this; }).length] = "y";
})(E || (E = {}));

View File

@ -54,8 +54,9 @@ var RegisteredUser = (function (_super) {
};
RegisteredUser.prototype.g = function () {
function inner() {
var _this = this;
(function () {
_super.sayHello.call(this);
_super.sayHello.call(_this);
});
}
};

View File

@ -7,7 +7,6 @@ export = f;
//// [es6ExportEquals.js]
export function f() { }
export = f;
//// [es6ExportEquals.d.ts]

View File

@ -2,14 +2,14 @@
export = { ["hi"]: "there" };
//// [exportEqualsUmd.js]
(function (factory) {
(function (dependencies, factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports); if (v !== undefined) module.exports = v;
}
else if (typeof define === 'function' && define.amd) {
define(["require", "exports"], factory);
define(dependencies, factory);
}
})(function (require, exports) {
})(["require", "exports"], function (require, exports) {
"use strict";
return (_a = {}, _a["hi"] = "there", _a);
var _a;

View File

@ -11,7 +11,8 @@ function x() {
function x() {
with ({}) {
function f() {
(function () { return this; });
var _this = this;
(function () { return _this; });
}
}
}

View File

@ -5,14 +5,14 @@ run(1);
//// [isolatedModulesPlainFile-UMD.js]
(function (factory) {
(function (dependencies, factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports); if (v !== undefined) module.exports = v;
}
else if (typeof define === 'function' && define.amd) {
define(["require", "exports"], factory);
define(dependencies, factory);
}
})(function (require, exports) {
})(["require", "exports"], function (require, exports) {
"use strict";
run(1);
});

View File

@ -4,14 +4,14 @@
export class Foo {}
//// [modulePrologueUmd.js]
(function (factory) {
(function (dependencies, factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports); if (v !== undefined) module.exports = v;
}
else if (typeof define === 'function' && define.amd) {
define(["require", "exports"], factory);
define(dependencies, factory);
}
})(function (require, exports) {
})(["require", "exports"], function (require, exports) {
"use strict";
var Foo = (function () {
function Foo() {

View File

@ -6,8 +6,9 @@ return this.edit(role)
//// [multiLinePropertyAccessAndArrowFunctionIndent1.js]
var _this = this;
return this.edit(role)
.then(function (role) {
return this.roleService.add(role)
return _this.roleService.add(role)
.then(function (data) { return data.data; });
});

View File

@ -16,6 +16,6 @@ var A = (function () {
}());
A = __decorate([
decorator,
__param(1, decorator),
__metadata('design:paramtypes', [Number, String])
__param(1, decorator),
__metadata("design:paramtypes", [Number, String])
], A);

View File

@ -3,13 +3,13 @@
export var x = 0;
//// [noImplicitUseStrict_system.js]
System.register([], function(exports_1, context_1) {
System.register([], function (exports_1, context_1) {
var __moduleName = context_1 && context_1.id;
var x;
return {
setters:[],
execute: function() {
setters: [],
execute: function () {
exports_1("x", x = 0);
}
}
};
});

View File

@ -3,13 +3,13 @@
export var x = 0;
//// [noImplicitUseStrict_umd.js]
(function (factory) {
(function (dependencies, factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports); if (v !== undefined) module.exports = v;
}
else if (typeof define === 'function' && define.amd) {
define(["require", "exports"], factory);
define(dependencies, factory);
}
})(function (require, exports) {
})(["require", "exports"], function (require, exports) {
exports.x = 0;
});

View File

@ -5,4 +5,5 @@ var v = {
//// [objectLiteralWithSemicolons4.js]
var v = {
a: };
a:
};

View File

@ -58,6 +58,7 @@ var __extends = (this && this.__extends) || function (d, b) {
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
function foo() {
var _this = this;
// super in a non class context
var x = _super.;
var y = function () { return _super.; };
@ -83,20 +84,28 @@ var RegisteredUser = (function (_super) {
}
// super call in a lambda in an inner function in a constructor
function inner2() {
var x = function () { return _super.sayHello.call(this); };
var _this = this;
var x = function () { return _super.sayHello.call(_this); };
}
// super call in a lambda in a function expression in a constructor
(function () { return function () { return _super.; }; })();
(function () {
var _this = this;
return function () { return _super.; };
})();
}
RegisteredUser.prototype.sayHello = function () {
// super call in a method
_super.prototype.sayHello.call(this);
// super call in a lambda in an inner function in a method
function inner() {
var x = function () { return _super.sayHello.call(this); };
var _this = this;
var x = function () { return _super.sayHello.call(_this); };
}
// super call in a lambda in a function expression in a constructor
(function () { return function () { return _super.; }; })();
(function () {
var _this = this;
return function () { return _super.; };
})();
};
RegisteredUser.staticFunction = function () {
var _this = this;

View File

@ -65,6 +65,7 @@ var __extends = (this && this.__extends) || function (d, b) {
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var _this = this;
var obj = {
__proto__: {
method: function () {
@ -87,7 +88,7 @@ var obj = {
_super.method.call(this);
},
p3: function () {
_super.method.call(this);
_super.method.call(_this);
}
};
var A = (function () {

View File

@ -48,6 +48,53 @@ function log(msg: string) {
}
}
let directorySeparator = "/";
function getRootLength(path: string): number {
if (path.charAt(0) === directorySeparator) {
if (path.charAt(1) !== directorySeparator) return 1;
const p1 = path.indexOf("/", 2);
if (p1 < 0) return 2;
const p2 = path.indexOf("/", p1 + 1);
if (p2 < 0) return p1 + 1;
return p2 + 1;
}
if (path.charAt(1) === ":") {
if (path.charAt(2) === directorySeparator) return 3;
return 2;
}
// Per RFC 1738 'file' URI schema has the shape file://<host>/<path>
// if <host> is omitted then it is assumed that host value is 'localhost',
// however slash after the omitted <host> is not removed.
// file:///folder1/file1 - this is a correct URI
// file://folder2/file2 - this is an incorrect URI
if (path.lastIndexOf("file:///", 0) === 0) {
return "file:///".length;
}
const idx = path.indexOf("://");
if (idx !== -1) {
return idx + "://".length;
}
return 0;
}
function getDirectoryPath(path: string): any {
path = switchToForwardSlashes(path);
return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(directorySeparator)));
}
function ensureDirectoriesExist(path: string) {
path = switchToForwardSlashes(path);
if (path.length > getRootLength(path) && !fs.existsSync(path)) {
const parentDirectory = getDirectoryPath(path);
ensureDirectoriesExist(parentDirectory);
if (!fs.existsSync(path)) {
fs.mkdirSync(path);
}
}
}
// Copied from the compiler sources
function dir(path: string, spec?: string, options?: any) {
options = options || <{ recursive?: boolean; }>{};
@ -94,28 +141,16 @@ function deleteFolderRecursive(path: string) {
};
function writeFile(path: string, data: any, opts: { recursive: boolean }) {
try {
fs.writeFileSync(path, data);
} catch (e) {
// assume file was written to a directory that exists, if not, start recursively creating them as necessary
var parts = switchToForwardSlashes(path).split('/');
for (var i = 0; i < parts.length; i++) {
var subDir = parts.slice(0, i).join('/');
if (!fs.existsSync(subDir)) {
fs.mkdir(subDir);
}
}
fs.writeFileSync(path, data);
}
ensureDirectoriesExist(getDirectoryPath(path));
fs.writeFileSync(path, data);
}
/// Request Handling ///
function handleResolutionRequest(filePath: string, res: http.ServerResponse) {
var resolvedPath = path.resolve(filePath, '');
resolvedPath = resolvedPath.substring(resolvedPath.indexOf('tests'));
var resolvedPath = path.resolve(filePath);
resolvedPath = switchToForwardSlashes(resolvedPath);
send('success', res, resolvedPath);
send('success', res, resolvedPath, 'text/javascript');
return;
}
@ -174,6 +209,7 @@ function getRequestOperation(req: http.ServerRequest, filename: string) {
else return RequestType.GetDir;
}
else {
var queryData: any = url.parse(req.url, true).query;
if (req.method === 'GET' && queryData.resolve !== undefined) return RequestType.ResolveFile
// mocha uses ?grep=<regexp> query string as equivalent to the --grep command line option used to filter tests
@ -223,7 +259,7 @@ function handleRequestOperation(req: http.ServerRequest, res: http.ServerRespons
send('success', res, null);
break;
case RequestType.WriteDir:
fs.mkdirSync(reqPath);
ensureDirectoriesExist(reqPath);
send('success', res, null);
break;
case RequestType.DeleteFile: