mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'transforms' into sourceMapUpdatesForClasses
This commit is contained in:
@@ -7,6 +7,7 @@ tests/cases/perf/*
|
||||
test-args.txt
|
||||
~*.docx
|
||||
tests/baselines/local/*
|
||||
tests/baselines/local.old/*
|
||||
tests/services/baselines/local/*
|
||||
tests/baselines/prototyping/local/*
|
||||
tests/baselines/rwc/*
|
||||
|
||||
+48
-34
@@ -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,11 +306,11 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
|
||||
}
|
||||
|
||||
if (opts.stripInternal) {
|
||||
options += " --stripInternal"
|
||||
options += " --stripInternal";
|
||||
}
|
||||
|
||||
if (useBuiltCompiler && Boolean(process.env.USE_TRANSFORMS)) {
|
||||
console.warn("\u001b[93mwarning: Found 'USE_TRANSFORMS' environment variable. Experimental transforms will be enabled by default.\u001b[0m");
|
||||
if (useBuiltCompiler && !environmentVariableIsDisabled("USE_TRANSFORMS")) {
|
||||
console.warn("\u001b[93mwarning: 'USE_TRANSFORMS' environment variable is not set to 'false'. Experimental transforms will be enabled by default.\u001b[0m");
|
||||
}
|
||||
|
||||
var cmd = host + " " + compilerPath + " " + options + " ";
|
||||
@@ -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/";
|
||||
@@ -717,7 +717,7 @@ function runTestsAndWriteOutput(file) {
|
||||
}
|
||||
|
||||
var args = [];
|
||||
args.push("-R", "TAP");
|
||||
args.push("-R", "tap");
|
||||
args.push("--no-colors");
|
||||
args.push("-t", testTimeout);
|
||||
if (tests) {
|
||||
@@ -826,14 +826,17 @@ function runTestsAndWriteOutput(file) {
|
||||
});
|
||||
}
|
||||
|
||||
function runConsoleTests(defaultReporter, defaultSubsets) {
|
||||
cleanTestDirs();
|
||||
function runConsoleTests(defaultReporter, defaultSubsets, dirty) {
|
||||
if (!dirty) {
|
||||
cleanTestDirs();
|
||||
}
|
||||
|
||||
var debug = process.env.debug || process.env.d;
|
||||
tests = process.env.test || process.env.tests || process.env.t;
|
||||
var light = process.env.light || false;
|
||||
var stackTraceLimit = process.env.stackTraceLimit || 1;
|
||||
var testConfigFile = 'test.config';
|
||||
if(fs.existsSync(testConfigFile)) {
|
||||
if (fs.existsSync(testConfigFile)) {
|
||||
fs.unlinkSync(testConfigFile);
|
||||
}
|
||||
|
||||
@@ -845,7 +848,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 +856,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;
|
||||
@@ -866,7 +869,7 @@ function runConsoleTests(defaultReporter, defaultSubsets) {
|
||||
console.log(cmd);
|
||||
exec(cmd, function () {
|
||||
deleteTemporaryProjectOutput();
|
||||
if (i === 0) {
|
||||
if (i === 0 && !dirty) {
|
||||
var lint = jake.Task['lint'];
|
||||
lint.addListener('complete', function () {
|
||||
complete();
|
||||
@@ -894,6 +897,9 @@ task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
|
||||
task("runtests-file", ["build-rules", "tests", builtLocalDirectory], function () {
|
||||
runTestsAndWriteOutput("tests/baselines/local/testresults.tap");
|
||||
}, { async: true });
|
||||
task("runtests-dirty", ["build-rules", "tests", builtLocalDirectory], function () {
|
||||
runConsoleTests("mocha-fivemat-progress-reporter", [], /*dirty*/ true);
|
||||
}, { async: true });
|
||||
|
||||
desc("Generates code coverage data via instanbul");
|
||||
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
|
||||
@@ -903,20 +909,20 @@ 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");
|
||||
task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() {
|
||||
var cmd = 'browserify built/local/run.js -o built/local/bundle.js';
|
||||
var cmd = 'browserify built/local/run.js -t ./scripts/browserify-optional -o built/local/bundle.js';
|
||||
exec(cmd);
|
||||
}, {async: true});
|
||||
|
||||
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 +936,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 +971,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 +1054,7 @@ task("update-sublime", ["local", serverFile], function() {
|
||||
});
|
||||
|
||||
var tslintRuleDir = "scripts/tslint";
|
||||
var tslintRules = ([
|
||||
var tslintRules = [
|
||||
"nextLineRule",
|
||||
"noNullRule",
|
||||
"preferConstRule",
|
||||
@@ -1056,7 +1062,7 @@ var tslintRules = ([
|
||||
"typeOperatorSpacingRule",
|
||||
"noInOperatorRule",
|
||||
"noIncrementDecrementRule"
|
||||
]);
|
||||
];
|
||||
var tslintRulesFiles = tslintRules.map(function(p) {
|
||||
return path.join(tslintRuleDir, p + ".ts");
|
||||
});
|
||||
@@ -1081,7 +1087,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();
|
||||
}
|
||||
|
||||
@@ -1258,4 +1264,12 @@ ProgressBar.prototype = {
|
||||
this._lastProgress = progress;
|
||||
this.visible = true;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function environmentVariableIsEnabled(name) {
|
||||
return /^(y(es)?|t(rue)?|on|enabled?|1|\+)$/.test(process.env[name]);
|
||||
}
|
||||
|
||||
function environmentVariableIsDisabled(name) {
|
||||
return /^(no?|f(alse)?|off|disabled?|0|-)$/.test(process.env[name]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// simple script to optionally elide source-map-support (or other optional modules) when running browserify.
|
||||
|
||||
var stream = require("stream"),
|
||||
Transform = stream.Transform,
|
||||
resolve = require("browser-resolve");
|
||||
|
||||
var requirePattern = /require\s*\(\s*['"](source-map-support)['"]\s*\)/;
|
||||
module.exports = function (file) {
|
||||
return new Transform({
|
||||
transform: function (data, encoding, cb) {
|
||||
var text = encoding === "buffer" ? data.toString("utf8") : data;
|
||||
this.push(new Buffer(text.replace(requirePattern, function (originalText, moduleName) {
|
||||
try {
|
||||
resolve.sync(moduleName, { filename: file });
|
||||
return originalText;
|
||||
}
|
||||
catch (e) {
|
||||
return "(function () { throw new Error(\"module '" + moduleName + "' not found.\"); })()";
|
||||
}
|
||||
}), "utf8"));
|
||||
cb();
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -1910,6 +1910,17 @@ namespace ts {
|
||||
// This is so that they can flow through PropertyName transforms unaffected.
|
||||
// Instead, we mark the container as ES6, so that it can properly handle the transform.
|
||||
transformFlags = TransformFlags.ContainsComputedPropertyName;
|
||||
if (subtreeFlags & TransformFlags.ContainsLexicalThis) {
|
||||
// A computed method name like `[this.getName()](x: string) { ... }` needs to
|
||||
// distinguish itself from the normal case of a method body containing `this`:
|
||||
// `this` inside a method doesn't need to be rewritten (the method provides `this`),
|
||||
// whereas `this` inside a computed name *might* need to be rewritten if the class/object
|
||||
// is inside an arrow function:
|
||||
// `_this = this; () => class K { [_this.getName()]() { ... } }`
|
||||
// To make this distinction, use ContainsLexicalThisInComputedPropertyName
|
||||
// instead of ContainsLexicalThis for computed property names
|
||||
transformFlags |= TransformFlags.ContainsLexicalThisInComputedPropertyName;
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.SpreadElementExpression:
|
||||
@@ -1945,6 +1956,11 @@ namespace ts {
|
||||
// is an ES6 node.
|
||||
transformFlags = TransformFlags.AssertES6;
|
||||
}
|
||||
if (subtreeFlags & TransformFlags.ContainsLexicalThisInComputedPropertyName) {
|
||||
// A computed property name containing `this` might need to be rewritten,
|
||||
// so propagate the ContainsLexicalThis flag upward.
|
||||
transformFlags |= TransformFlags.ContainsLexicalThis;
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.CallExpression:
|
||||
@@ -2256,6 +2272,11 @@ namespace ts {
|
||||
|| hasModifier(node, ModifierFlags.Export)) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
if (subtreeFlags & TransformFlags.ContainsLexicalThisInComputedPropertyName) {
|
||||
// A computed property name containing `this` might need to be rewritten,
|
||||
// so propagate the ContainsLexicalThis flag upward.
|
||||
transformFlags |= TransformFlags.ContainsLexicalThis;
|
||||
}
|
||||
|
||||
return updateTransformFlags(node, subtreeFlags, transformFlags, TransformFlags.ClassExcludes);
|
||||
}
|
||||
@@ -2272,6 +2293,11 @@ namespace ts {
|
||||
| TransformFlags.ContainsDecorators)) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
if (subtreeFlags & TransformFlags.ContainsLexicalThisInComputedPropertyName) {
|
||||
// A computed property name containing `this` might need to be rewritten,
|
||||
// so propagate the ContainsLexicalThis flag upward.
|
||||
transformFlags |= TransformFlags.ContainsLexicalThis;
|
||||
}
|
||||
|
||||
return updateTransformFlags(node, subtreeFlags, transformFlags, TransformFlags.ClassExcludes);
|
||||
}
|
||||
|
||||
+90
-39
@@ -1118,7 +1118,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Resolves a qualified name and any involved aliases
|
||||
function resolveEntityName(name: EntityName | Expression, meaning: SymbolFlags, ignoreErrors?: boolean): Symbol {
|
||||
function resolveEntityName(name: EntityName | Expression, meaning: SymbolFlags, ignoreErrors?: boolean, location?: Node): Symbol {
|
||||
if (nodeIsMissing(name)) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -1127,7 +1127,7 @@ namespace ts {
|
||||
if (name.kind === SyntaxKind.Identifier) {
|
||||
const message = meaning === SymbolFlags.Namespace ? Diagnostics.Cannot_find_namespace_0 : Diagnostics.Cannot_find_name_0;
|
||||
|
||||
symbol = resolveName(name, (<Identifier>name).text, meaning, ignoreErrors ? undefined : message, <Identifier>name);
|
||||
symbol = resolveName(location || name, (<Identifier>name).text, meaning, ignoreErrors ? undefined : message, <Identifier>name);
|
||||
if (!symbol) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -1136,7 +1136,7 @@ namespace ts {
|
||||
const left = name.kind === SyntaxKind.QualifiedName ? (<QualifiedName>name).left : (<PropertyAccessExpression>name).expression;
|
||||
const right = name.kind === SyntaxKind.QualifiedName ? (<QualifiedName>name).right : (<PropertyAccessExpression>name).name;
|
||||
|
||||
const namespace = resolveEntityName(left, SymbolFlags.Namespace, ignoreErrors);
|
||||
const namespace = resolveEntityName(left, SymbolFlags.Namespace, ignoreErrors, location);
|
||||
if (!namespace || namespace === unknownSymbol || nodeIsMissing(right)) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -16042,7 +16042,14 @@ namespace ts {
|
||||
// Emitter support
|
||||
|
||||
function isArgumentsLocalBinding(node: Identifier): boolean {
|
||||
return getReferencedValueSymbol(node) === argumentsSymbol;
|
||||
if (!isGeneratedIdentifier(node)) {
|
||||
node = getSourceTreeNodeOfType(node, isIdentifier);
|
||||
if (node) {
|
||||
return getReferencedValueSymbol(node) === argumentsSymbol;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean {
|
||||
@@ -16077,37 +16084,49 @@ namespace ts {
|
||||
// When resolved as an expression identifier, if the given node references an exported entity, return the declaration
|
||||
// node of the exported entity's container. Otherwise, return undefined.
|
||||
function getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration {
|
||||
let symbol = getReferencedValueSymbol(node);
|
||||
if (symbol) {
|
||||
if (symbol.flags & SymbolFlags.ExportValue) {
|
||||
// If we reference an exported entity within the same module declaration, then whether
|
||||
// we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the
|
||||
// kinds that we do NOT prefix.
|
||||
const exportSymbol = getMergedSymbol(symbol.exportSymbol);
|
||||
if (exportSymbol.flags & SymbolFlags.ExportHasLocal && !prefixLocals) {
|
||||
return undefined;
|
||||
node = getSourceTreeNodeOfType(node, isIdentifier);
|
||||
if (node) {
|
||||
let symbol = getReferencedValueSymbol(node);
|
||||
if (symbol) {
|
||||
if (symbol.flags & SymbolFlags.ExportValue) {
|
||||
// If we reference an exported entity within the same module declaration, then whether
|
||||
// we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the
|
||||
// kinds that we do NOT prefix.
|
||||
const exportSymbol = getMergedSymbol(symbol.exportSymbol);
|
||||
if (exportSymbol.flags & SymbolFlags.ExportHasLocal && !prefixLocals) {
|
||||
return undefined;
|
||||
}
|
||||
symbol = exportSymbol;
|
||||
}
|
||||
symbol = exportSymbol;
|
||||
}
|
||||
const parentSymbol = getParentOfSymbol(symbol);
|
||||
if (parentSymbol) {
|
||||
if (parentSymbol.flags & SymbolFlags.ValueModule && parentSymbol.valueDeclaration.kind === SyntaxKind.SourceFile) {
|
||||
return <SourceFile>parentSymbol.valueDeclaration;
|
||||
}
|
||||
for (let n = node.parent; n; n = n.parent) {
|
||||
if ((n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.EnumDeclaration) && getSymbolOfNode(n) === parentSymbol) {
|
||||
return <ModuleDeclaration | EnumDeclaration>n;
|
||||
const parentSymbol = getParentOfSymbol(symbol);
|
||||
if (parentSymbol) {
|
||||
if (parentSymbol.flags & SymbolFlags.ValueModule && parentSymbol.valueDeclaration.kind === SyntaxKind.SourceFile) {
|
||||
return <SourceFile>parentSymbol.valueDeclaration;
|
||||
}
|
||||
for (let n = node.parent; n; n = n.parent) {
|
||||
if ((n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.EnumDeclaration) && getSymbolOfNode(n) === parentSymbol) {
|
||||
return <ModuleDeclaration | EnumDeclaration>n;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// When resolved as an expression identifier, if the given node references an import, return the declaration of
|
||||
// that import. Otherwise, return undefined.
|
||||
function getReferencedImportDeclaration(node: Identifier): Declaration {
|
||||
const symbol = getReferencedValueSymbol(node);
|
||||
return symbol && symbol.flags & SymbolFlags.Alias ? getDeclarationOfAliasSymbol(symbol) : undefined;
|
||||
node = getSourceTreeNodeOfType(node, isIdentifier);
|
||||
if (node) {
|
||||
const symbol = getReferencedValueSymbol(node);
|
||||
if (symbol && symbol.flags & SymbolFlags.Alias) {
|
||||
return getDeclarationOfAliasSymbol(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isSymbolOfDeclarationWithCollidingName(symbol: Symbol): boolean {
|
||||
@@ -16157,35 +16176,57 @@ namespace ts {
|
||||
// a name that either hides an existing name or might hide it when compiled downlevel,
|
||||
// return the declaration of that entity. Otherwise, return undefined.
|
||||
function getReferencedDeclarationWithCollidingName(node: Identifier): Declaration {
|
||||
const symbol = getReferencedValueSymbol(node);
|
||||
return symbol && isSymbolOfDeclarationWithCollidingName(symbol) ? symbol.valueDeclaration : undefined;
|
||||
if (!isGeneratedIdentifier(node)) {
|
||||
node = getSourceTreeNodeOfType(node, isIdentifier);
|
||||
if (node) {
|
||||
const symbol = getReferencedValueSymbol(node);
|
||||
if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) {
|
||||
return symbol.valueDeclaration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Return true if the given node is a declaration of a nested block scoped entity with a name that either hides an
|
||||
// existing name or might hide a name when compiled downlevel
|
||||
function isDeclarationWithCollidingName(node: Declaration): boolean {
|
||||
return isSymbolOfDeclarationWithCollidingName(getSymbolOfNode(node));
|
||||
node = getSourceTreeNodeOfType(node, isDeclaration);
|
||||
if (node) {
|
||||
const symbol = getSymbolOfNode(node);
|
||||
if (symbol) {
|
||||
return isSymbolOfDeclarationWithCollidingName(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isValueAliasDeclaration(node: Node): boolean {
|
||||
node = getSourceTreeNode(node);
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ImportClause:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
return isAliasResolvedToValue(getSymbolOfNode(node));
|
||||
return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol);
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
const exportClause = (<ExportDeclaration>node).exportClause;
|
||||
return exportClause && forEach(exportClause.elements, isValueAliasDeclaration);
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return (<ExportAssignment>node).expression && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier ? isAliasResolvedToValue(getSymbolOfNode(node)) : true;
|
||||
return (<ExportAssignment>node).expression
|
||||
&& (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier
|
||||
? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol)
|
||||
: true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean {
|
||||
if (node.parent.kind !== SyntaxKind.SourceFile || !isInternalModuleImportEqualsDeclaration(node)) {
|
||||
node = getSourceTreeNodeOfType(node, isImportEqualsDeclaration);
|
||||
if (node === undefined || node.parent.kind !== SyntaxKind.SourceFile || !isInternalModuleImportEqualsDeclaration(node)) {
|
||||
// parent is not source file or it is not reference to internal module
|
||||
return false;
|
||||
}
|
||||
@@ -16212,9 +16253,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean {
|
||||
node = getSourceTreeNode(node);
|
||||
if (isAliasSymbolDeclaration(node)) {
|
||||
const symbol = getSymbolOfNode(node);
|
||||
if (getSymbolLinks(symbol).referenced) {
|
||||
if (symbol && getSymbolLinks(symbol).referenced) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -16247,7 +16289,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getNodeCheckFlags(node: Node): NodeCheckFlags {
|
||||
return getNodeLinks(node).flags;
|
||||
node = getSourceTreeNode(node);
|
||||
return node ? getNodeLinks(node).flags : undefined;
|
||||
}
|
||||
|
||||
function getEnumMemberValue(node: EnumMember): number {
|
||||
@@ -16275,16 +16318,16 @@ namespace ts {
|
||||
return type.flags & TypeFlags.ObjectType && getSignaturesOfType(type, SignatureKind.Call).length > 0;
|
||||
}
|
||||
|
||||
function getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind {
|
||||
function getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind {
|
||||
// Resolve the symbol as a value to ensure the type can be reached at runtime during emit.
|
||||
const valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true);
|
||||
const valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true, location);
|
||||
const constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined;
|
||||
if (constructorType && isConstructorType(constructorType)) {
|
||||
return TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
|
||||
}
|
||||
|
||||
// Resolve the symbol as a type so that we can provide a more useful hint for the type serializer.
|
||||
const typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true);
|
||||
const typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true, location);
|
||||
// We might not be able to resolve type symbol so use unknown type in that case (eg error case)
|
||||
if (!typeSymbol) {
|
||||
return TypeReferenceSerializationKind.ObjectType;
|
||||
@@ -16363,9 +16406,17 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getReferencedValueDeclaration(reference: Identifier): Declaration {
|
||||
Debug.assert(!nodeIsSynthesized(reference));
|
||||
const symbol = getReferencedValueSymbol(reference);
|
||||
return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
|
||||
if (!isGeneratedIdentifier(reference)) {
|
||||
reference = getSourceTreeNodeOfType(reference, isIdentifier);
|
||||
if (reference) {
|
||||
const symbol = getReferencedValueSymbol(reference);
|
||||
if (symbol) {
|
||||
return getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function createResolver(): EmitResolver {
|
||||
|
||||
@@ -333,11 +333,10 @@ namespace ts {
|
||||
description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output
|
||||
},
|
||||
{
|
||||
// this option will be removed when this is merged with master and exists solely
|
||||
// to enable the tree transforming emitter side-by-side with the existing emitter.
|
||||
name: "experimentalTransforms",
|
||||
name: "useLegacyEmitter",
|
||||
type: "boolean",
|
||||
experimental: true
|
||||
experimental: true,
|
||||
description: Diagnostics.Use_the_legacy_emitter_instead_of_the_transforming_emitter
|
||||
}
|
||||
];
|
||||
|
||||
@@ -475,7 +474,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string) {
|
||||
const key = (value || "").trim().toLowerCase();
|
||||
const key = (value || "").toLowerCase();
|
||||
const map = opt.type;
|
||||
if (hasProperty(map, key)) {
|
||||
return map[key];
|
||||
@@ -486,7 +485,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseListTypeOption(opt: CommandLineOptionOfListType, value: string): (string | number)[] {
|
||||
const values = (value || "").trim().split(",");
|
||||
const values = (value || "").split(",");
|
||||
switch (opt.element.type) {
|
||||
case "number":
|
||||
return ts.map(values, parseInt);
|
||||
|
||||
@@ -1105,11 +1105,11 @@ namespace ts {
|
||||
return currentAssertionLevel;
|
||||
}
|
||||
|
||||
const developmentMode = sys && /^development$/i.test(sys.getEnvironmentVariable("NODE_ENV"));
|
||||
if (developmentMode === undefined) {
|
||||
if (sys === undefined) {
|
||||
return AssertionLevel.None;
|
||||
}
|
||||
|
||||
const developmentMode = /^development$/i.test(getEnvironmentVariable("NODE_ENV"));
|
||||
currentAssertionLevel = developmentMode
|
||||
? AssertionLevel.Normal
|
||||
: AssertionLevel.None;
|
||||
|
||||
@@ -2604,6 +2604,10 @@
|
||||
"category": "Message",
|
||||
"code": 6112
|
||||
},
|
||||
"Use the legacy emitter instead of the transforming emitter.": {
|
||||
"category": "Message",
|
||||
"code": 6113
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
|
||||
+19
-12
@@ -2240,41 +2240,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
emit(node.right);
|
||||
}
|
||||
|
||||
function emitQualifiedNameAsExpression(node: QualifiedName, useFallback: boolean) {
|
||||
function emitQualifiedNameAsExpression(node: QualifiedName, useFallback: boolean, location?: Node) {
|
||||
if (node.left.kind === SyntaxKind.Identifier) {
|
||||
emitEntityNameAsExpression(node.left, useFallback);
|
||||
emitEntityNameAsExpression(node.left, useFallback, location);
|
||||
}
|
||||
else if (useFallback) {
|
||||
const temp = createAndRecordTempVariable(TempFlags.Auto);
|
||||
write("(");
|
||||
emitNodeWithoutSourceMap(temp);
|
||||
write(" = ");
|
||||
emitEntityNameAsExpression(node.left, /*useFallback*/ true);
|
||||
emitEntityNameAsExpression(node.left, /*useFallback*/ true, location);
|
||||
write(") && ");
|
||||
emitNodeWithoutSourceMap(temp);
|
||||
}
|
||||
else {
|
||||
emitEntityNameAsExpression(node.left, /*useFallback*/ false);
|
||||
emitEntityNameAsExpression(node.left, /*useFallback*/ false, location);
|
||||
}
|
||||
|
||||
write(".");
|
||||
emit(node.right);
|
||||
}
|
||||
|
||||
function emitEntityNameAsExpression(node: EntityName | Expression, useFallback: boolean) {
|
||||
function emitEntityNameAsExpression(node: EntityName | Expression, useFallback: boolean, location?: Node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
let name = <Identifier>node;
|
||||
if (location) {
|
||||
// to resolve the expression to the correct container, create a shallow
|
||||
// clone of `node` with a new parent.
|
||||
name = clone(name);
|
||||
name.parent = location;
|
||||
}
|
||||
|
||||
if (useFallback) {
|
||||
write("typeof ");
|
||||
emitExpressionIdentifier(<Identifier>node);
|
||||
emitExpressionIdentifier(name);
|
||||
write(" !== 'undefined' && ");
|
||||
}
|
||||
|
||||
emitExpressionIdentifier(<Identifier>node);
|
||||
emitExpressionIdentifier(name);
|
||||
break;
|
||||
|
||||
case SyntaxKind.QualifiedName:
|
||||
emitQualifiedNameAsExpression(<QualifiedName>node, useFallback);
|
||||
emitQualifiedNameAsExpression(<QualifiedName>node, useFallback, location);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -5943,22 +5951,21 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
|
||||
// Clone the type name and parent it to a location outside of the current declaration.
|
||||
const typeName = cloneEntityName(node.typeName, location);
|
||||
const result = resolver.getTypeReferenceSerializationKind(typeName);
|
||||
const result = resolver.getTypeReferenceSerializationKind(node.typeName, location);
|
||||
switch (result) {
|
||||
case TypeReferenceSerializationKind.Unknown:
|
||||
let temp = createAndRecordTempVariable(TempFlags.Auto);
|
||||
write("(typeof (");
|
||||
emitNodeWithoutSourceMap(temp);
|
||||
write(" = ");
|
||||
emitEntityNameAsExpression(typeName, /*useFallback*/ true);
|
||||
emitEntityNameAsExpression(node.typeName, /*useFallback*/ true, location);
|
||||
write(") === 'function' && ");
|
||||
emitNodeWithoutSourceMap(temp);
|
||||
write(") || Object");
|
||||
break;
|
||||
|
||||
case TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
|
||||
emitEntityNameAsExpression(typeName, /*useFallback*/ false);
|
||||
emitEntityNameAsExpression(node.typeName, /*useFallback*/ false, location);
|
||||
break;
|
||||
|
||||
case TypeReferenceSerializationKind.VoidType:
|
||||
|
||||
+89
-7
@@ -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 {
|
||||
@@ -1252,7 +1252,18 @@ namespace ts {
|
||||
return (node.expression as StringLiteral).text === "use strict";
|
||||
}
|
||||
|
||||
/**
|
||||
* Add any necessary prologue-directives into target statement-array.
|
||||
* The function needs to be called during each transformation step.
|
||||
* This function needs to be called whenever we transform the statement
|
||||
* list of a source file, namespace, or function-like body.
|
||||
*
|
||||
* @param target: result statements array
|
||||
* @param source: origin statements array
|
||||
* @param ensureUseStrict: boolean determining whether the function need to add prologue-directives
|
||||
*/
|
||||
export function addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean): number {
|
||||
Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array");
|
||||
let foundUseStrict = false;
|
||||
for (let i = 0; i < source.length; i++) {
|
||||
if (isPrologueDirective(source[i])) {
|
||||
@@ -1707,4 +1718,75 @@ namespace ts {
|
||||
nodes.hasTrailingComma = hasTrailingComma;
|
||||
return nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of that target module from an import or export declaration
|
||||
*/
|
||||
export function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile): Identifier {
|
||||
const namespaceDeclaration = getNamespaceDeclarationNode(node);
|
||||
if (namespaceDeclaration && !isDefaultImport(node)) {
|
||||
return createIdentifier(getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name));
|
||||
}
|
||||
if (node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).importClause) {
|
||||
return getGeneratedNameForNode(node);
|
||||
}
|
||||
if (node.kind === SyntaxKind.ExportDeclaration && (<ExportDeclaration>node).moduleSpecifier) {
|
||||
return getGeneratedNameForNode(node);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of a target module from an import/export declaration as should be written in the emitted output.
|
||||
* The emitted output name can be different from the input if:
|
||||
* 1. The module has a /// <amd-module name="<new name>" />
|
||||
* 2. --out or --outFile is used, making the name relative to the rootDir
|
||||
* 3- The containing SourceFile has an entry in renamedDependencies for the import as requested by some module loaders (e.g. System).
|
||||
* Otherwise, a new StringLiteral node representing the module name will be returned.
|
||||
*/
|
||||
export function getExternalModuleNameLiteral(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, compilerOptions: CompilerOptions) {
|
||||
const moduleName = getExternalModuleName(importNode);
|
||||
if (moduleName.kind === SyntaxKind.StringLiteral) {
|
||||
return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions)
|
||||
|| tryRenameExternalModule(<StringLiteral>moduleName, sourceFile)
|
||||
|| getSynthesizedClone(<StringLiteral>moduleName);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Some bundlers (SystemJS builder) sometimes want to rename dependencies.
|
||||
* Here we check if alternative name was provided for a given moduleName and return it if possible.
|
||||
*/
|
||||
function tryRenameExternalModule(moduleName: LiteralExpression, sourceFile: SourceFile) {
|
||||
if (sourceFile.renamedDependencies && hasProperty(sourceFile.renamedDependencies, moduleName.text)) {
|
||||
return createLiteral(sourceFile.renamedDependencies[moduleName.text]);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of a module as should be written in the emitted output.
|
||||
* The emitted output name can be different from the input if:
|
||||
* 1. The module has a /// <amd-module name="<new name>" />
|
||||
* 2. --out or --outFile is used, making the name relative to the rootDir
|
||||
* Otherwise, a new StringLiteral node representing the module name will be returned.
|
||||
*/
|
||||
export function tryGetModuleNameFromFile(file: SourceFile, host: EmitHost, options: CompilerOptions): StringLiteral {
|
||||
if (!file) {
|
||||
return undefined;
|
||||
}
|
||||
if (file.moduleName) {
|
||||
return createLiteral(file.moduleName);
|
||||
}
|
||||
if (!isDeclarationFile(file) && (options.out || options.outFile)) {
|
||||
return createLiteral(getExternalModuleNameFromPath(host, file.fileName));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function tryGetModuleNameFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration, host: EmitHost, resolver: EmitResolver, compilerOptions: CompilerOptions) {
|
||||
return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions);
|
||||
}
|
||||
}
|
||||
@@ -1642,8 +1642,10 @@ const _super = (function (geti, seti) {
|
||||
function emitImportDeclaration(node: ImportDeclaration) {
|
||||
emitModifiers(node, node.modifiers);
|
||||
write("import ");
|
||||
emit(node.importClause);
|
||||
write(" from ");
|
||||
if (node.importClause) {
|
||||
emit(node.importClause);
|
||||
write(" from ");
|
||||
}
|
||||
emitExpression(node.moduleSpecifier);
|
||||
write(";");
|
||||
}
|
||||
@@ -2605,8 +2607,10 @@ const _super = (function (geti, seti) {
|
||||
function getSourceNodeForGeneratedName(name: Identifier) {
|
||||
let node: Node = name;
|
||||
while (node.original !== undefined) {
|
||||
const nodeId = node.id;
|
||||
node = node.original;
|
||||
if (isIdentifier(node) && node.autoGenerateKind === GeneratedIdentifierKind.Node) {
|
||||
// If "node" is not the exact clone of "original" identifier, use "original" identifier to generate the name
|
||||
if (isIdentifier(node) && node.autoGenerateKind === GeneratedIdentifierKind.Node && node.id !== nodeId) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -644,7 +644,8 @@ namespace ts {
|
||||
fileExists: fileName => sys.fileExists(fileName),
|
||||
readFile: fileName => sys.readFile(fileName),
|
||||
trace: (s: string) => sys.write(s + newLine),
|
||||
directoryExists: directoryName => sys.directoryExists(directoryName)
|
||||
directoryExists: directoryName => sys.directoryExists(directoryName),
|
||||
getEnvironmentVariable: name => getEnvironmentVariable(name, /*host*/ undefined)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -995,11 +996,12 @@ namespace ts {
|
||||
const start = new Date().getTime();
|
||||
|
||||
// TODO(rbuckton): remove USE_TRANSFORMS condition when we switch to transforms permanently.
|
||||
if (/^(y(es)?|t(rue|ransforms?)?|1|\+)$/i.test(sys.getEnvironmentVariable("USE_TRANSFORMS"))) {
|
||||
options.experimentalTransforms = true;
|
||||
let useLegacyEmitter = options.useLegacyEmitter;
|
||||
if (/^(no?|f(alse)?|0|-)$/i.test(getEnvironmentVariable("USE_TRANSFORMS", host))) {
|
||||
useLegacyEmitter = true;
|
||||
}
|
||||
|
||||
const fileEmitter = options.experimentalTransforms ? printFiles : emitFiles;
|
||||
const fileEmitter = useLegacyEmitter ? emitFiles : printFiles;
|
||||
const emitResult = fileEmitter(
|
||||
emitResolver,
|
||||
getEmitHost(writeFileCallback),
|
||||
|
||||
+2
-3
@@ -74,6 +74,7 @@ namespace ts {
|
||||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
|
||||
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
|
||||
getEnvironmentVariable?(name: string): string;
|
||||
};
|
||||
|
||||
export var sys: System = (function () {
|
||||
@@ -632,9 +633,7 @@ namespace ts {
|
||||
createDirectory: ChakraHost.createDirectory,
|
||||
getExecutingFilePath: () => ChakraHost.executingFile,
|
||||
getCurrentDirectory: () => ChakraHost.currentDirectory,
|
||||
getEnvironmentVariable(name: string) {
|
||||
return "";
|
||||
},
|
||||
getEnvironmentVariable: ChakraHost.getEnvironmentVariable || ((name: string) => ""),
|
||||
readDirectory: ChakraHost.readDirectory,
|
||||
exit: ChakraHost.quit,
|
||||
};
|
||||
|
||||
@@ -68,6 +68,7 @@ namespace ts {
|
||||
const context: TransformationContext = {
|
||||
getCompilerOptions: () => host.getCompilerOptions(),
|
||||
getEmitResolver: () => resolver,
|
||||
getEmitHost: () => host,
|
||||
getNodeEmitFlags,
|
||||
setNodeEmitFlags,
|
||||
hoistVariableDeclaration,
|
||||
|
||||
@@ -17,10 +17,16 @@ namespace ts {
|
||||
node: BinaryExpression,
|
||||
needsValue: boolean,
|
||||
recordTempVariable: (node: Identifier) => void,
|
||||
visitor?: (node: Node) => VisitResult<Node>) {
|
||||
visitor?: (node: Node) => VisitResult<Node>): Expression {
|
||||
|
||||
if (isEmptyObjectLiteralOrArrayLiteral(node.left)) {
|
||||
return node.right;
|
||||
const right = node.right;
|
||||
if (isDestructuringAssignment(right)) {
|
||||
return flattenDestructuringAssignment(context, right, needsValue, recordTempVariable, visitor);
|
||||
}
|
||||
else {
|
||||
return node.right;
|
||||
}
|
||||
}
|
||||
|
||||
let location: TextRange = node;
|
||||
@@ -401,4 +407,4 @@ namespace ts {
|
||||
return emitTempVariableAssignment(value, location);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,7 +467,7 @@ namespace ts {
|
||||
if (isGeneratedIdentifier(node)) {
|
||||
return node;
|
||||
}
|
||||
if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(<Identifier>getOriginalNode(node))) {
|
||||
if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) {
|
||||
return node;
|
||||
}
|
||||
return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = createUniqueName("arguments"));
|
||||
@@ -549,7 +549,7 @@ namespace ts {
|
||||
/*modifiers*/ undefined,
|
||||
createVariableDeclarationList([
|
||||
createVariableDeclaration(
|
||||
getDeclarationName(node),
|
||||
getDeclarationName(node, /*allowComments*/ true),
|
||||
transformClassLikeDeclarationToExpression(node)
|
||||
)
|
||||
]),
|
||||
@@ -739,7 +739,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) {
|
||||
@@ -928,7 +935,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1208,7 +1215,15 @@ namespace ts {
|
||||
let statementsLocation: TextRange;
|
||||
|
||||
const statements: Statement[] = [];
|
||||
const body = node.body;
|
||||
let statementOffset: number;
|
||||
|
||||
startLexicalEnvironment();
|
||||
if (isBlock(body)) {
|
||||
// ensureUseStrict is false because no new prologue-directive should be added.
|
||||
// addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array
|
||||
statementOffset = addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false);
|
||||
}
|
||||
addCaptureThisForNodeIfNeeded(statements, node);
|
||||
addDefaultValueAssignmentsIfNeeded(statements, node);
|
||||
addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false);
|
||||
@@ -1218,10 +1233,9 @@ namespace ts {
|
||||
multiLine = true;
|
||||
}
|
||||
|
||||
const body = node.body;
|
||||
if (isBlock(body)) {
|
||||
statementsLocation = body.statements;
|
||||
addRange(statements, visitNodes(body.statements, visitor, isStatement));
|
||||
addRange(statements, visitNodes(body.statements, visitor, isStatement, statementOffset));
|
||||
|
||||
// If the original body was a multi-line block, this must be a multi-line block.
|
||||
if (!multiLine && body.multiLine) {
|
||||
@@ -1423,10 +1437,7 @@ namespace ts {
|
||||
// * Why loop initializer is excluded?
|
||||
// - Since we've introduced a fresh name it already will be undefined.
|
||||
|
||||
const original = getOriginalNode(node);
|
||||
Debug.assert(isVariableDeclaration(original));
|
||||
|
||||
const flags = resolver.getNodeCheckFlags(original);
|
||||
const flags = resolver.getNodeCheckFlags(node);
|
||||
const isCapturedInFunction = flags & NodeCheckFlags.CapturedBlockScopedBinding;
|
||||
const isDeclaredInLoop = flags & NodeCheckFlags.BlockScopedBindingInLoop;
|
||||
const emittedAsTopLevel =
|
||||
@@ -1440,7 +1451,7 @@ namespace ts {
|
||||
!emittedAsTopLevel
|
||||
&& enclosingBlockScopeContainer.kind !== SyntaxKind.ForInStatement
|
||||
&& enclosingBlockScopeContainer.kind !== SyntaxKind.ForOfStatement
|
||||
&& (!resolver.isDeclarationWithCollidingName(<Declaration>original)
|
||||
&& (!resolver.isDeclarationWithCollidingName(node)
|
||||
|| (isDeclaredInLoop
|
||||
&& !isCapturedInFunction
|
||||
&& !isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false)));
|
||||
@@ -1718,7 +1729,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function shouldConvertIterationStatementBody(node: IterationStatement): boolean {
|
||||
return (resolver.getNodeCheckFlags(getOriginalNode(node)) & NodeCheckFlags.LoopWithCapturedBlockScopedBinding) !== 0;
|
||||
return (resolver.getNodeCheckFlags(node) & NodeCheckFlags.LoopWithCapturedBlockScopedBinding) !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2611,8 +2622,8 @@ namespace ts {
|
||||
// Only substitute the identifier if we have enabled substitutions for block-scoped
|
||||
// bindings.
|
||||
if (enabledSubstitutions & ES6SubstitutionFlags.BlockScopedBindings) {
|
||||
const original = getOriginalNode(node);
|
||||
if (isIdentifier(original) && !nodeIsSynthesized(original) && original.parent && isNameOfDeclarationWithCollidingName(original)) {
|
||||
const original = getSourceTreeNodeOfType(node, isIdentifier);
|
||||
if (original && isNameOfDeclarationWithCollidingName(original)) {
|
||||
return getGeneratedNameForNode(original);
|
||||
}
|
||||
}
|
||||
@@ -2665,12 +2676,9 @@ namespace ts {
|
||||
*/
|
||||
function substituteExpressionIdentifier(node: Identifier): Identifier {
|
||||
if (enabledSubstitutions & ES6SubstitutionFlags.BlockScopedBindings) {
|
||||
const original = getOriginalNode(node);
|
||||
if (isIdentifier(original)) {
|
||||
const declaration = resolver.getReferencedDeclarationWithCollidingName(original);
|
||||
if (declaration) {
|
||||
return getGeneratedNameForNode(declaration.name);
|
||||
}
|
||||
const declaration = resolver.getReferencedDeclarationWithCollidingName(node);
|
||||
if (declaration) {
|
||||
return getGeneratedNameForNode(declaration.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2690,8 +2698,25 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
function getDeclarationName(node: ClassExpression | ClassDeclaration | FunctionDeclaration) {
|
||||
return node.name ? getSynthesizedClone(node.name) : getGeneratedNameForNode(node);
|
||||
/**
|
||||
* Gets the name of a declaration, without source map or comments.
|
||||
*
|
||||
* @param node The declaration.
|
||||
* @param allowComments Allow comments for the name.
|
||||
*/
|
||||
function getDeclarationName(node: DeclarationStatement | ClassExpression, allowComments?: boolean) {
|
||||
if (node.name) {
|
||||
const name = getMutableClone(node.name);
|
||||
let flags = NodeEmitFlags.NoSourceMap;
|
||||
if (!allowComments) {
|
||||
flags |= NodeEmitFlags.NoComments;
|
||||
}
|
||||
|
||||
setNodeEmitFlags(name, flags | getNodeEmitFlags(name));
|
||||
return name;
|
||||
}
|
||||
|
||||
return getGeneratedNameForNode(node);
|
||||
}
|
||||
|
||||
function getClassMemberPrefix(node: ClassExpression | ClassDeclaration, member: ClassElement) {
|
||||
@@ -2733,4 +2758,4 @@ namespace ts {
|
||||
return isIdentifier(expression) && expression === parameter.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,59 @@ namespace ts {
|
||||
return visitNamedBindings(<NamedImportBindings>node);
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
return visitImportSpecifier(<ImportSpecifier>node);
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return visitExportAssignment(<ExportAssignment>node);
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return visitExportDeclaration(<ExportDeclaration>node);
|
||||
case SyntaxKind.NamedExports:
|
||||
return visitNamedExports(<NamedExports>node);
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
return visitExportSpecifier(<ExportSpecifier>node);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitExportAssignment(node: ExportAssignment): ExportAssignment {
|
||||
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 visitExportDeclaration(node: ExportDeclaration): ExportDeclaration {
|
||||
if (!node.exportClause) {
|
||||
return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined;
|
||||
}
|
||||
if (!resolver.isValueAliasDeclaration(node)) {
|
||||
return undefined;
|
||||
}
|
||||
const newExportClause = visitNode(node.exportClause, visitor, isNamedExports, /*optional*/ true);
|
||||
if (node.exportClause === newExportClause) {
|
||||
return node;
|
||||
}
|
||||
return newExportClause
|
||||
? createExportDeclaration(newExportClause, node.moduleSpecifier)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function visitNamedExports(node: NamedExports): NamedExports {
|
||||
const newExports = visitNodes(node.elements, visitor, isExportSpecifier);
|
||||
if (node.elements === newExports) {
|
||||
return node;
|
||||
}
|
||||
return newExports.length ? createNamedExports(newExports) : undefined;
|
||||
}
|
||||
|
||||
function visitExportSpecifier(node: ExportSpecifier): ExportSpecifier {
|
||||
return resolver.isValueAliasDeclaration(node) ? 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);
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace ts {
|
||||
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
const resolver = context.getEmitResolver();
|
||||
const host = context.getEmitHost();
|
||||
const languageVersion = getEmitScriptTarget(compilerOptions);
|
||||
const moduleKind = getEmitModuleKind(compilerOptions);
|
||||
const previousExpressionSubstitution = context.expressionSubstitution;
|
||||
@@ -31,7 +32,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 +46,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 +56,7 @@ namespace ts {
|
||||
externalImports = undefined;
|
||||
exportSpecifiers = undefined;
|
||||
exportEquals = undefined;
|
||||
hasExportStars = false;
|
||||
hasExportStarsToExportValues = false;
|
||||
return updated;
|
||||
}
|
||||
|
||||
@@ -77,7 +78,7 @@ namespace ts {
|
||||
addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false);
|
||||
|
||||
const updated = updateSourceFile(node, statements);
|
||||
if (hasExportStars) {
|
||||
if (hasExportStarsToExportValues) {
|
||||
setNodeEmitFlags(updated, NodeEmitFlags.EmitExportStar | getNodeEmitFlags(node));
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ namespace ts {
|
||||
*/
|
||||
function transformAMDModule(node: SourceFile) {
|
||||
const define = createIdentifier("define");
|
||||
const moduleName = node.moduleName ? createLiteral(node.moduleName) : undefined;
|
||||
const moduleName = tryGetModuleNameFromFile(node, host, compilerOptions);
|
||||
return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true);
|
||||
}
|
||||
|
||||
@@ -200,7 +201,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);
|
||||
@@ -357,6 +358,9 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Set emitFlags on the name of the importEqualsDeclaration
|
||||
// This is so the printer will not substitute the identifier
|
||||
setNodeEmitFlags(node.name, NodeEmitFlags.NoSubstitution);
|
||||
const statements: Statement[] = [];
|
||||
if (moduleKind !== ModuleKind.AMD) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
@@ -442,7 +446,7 @@ namespace ts {
|
||||
|
||||
return singleOrMany(statements);
|
||||
}
|
||||
else {
|
||||
else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) {
|
||||
// export * from "mod";
|
||||
return createStatement(
|
||||
createCall(
|
||||
@@ -460,8 +464,7 @@ namespace ts {
|
||||
|
||||
function visitExportAssignment(node: ExportAssignment): VisitResult<Statement> {
|
||||
if (!node.isExportEquals) {
|
||||
const original = getOriginalNode(node);
|
||||
if (nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original)) {
|
||||
if (nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) {
|
||||
const statements: Statement[] = [];
|
||||
addExportDefault(statements, node.expression, /*location*/ node);
|
||||
return statements;
|
||||
@@ -553,7 +556,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
statements.push(
|
||||
createExportStatement(node.name, node.name, /*location*/ node)
|
||||
createExportStatement(node.name, setNodeEmitFlags(getSynthesizedClone(node.name), NodeEmitFlags.LocalName), /*location*/ node)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -639,6 +642,9 @@ namespace ts {
|
||||
function visitClassDeclaration(node: ClassDeclaration): VisitResult<Statement> {
|
||||
const statements: Statement[] = [];
|
||||
const name = node.name || getGeneratedNameForNode(node);
|
||||
// Set emitFlags on the name of the classDeclaration
|
||||
// This is so that when printer will not substitute the identifier
|
||||
setNodeEmitFlags(name, NodeEmitFlags.NoSubstitution);
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
statements.push(
|
||||
createClassDeclaration(
|
||||
@@ -713,40 +719,50 @@ namespace ts {
|
||||
}
|
||||
|
||||
function substituteExpressionIdentifier(node: Identifier): Expression {
|
||||
const original = getOriginalNode(node);
|
||||
if (isIdentifier(original)) {
|
||||
const container = resolver.getReferencedExportContainer(original, (getNodeEmitFlags(node) & NodeEmitFlags.PrefixExportedLocal) !== 0);
|
||||
if (container) {
|
||||
if (container.kind === SyntaxKind.SourceFile) {
|
||||
return createPropertyAccess(
|
||||
createIdentifier("exports"),
|
||||
getSynthesizedClone(node),
|
||||
/*location*/ node
|
||||
);
|
||||
}
|
||||
if (getNodeEmitFlags(node) & NodeEmitFlags.LocalName) {
|
||||
return node;
|
||||
}
|
||||
|
||||
const container = resolver.getReferencedExportContainer(node, (getNodeEmitFlags(node) & NodeEmitFlags.ExportName) !== 0);
|
||||
if (container) {
|
||||
if (container.kind === SyntaxKind.SourceFile) {
|
||||
return createPropertyAccess(
|
||||
createIdentifier("exports"),
|
||||
getSynthesizedClone(node),
|
||||
/*location*/ node
|
||||
);
|
||||
}
|
||||
else {
|
||||
const declaration = resolver.getReferencedImportDeclaration(node.parent ? node : original);
|
||||
if (declaration) {
|
||||
if (declaration.kind === SyntaxKind.ImportClause) {
|
||||
if (languageVersion >= ScriptTarget.ES5) {
|
||||
return createPropertyAccess(
|
||||
getGeneratedNameForNode(declaration.parent),
|
||||
createIdentifier("default"),
|
||||
/*location*/ node
|
||||
);
|
||||
}
|
||||
else {
|
||||
return createElementAccess(
|
||||
getGeneratedNameForNode(declaration.parent),
|
||||
createLiteral("default"),
|
||||
/*location*/ node
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const declaration = resolver.getReferencedImportDeclaration(node);
|
||||
if (declaration) {
|
||||
if (declaration.kind === SyntaxKind.ImportClause) {
|
||||
if (languageVersion >= ScriptTarget.ES5) {
|
||||
return createPropertyAccess(
|
||||
getGeneratedNameForNode(declaration.parent),
|
||||
createIdentifier("default"),
|
||||
/*location*/ node
|
||||
);
|
||||
}
|
||||
else if (declaration.kind === SyntaxKind.ImportSpecifier) {
|
||||
const name = (<ImportSpecifier>declaration).propertyName
|
||||
|| (<ImportSpecifier>declaration).name;
|
||||
else {
|
||||
return createElementAccess(
|
||||
getGeneratedNameForNode(declaration.parent),
|
||||
createLiteral("default"),
|
||||
/*location*/ node
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (declaration.kind === SyntaxKind.ImportSpecifier) {
|
||||
const name = (<ImportSpecifier>declaration).propertyName
|
||||
|| (<ImportSpecifier>declaration).name;
|
||||
if (name.originalKeywordKind === SyntaxKind.DefaultKeyword && languageVersion <= ScriptTarget.ES3) {
|
||||
return createElementAccess(
|
||||
getGeneratedNameForNode(declaration.parent.parent.parent),
|
||||
createLiteral(name.text),
|
||||
/*location*/ node
|
||||
);
|
||||
}
|
||||
else {
|
||||
return createPropertyAccess(
|
||||
getGeneratedNameForNode(declaration.parent.parent.parent),
|
||||
getSynthesizedClone(name),
|
||||
@@ -768,42 +784,8 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
function getExternalModuleNameLiteral(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration) {
|
||||
const moduleName = getExternalModuleName(importNode);
|
||||
if (moduleName.kind === SyntaxKind.StringLiteral) {
|
||||
return tryRenameExternalModule(<StringLiteral>moduleName)
|
||||
|| createLiteral(<StringLiteral>moduleName);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Some bundlers (SystemJS builder) sometimes want to rename dependencies.
|
||||
* Here we check if alternative name was provided for a given moduleName and return it if possible.
|
||||
*/
|
||||
function tryRenameExternalModule(moduleName: LiteralExpression) {
|
||||
if (currentSourceFile.renamedDependencies && hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) {
|
||||
return createLiteral(currentSourceFile.renamedDependencies[moduleName.text]);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): Identifier {
|
||||
const namespaceDeclaration = getNamespaceDeclarationNode(node);
|
||||
if (namespaceDeclaration && !isDefaultImport(node)) {
|
||||
return createIdentifier(getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name));
|
||||
}
|
||||
if (node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).importClause) {
|
||||
return getGeneratedNameForNode(node);
|
||||
}
|
||||
if (node.kind === SyntaxKind.ExportDeclaration && (<ExportDeclaration>node).moduleSpecifier) {
|
||||
return getGeneratedNameForNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
function createRequireCall(importNode: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration) {
|
||||
const moduleName = getExternalModuleNameLiteral(importNode);
|
||||
const moduleName = getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions);
|
||||
const args: Expression[] = [];
|
||||
if (isDefined(moduleName)) {
|
||||
args.push(moduleName);
|
||||
@@ -818,7 +800,7 @@ namespace ts {
|
||||
|
||||
function createExportAssignment(name: Identifier, value: Expression) {
|
||||
return createAssignment(
|
||||
name.originalKeywordKind && languageVersion === ScriptTarget.ES3
|
||||
name.originalKeywordKind === SyntaxKind.DefaultKeyword && languageVersion === ScriptTarget.ES3
|
||||
? createElementAccess(
|
||||
createIdentifier("exports"),
|
||||
createLiteral(name.text)
|
||||
@@ -862,11 +844,14 @@ namespace ts {
|
||||
|
||||
for (const importNode of externalImports) {
|
||||
// Find the name of the external module
|
||||
const externalModuleName = getExternalModuleNameLiteral(importNode);
|
||||
const externalModuleName = getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions);
|
||||
|
||||
// Find the name of the module alias, if there is one
|
||||
const importAliasName = getLocalNameForExternalImport(importNode);
|
||||
const importAliasName = getLocalNameForExternalImport(importNode, currentSourceFile);
|
||||
if (includeNonAmdDependencies && importAliasName) {
|
||||
// Set emitFlags on the name of the classDeclaration
|
||||
// This is so that when printer will not substitute the identifier
|
||||
setNodeEmitFlags(importAliasName, NodeEmitFlags.NoSubstitution);
|
||||
aliasedModuleNames.push(externalModuleName);
|
||||
importAliasNames.push(createParameter(importAliasName));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const {
|
||||
getNodeEmitFlags,
|
||||
startLexicalEnvironment,
|
||||
endLexicalEnvironment,
|
||||
hoistVariableDeclaration,
|
||||
@@ -19,6 +20,7 @@ namespace ts {
|
||||
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
const resolver = context.getEmitResolver();
|
||||
const host = context.getEmitHost();
|
||||
const languageVersion = getEmitScriptTarget(compilerOptions);
|
||||
const previousExpressionSubstitution = context.expressionSubstitution;
|
||||
context.enableExpressionSubstitution(SyntaxKind.Identifier);
|
||||
@@ -37,7 +39,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 +64,7 @@ namespace ts {
|
||||
externalImports = undefined;
|
||||
exportSpecifiers = undefined;
|
||||
exportEquals = undefined;
|
||||
hasExportStars = false;
|
||||
hasExportStarsToExportValues = false;
|
||||
exportFunctionForFile = undefined;
|
||||
contextObjectForFile = undefined;
|
||||
exportedLocalNames = undefined;
|
||||
@@ -89,7 +91,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.
|
||||
@@ -105,6 +107,7 @@ namespace ts {
|
||||
// Add the body of the module.
|
||||
addSystemModuleBody(statements, node, dependencyGroups);
|
||||
|
||||
const moduleName = tryGetModuleNameFromFile(node, host, compilerOptions);
|
||||
const dependencies = createArrayLiteral(map(dependencyGroups, getNameOfDependencyGroup));
|
||||
const body = createFunctionExpression(
|
||||
/*asteriskToken*/ undefined,
|
||||
@@ -120,16 +123,18 @@ namespace ts {
|
||||
);
|
||||
|
||||
// Write the call to `System.register`
|
||||
// Clear the emit-helpers flag for later passes since we'll have already used it in the module body
|
||||
// So the helper will be emit at the correct position instead of at the top of the source-file
|
||||
return updateSourceFile(node, [
|
||||
createStatement(
|
||||
createCall(
|
||||
createPropertyAccess(createIdentifier("System"), "register"),
|
||||
node.moduleName
|
||||
? [createLiteral(node.moduleName), dependencies, body]
|
||||
moduleName
|
||||
? [moduleName, dependencies, body]
|
||||
: [dependencies, body]
|
||||
)
|
||||
)
|
||||
]);
|
||||
], /*nodeEmitFlags*/ ~NodeEmitFlags.EmitEmitHelpers & getNodeEmitFlags(node));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +193,7 @@ namespace ts {
|
||||
startLexicalEnvironment();
|
||||
|
||||
// Add any prologue directives.
|
||||
const statementOffset = addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict);
|
||||
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict);
|
||||
|
||||
// var __moduleName = context_1 && context_1.id;
|
||||
addNode(statements,
|
||||
@@ -253,7 +258,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function addExportStarIfNeeded(statements: Statement[]) {
|
||||
if (!hasExportStars) {
|
||||
if (!hasExportStarsToExportValues) {
|
||||
return;
|
||||
}
|
||||
// when resolving exports local exported entries/indirect exported entries in the module
|
||||
@@ -338,11 +343,11 @@ namespace ts {
|
||||
const setters: Expression[] = [];
|
||||
for (const group of dependencyGroups) {
|
||||
// derive a unique name for parameter from the first named entry in the group
|
||||
const localName = forEach(group.externalImports, getLocalNameForExternalImport);
|
||||
const localName = forEach(group.externalImports, i => getLocalNameForExternalImport(i, currentSourceFile));
|
||||
const parameterName = localName ? getGeneratedNameForNode(localName) : createUniqueName("");
|
||||
const statements: Statement[] = [];
|
||||
for (const entry of group.externalImports) {
|
||||
const importVariableName = getLocalNameForExternalImport(entry);
|
||||
const importVariableName = getLocalNameForExternalImport(entry, currentSourceFile);
|
||||
switch (entry.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
if (!(<ImportDeclaration>entry).importClause) {
|
||||
@@ -531,7 +536,7 @@ namespace ts {
|
||||
|
||||
function visitImportDeclaration(node: ImportDeclaration): Node {
|
||||
if (node.importClause && contains(externalImports, node)) {
|
||||
hoistVariableDeclaration(getLocalNameForExternalImport(node));
|
||||
hoistVariableDeclaration(getLocalNameForExternalImport(node, currentSourceFile));
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -539,7 +544,7 @@ namespace ts {
|
||||
|
||||
function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): Node {
|
||||
if (contains(externalImports, node)) {
|
||||
hoistVariableDeclaration(getLocalNameForExternalImport(node));
|
||||
hoistVariableDeclaration(getLocalNameForExternalImport(node, currentSourceFile));
|
||||
}
|
||||
|
||||
// NOTE(rbuckton): Do we support export import = require('') in System?
|
||||
@@ -570,8 +575,7 @@ namespace ts {
|
||||
|
||||
function visitExportAssignment(node: ExportAssignment): Statement {
|
||||
if (!node.isExportEquals) {
|
||||
const original = getOriginalNode(node);
|
||||
if (nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original)) {
|
||||
if (nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) {
|
||||
return createExportStatement(
|
||||
createLiteral("default"),
|
||||
node.expression
|
||||
@@ -1012,8 +1016,7 @@ namespace ts {
|
||||
const left = node.left;
|
||||
switch (left.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
const originalNode = getOriginalNode(left);
|
||||
const exportDeclaration = resolver.getReferencedExportContainer(<Identifier>originalNode);
|
||||
const exportDeclaration = resolver.getReferencedExportContainer(<Identifier>left);
|
||||
if (exportDeclaration) {
|
||||
return createExportExpression(<Identifier>left, node);
|
||||
}
|
||||
@@ -1149,41 +1152,6 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
function getExternalModuleNameLiteral(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration) {
|
||||
const moduleName = getExternalModuleName(importNode);
|
||||
if (moduleName.kind === SyntaxKind.StringLiteral) {
|
||||
return tryRenameExternalModule(<StringLiteral>moduleName)
|
||||
|| getSynthesizedClone(<StringLiteral>moduleName);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Some bundlers (SystemJS builder) sometimes want to rename dependencies.
|
||||
* Here we check if alternative name was provided for a given moduleName and return it if possible.
|
||||
*/
|
||||
function tryRenameExternalModule(moduleName: LiteralExpression) {
|
||||
if (currentSourceFile.renamedDependencies && hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) {
|
||||
return createLiteral(currentSourceFile.renamedDependencies[moduleName.text]);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): Identifier {
|
||||
const namespaceDeclaration = getNamespaceDeclarationNode(node);
|
||||
if (namespaceDeclaration && !isDefaultImport(node)) {
|
||||
return createIdentifier(getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name));
|
||||
}
|
||||
if (node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).importClause) {
|
||||
return getGeneratedNameForNode(node);
|
||||
}
|
||||
if (node.kind === SyntaxKind.ExportDeclaration && (<ExportDeclaration>node).moduleSpecifier) {
|
||||
return getGeneratedNameForNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a name to use for a DeclarationStatement.
|
||||
* @param node The declaration statement.
|
||||
@@ -1313,7 +1281,7 @@ namespace ts {
|
||||
const dependencyGroups: DependencyGroup[] = [];
|
||||
for (let i = 0; i < externalImports.length; i++) {
|
||||
const externalImport = externalImports[i];
|
||||
const externalModuleName = getExternalModuleNameLiteral(externalImport);
|
||||
const externalModuleName = getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions);
|
||||
const text = externalModuleName.text;
|
||||
if (hasProperty(groupIndices, text)) {
|
||||
// deduplicate/group entries in dependency list by the dependency name
|
||||
@@ -1374,9 +1342,10 @@ namespace ts {
|
||||
hoistBindingElement(node, /*isExported*/ false);
|
||||
}
|
||||
|
||||
function updateSourceFile(node: SourceFile, statements: Statement[]) {
|
||||
function updateSourceFile(node: SourceFile, statements: Statement[], nodeEmitFlags: NodeEmitFlags) {
|
||||
const updated = getMutableClone(node);
|
||||
updated.statements = createNodeArray(statements, node.statements);
|
||||
setNodeEmitFlags(updated, nodeEmitFlags);
|
||||
return updated;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,15 @@ namespace ts {
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function namespaceElementVisitorWorker(node: Node): VisitResult<Node> {
|
||||
if (node.transformFlags & TransformFlags.TypeScript || hasModifier(node, ModifierFlags.Export)) {
|
||||
if (node.kind === SyntaxKind.ExportDeclaration ||
|
||||
node.kind === SyntaxKind.ImportDeclaration ||
|
||||
node.kind === SyntaxKind.ImportClause ||
|
||||
(node.kind === SyntaxKind.ImportEqualsDeclaration &&
|
||||
(<ImportEqualsDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference)) {
|
||||
// do not emit ES6 imports and exports since they are illegal inside a namespace
|
||||
return undefined;
|
||||
}
|
||||
else if (node.transformFlags & TransformFlags.TypeScript || hasModifier(node, ModifierFlags.Export)) {
|
||||
// This node is explicitly marked as TypeScript, or is exported at the namespace
|
||||
// level, so we should transform the node.
|
||||
return visitTypeScript(node);
|
||||
@@ -596,7 +604,7 @@ namespace ts {
|
||||
|
||||
// Record an alias to avoid class double-binding.
|
||||
let decoratedClassAlias: Identifier;
|
||||
if (resolver.getNodeCheckFlags(getOriginalNode(node)) & NodeCheckFlags.DecoratedClassWithSelfReference) {
|
||||
if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.DecoratedClassWithSelfReference) {
|
||||
enableExpressionSubstitutionForDecoratedClasses();
|
||||
decoratedClassAlias = createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? node.name.text : "default");
|
||||
decoratedClassAliases[getOriginalNodeId(node)] = decoratedClassAlias;
|
||||
@@ -829,7 +837,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
|
||||
);
|
||||
}
|
||||
@@ -1262,7 +1276,7 @@ namespace ts {
|
||||
//
|
||||
|
||||
const prefix = getClassMemberPrefix(node, member);
|
||||
const memberName = getExpressionForPropertyName(member);
|
||||
const memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true);
|
||||
const descriptor = languageVersion > ScriptTarget.ES3
|
||||
? member.kind === SyntaxKind.PropertyDeclaration
|
||||
// We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
|
||||
@@ -1374,7 +1388,6 @@ namespace ts {
|
||||
|
||||
function addOldTypeMetadata(node: Declaration, decoratorExpressions: Expression[]) {
|
||||
if (compilerOptions.emitDecoratorMetadata) {
|
||||
let properties: ObjectLiteralElement[];
|
||||
if (shouldAddTypeMetadata(node)) {
|
||||
decoratorExpressions.push(createMetadataHelper("design:type", serializeTypeOfNode(node)));
|
||||
}
|
||||
@@ -1608,11 +1621,9 @@ namespace ts {
|
||||
* @param node The type reference node.
|
||||
*/
|
||||
function serializeTypeReferenceNode(node: TypeReferenceNode) {
|
||||
// Clone the type name and parent it to a location outside of the current declaration.
|
||||
const typeName = cloneEntityName(node.typeName, currentScope);
|
||||
switch (resolver.getTypeReferenceSerializationKind(typeName)) {
|
||||
switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) {
|
||||
case TypeReferenceSerializationKind.Unknown:
|
||||
const serialized = serializeEntityNameAsExpression(typeName, /*useFallback*/ true);
|
||||
const serialized = serializeEntityNameAsExpression(node.typeName, /*useFallback*/ true);
|
||||
const temp = createTempVariable(hoistVariableDeclaration);
|
||||
return createLogicalOr(
|
||||
createLogicalAnd(
|
||||
@@ -1628,7 +1639,7 @@ namespace ts {
|
||||
);
|
||||
|
||||
case TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
|
||||
return serializeEntityNameAsExpression(typeName, /*useFallback*/ false);
|
||||
return serializeEntityNameAsExpression(node.typeName, /*useFallback*/ false);
|
||||
|
||||
case TypeReferenceSerializationKind.VoidType:
|
||||
return createVoidZero();
|
||||
@@ -1669,17 +1680,20 @@ namespace ts {
|
||||
function serializeEntityNameAsExpression(node: EntityName, useFallback: boolean): Expression {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
const name = getMutableClone(<Identifier>node);
|
||||
name.original = undefined;
|
||||
name.parent = currentScope;
|
||||
if (useFallback) {
|
||||
return createLogicalAnd(
|
||||
createStrictInequality(
|
||||
createTypeOf(<Identifier>node),
|
||||
createTypeOf(name),
|
||||
createLiteral("undefined")
|
||||
),
|
||||
<Identifier>node
|
||||
name
|
||||
);
|
||||
}
|
||||
|
||||
return <Identifier>node;
|
||||
return name;
|
||||
|
||||
case SyntaxKind.QualifiedName:
|
||||
return serializeQualifiedNameAsExpression(<QualifiedName>node, useFallback);
|
||||
@@ -1736,10 +1750,12 @@ namespace ts {
|
||||
*
|
||||
* @param member The member whose name should be converted into an expression.
|
||||
*/
|
||||
function getExpressionForPropertyName(member: ClassElement | EnumMember): Expression {
|
||||
function getExpressionForPropertyName(member: ClassElement | EnumMember, generateNameForComputedPropertyName: boolean): Expression {
|
||||
const name = member.name;
|
||||
if (isComputedPropertyName(name)) {
|
||||
return getGeneratedNameForNode(name);
|
||||
return generateNameForComputedPropertyName
|
||||
? getGeneratedNameForNode(name)
|
||||
: (<ComputedPropertyName>name).expression;
|
||||
}
|
||||
else if (isIdentifier(name)) {
|
||||
return createLiteral(name.text);
|
||||
@@ -2207,24 +2223,6 @@ namespace ts {
|
||||
|| (isES6ExportedDeclaration(node) && isFirstDeclarationOfKind(node, node.kind));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a leading VariableStatement for an enum or module declaration.
|
||||
*/
|
||||
function addVarForEnumDeclaration(statements: Statement[], node: EnumDeclaration) {
|
||||
// Emit a variable statement for the enum.
|
||||
statements.push(
|
||||
createVariableStatement(
|
||||
isES6ExportedDeclaration(node)
|
||||
? visitNodes(node.modifiers, visitor, isModifier)
|
||||
: undefined,
|
||||
[createVariableDeclaration(
|
||||
getDeclarationName(node)
|
||||
)],
|
||||
/*location*/ node
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a trailing VariableStatement for an enum or module declaration.
|
||||
*/
|
||||
@@ -2255,7 +2253,7 @@ namespace ts {
|
||||
|
||||
const statements: Statement[] = [];
|
||||
if (shouldEmitVarForEnumDeclaration(node)) {
|
||||
addVarForEnumDeclaration(statements, node);
|
||||
addVarForEnumOrModuleDeclaration(statements, node);
|
||||
}
|
||||
|
||||
const localName = getGeneratedNameForNode(node);
|
||||
@@ -2323,7 +2321,10 @@ namespace ts {
|
||||
* @param member The enum member node.
|
||||
*/
|
||||
function transformEnumMember(member: EnumMember): Statement {
|
||||
const name = getExpressionForPropertyName(member);
|
||||
// enums don't support computed properties
|
||||
// we pass false as 'generateNameForComputedPropertyName' for a backward compatibility purposes
|
||||
// old emitter always generate 'expression' part of the name as-is.
|
||||
const name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false);
|
||||
return createStatement(
|
||||
createAssignment(
|
||||
createElementAccess(
|
||||
@@ -2389,9 +2390,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a leading VariableStatement for a module declaration.
|
||||
* Adds a leading VariableStatement for a enum or module declaration.
|
||||
*/
|
||||
function addVarForModuleDeclaration(statements: Statement[], node: ModuleDeclaration) {
|
||||
function addVarForEnumOrModuleDeclaration(statements: Statement[], node: ModuleDeclaration | EnumDeclaration) {
|
||||
// Emit a variable statement for the module.
|
||||
statements.push(
|
||||
setOriginalNode(
|
||||
@@ -2402,7 +2403,21 @@ namespace ts {
|
||||
[createVariableDeclaration(
|
||||
getDeclarationName(node)
|
||||
)],
|
||||
/*location*/ node
|
||||
// Trailing comments for module declaration should be emitted with function closure instead of variable statement
|
||||
// So do not set the end position for the variable statement node
|
||||
// /** Module comment*/
|
||||
// module m1 {
|
||||
// function foo4Export() {
|
||||
// }
|
||||
// } // trailing comment module
|
||||
// Should emit
|
||||
// /** Module comment*/
|
||||
// var m1;
|
||||
// (function (m1) {
|
||||
// function foo4Export() {
|
||||
// }
|
||||
// })(m1 || (m1 = {})); // trailing comment module
|
||||
/*location*/ { pos: node.pos, end: -1 }
|
||||
),
|
||||
node
|
||||
)
|
||||
@@ -2427,7 +2442,7 @@ namespace ts {
|
||||
const statements: Statement[] = [];
|
||||
|
||||
if (shouldEmitVarForModuleDeclaration(node)) {
|
||||
addVarForModuleDeclaration(statements, node);
|
||||
addVarForEnumOrModuleDeclaration(statements, node);
|
||||
}
|
||||
|
||||
const localName = getGeneratedNameForNode(node);
|
||||
@@ -2638,9 +2653,9 @@ namespace ts {
|
||||
return getNamespaceMemberName(name);
|
||||
}
|
||||
else {
|
||||
// We set the "PrefixExportedLocal" flag to indicate to any module transformer
|
||||
// We set the "ExportName" flag to indicate to any module transformer
|
||||
// downstream that any `exports.` prefix should be added.
|
||||
setNodeEmitFlags(name, getNodeEmitFlags(name) | NodeEmitFlags.PrefixExportedLocal);
|
||||
setNodeEmitFlags(name, getNodeEmitFlags(name) | NodeEmitFlags.ExportName);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -2732,41 +2747,52 @@ namespace ts {
|
||||
}
|
||||
|
||||
function substituteExpressionIdentifier(node: Identifier): Expression {
|
||||
return trySubstituteDecoratedClassName(node)
|
||||
|| trySubstituteNamespaceExportedName(node)
|
||||
|| node;
|
||||
}
|
||||
|
||||
function trySubstituteDecoratedClassName(node: Identifier): Expression {
|
||||
if (enabledSubstitutions & TypeScriptSubstitutionFlags.DecoratedClasses) {
|
||||
const original = getOriginalNode(node);
|
||||
if (isIdentifier(original)) {
|
||||
if (resolver.getNodeCheckFlags(original) & NodeCheckFlags.SelfReferenceInDecoratedClass) {
|
||||
// Due to the emit for class decorators, any reference to the class from inside of the class body
|
||||
// must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
|
||||
// behavior of class names in ES6.
|
||||
const declaration = resolver.getReferencedValueDeclaration(original);
|
||||
if (declaration) {
|
||||
const classAlias = currentDecoratedClassAliases[getNodeId(declaration)];
|
||||
if (classAlias) {
|
||||
return getRelocatedClone(classAlias, /*location*/ node);
|
||||
}
|
||||
if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.SelfReferenceInDecoratedClass) {
|
||||
// Due to the emit for class decorators, any reference to the class from inside of the class body
|
||||
// must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
|
||||
// behavior of class names in ES6.
|
||||
const declaration = resolver.getReferencedValueDeclaration(node);
|
||||
if (declaration) {
|
||||
const classAlias = currentDecoratedClassAliases[getNodeId(declaration)];
|
||||
if (classAlias) {
|
||||
return getRelocatedClone(classAlias, /*location*/ node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function trySubstituteNamespaceExportedName(node: Identifier): Expression {
|
||||
if (enabledSubstitutions & applicableSubstitutions) {
|
||||
// If this is explicitly a local name, do not substitute.
|
||||
if (getNodeEmitFlags(node) & NodeEmitFlags.LocalName) {
|
||||
return node;
|
||||
}
|
||||
|
||||
// If we are nested within a namespace declaration, we may need to qualifiy
|
||||
// an identifier that is exported from a merged namespace.
|
||||
const original = getOriginalNode(node);
|
||||
if (isIdentifier(original) && original.parent) {
|
||||
const container = resolver.getReferencedExportContainer(original);
|
||||
if (container) {
|
||||
const substitute =
|
||||
(applicableSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports && container.kind === SyntaxKind.ModuleDeclaration) ||
|
||||
(applicableSubstitutions & TypeScriptSubstitutionFlags.NonQualifiedEnumMembers && container.kind === SyntaxKind.EnumDeclaration);
|
||||
if (substitute) {
|
||||
return createPropertyAccess(getGeneratedNameForNode(container), node, /*location*/ node);
|
||||
}
|
||||
const original = getSourceTreeNodeOfType(node, isIdentifier);
|
||||
const container = resolver.getReferencedExportContainer(original, /*prefixLocals*/ false);
|
||||
if (container && original !== container.name) {
|
||||
const substitute =
|
||||
(applicableSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports && container.kind === SyntaxKind.ModuleDeclaration) ||
|
||||
(applicableSubstitutions & TypeScriptSubstitutionFlags.NonQualifiedEnumMembers && container.kind === SyntaxKind.EnumDeclaration);
|
||||
if (substitute) {
|
||||
return createPropertyAccess(getGeneratedNameForNode(container), node, /*location*/ node);
|
||||
}
|
||||
}
|
||||
}
|
||||
return node;
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function substituteCallExpression(node: CallExpression): Expression {
|
||||
@@ -2894,7 +2920,7 @@ namespace ts {
|
||||
|
||||
function getSuperContainerAsyncMethodFlags() {
|
||||
return currentSuperContainer !== undefined
|
||||
&& resolver.getNodeCheckFlags(getOriginalNode(currentSuperContainer)) & (NodeCheckFlags.AsyncMethodWithSuper | NodeCheckFlags.AsyncMethodWithSuperBinding);
|
||||
&& resolver.getNodeCheckFlags(currentSuperContainer) & (NodeCheckFlags.AsyncMethodWithSuper | NodeCheckFlags.AsyncMethodWithSuperBinding);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-11
@@ -1963,7 +1963,7 @@ namespace ts {
|
||||
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
getReferencedValueDeclaration(reference: Identifier): Declaration;
|
||||
getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind;
|
||||
getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind;
|
||||
isOptionalParameter(node: ParameterDeclaration): boolean;
|
||||
moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean;
|
||||
isArgumentsLocalBinding(node: Identifier): boolean;
|
||||
@@ -2498,7 +2498,7 @@ namespace ts {
|
||||
noImplicitUseStrict?: boolean;
|
||||
lib?: string[];
|
||||
/* @internal */ stripInternal?: boolean;
|
||||
/* @internal */ experimentalTransforms?: boolean;
|
||||
/* @internal */ useLegacyEmitter?: boolean;
|
||||
|
||||
// Skip checking lib.d.ts to help speed up tests.
|
||||
/* @internal */ skipDefaultLibCheck?: boolean;
|
||||
@@ -2805,6 +2805,7 @@ namespace ts {
|
||||
* 'throw new Error("NotImplemented")'
|
||||
*/
|
||||
resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
|
||||
getEnvironmentVariable?(name: string): string;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -2829,11 +2830,12 @@ namespace ts {
|
||||
ContainsPropertyInitializer = 1 << 10,
|
||||
ContainsLexicalThis = 1 << 11,
|
||||
ContainsCapturedLexicalThis = 1 << 12,
|
||||
ContainsDefaultValueAssignments = 1 << 13,
|
||||
ContainsParameterPropertyAssignments = 1 << 14,
|
||||
ContainsSpreadElementExpression = 1 << 15,
|
||||
ContainsComputedPropertyName = 1 << 16,
|
||||
ContainsBlockScopedBinding = 1 << 17,
|
||||
ContainsLexicalThisInComputedPropertyName = 1 << 13,
|
||||
ContainsDefaultValueAssignments = 1 << 14,
|
||||
ContainsParameterPropertyAssignments = 1 << 15,
|
||||
ContainsSpreadElementExpression = 1 << 16,
|
||||
ContainsComputedPropertyName = 1 << 17,
|
||||
ContainsBlockScopedBinding = 1 << 18,
|
||||
|
||||
HasComputedFlags = 1 << 31, // Transform flags have been computed.
|
||||
|
||||
@@ -2852,10 +2854,10 @@ namespace ts {
|
||||
FunctionExcludes = ContainsDecorators | ContainsDefaultValueAssignments | ContainsCapturedLexicalThis | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding,
|
||||
ConstructorExcludes = ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding,
|
||||
MethodOrAccessorExcludes = ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding,
|
||||
ClassExcludes = ContainsDecorators | ContainsPropertyInitializer | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsComputedPropertyName | ContainsParameterPropertyAssignments,
|
||||
ClassExcludes = ContainsDecorators | ContainsPropertyInitializer | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsComputedPropertyName | ContainsParameterPropertyAssignments | ContainsLexicalThisInComputedPropertyName,
|
||||
ModuleExcludes = ContainsDecorators | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding,
|
||||
TypeExcludes = ~ContainsTypeScript,
|
||||
ObjectLiteralExcludes = ContainsDecorators | ContainsComputedPropertyName,
|
||||
ObjectLiteralExcludes = ContainsDecorators | ContainsComputedPropertyName | ContainsLexicalThisInComputedPropertyName,
|
||||
ArrayLiteralOrCallOrNewExcludes = ContainsSpreadElementExpression,
|
||||
}
|
||||
|
||||
@@ -2874,8 +2876,9 @@ namespace ts {
|
||||
NoSourceMap = 1 << 10, // Do not emit a source map location for this node.
|
||||
NoNestedSourceMaps = 1 << 11, // Do not emit source map locations for children of this node.
|
||||
NoComments = 1 << 12, // Do not emit comments for this node.
|
||||
PrefixExportedLocal = 1 << 13, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal).
|
||||
Indented = 1 << 14, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter).
|
||||
ExportName = 1 << 13, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal).
|
||||
LocalName = 1 << 14, // Ensure an export prefix is not added for an identifier that points to an exported declaration.
|
||||
Indented = 1 << 15, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter).
|
||||
}
|
||||
|
||||
/** Additional context provided to `visitEachChild` */
|
||||
@@ -2891,6 +2894,7 @@ namespace ts {
|
||||
export interface TransformationContext extends LexicalEnvironment {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getEmitResolver(): EmitResolver;
|
||||
getEmitHost(): EmitHost;
|
||||
getNodeEmitFlags(node: Node): NodeEmitFlags;
|
||||
setNodeEmitFlags<T extends Node>(node: T, flags: NodeEmitFlags): T;
|
||||
hoistFunctionDeclaration(node: FunctionDeclaration): void;
|
||||
|
||||
+44
-26
@@ -169,6 +169,18 @@ namespace ts {
|
||||
return `${ file.fileName }(${ loc.line + 1 },${ loc.character + 1 })`;
|
||||
}
|
||||
|
||||
export function getEnvironmentVariable(name: string, host?: CompilerHost) {
|
||||
if (host && host.getEnvironmentVariable) {
|
||||
return host.getEnvironmentVariable(name);
|
||||
}
|
||||
|
||||
if (sys && sys.getEnvironmentVariable) {
|
||||
return sys.getEnvironmentVariable(name);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
export function getStartPosOfNode(node: Node): number {
|
||||
return node.pos;
|
||||
}
|
||||
@@ -1699,24 +1711,6 @@ namespace ts {
|
||||
|| kind === SyntaxKind.SourceFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a deep clone of an EntityName, with new parent pointers.
|
||||
* @param node The EntityName to clone.
|
||||
* @param parent The parent for the cloned node.
|
||||
*/
|
||||
export function cloneEntityName(node: EntityName, parent?: Node): EntityName {
|
||||
const clone = getMutableClone(node);
|
||||
clone.parent = parent;
|
||||
if (isQualifiedName(clone)) {
|
||||
const { left, right } = clone;
|
||||
clone.left = cloneEntityName(left, clone);
|
||||
clone.right = getMutableClone(right);
|
||||
clone.right.parent = clone;
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
export function nodeIsSynthesized(node: TextRange): boolean {
|
||||
return positionIsSynthesized(node.pos)
|
||||
|| positionIsSynthesized(node.end);
|
||||
@@ -1729,13 +1723,31 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getOriginalNode(node: Node): Node {
|
||||
while (node.original !== undefined) {
|
||||
node = node.original;
|
||||
if (node) {
|
||||
while (node.original !== undefined) {
|
||||
node = node.original;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
export function getSourceTreeNode(node: Node): Node {
|
||||
node = getOriginalNode(node);
|
||||
if (node) {
|
||||
if (node.parent || node.kind === SyntaxKind.SourceFile) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getSourceTreeNodeOfType<T extends Node>(node: T, nodeTest: (node: Node) => node is T): T {
|
||||
const source = getSourceTreeNode(node);
|
||||
return source && nodeTest(source) ? source : undefined;
|
||||
}
|
||||
|
||||
export function getOriginalNodeId(node: Node) {
|
||||
node = getOriginalNode(node);
|
||||
return node ? getNodeId(node) : 0;
|
||||
@@ -2972,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:
|
||||
@@ -2987,7 +2999,7 @@ namespace ts {
|
||||
break;
|
||||
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
if ((<ImportEqualsDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference && resolver.isReferencedAliasDeclaration(getOriginalNode(node))) {
|
||||
if ((<ImportEqualsDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference && resolver.isReferencedAliasDeclaration(node)) {
|
||||
// import x = require("mod") where x is referenced
|
||||
externalImports.push(<ImportEqualsDeclaration>node);
|
||||
}
|
||||
@@ -2997,10 +3009,12 @@ 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))) {
|
||||
else if (resolver.isValueAliasDeclaration(node)) {
|
||||
// export { x, y } from "mod" where at least one export is a value symbol
|
||||
externalImports.push(<ExportDeclaration>node);
|
||||
}
|
||||
@@ -3028,7 +3042,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
return { externalImports, exportSpecifiers, exportEquals, hasExportStars };
|
||||
return { externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues };
|
||||
}
|
||||
|
||||
export function getInitializedVariables(node: VariableDeclarationList) {
|
||||
@@ -3402,6 +3416,10 @@ namespace ts {
|
||||
|| kind === SyntaxKind.ModuleDeclaration;
|
||||
}
|
||||
|
||||
export function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration {
|
||||
return node.kind === SyntaxKind.ImportEqualsDeclaration;
|
||||
}
|
||||
|
||||
export function isImportClause(node: Node): node is ImportClause {
|
||||
return node.kind === SyntaxKind.ImportClause;
|
||||
}
|
||||
|
||||
+23
-4
@@ -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;
|
||||
@@ -480,6 +480,8 @@ namespace Harness {
|
||||
getExecutingFilePath(): string;
|
||||
exit(exitCode?: number): void;
|
||||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
tryEnableSourceMapsForHost?(): void;
|
||||
getEnvironmentVariable?(name: string): string;
|
||||
}
|
||||
export var IO: IO;
|
||||
|
||||
@@ -518,6 +520,7 @@ namespace Harness {
|
||||
export const fileExists: typeof IO.fileExists = fso.FileExists;
|
||||
export const log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine;
|
||||
export const readDirectory: typeof IO.readDirectory = (path, extension, exclude) => ts.sys.readDirectory(path, extension, exclude);
|
||||
export const getEnvironmentVariable: typeof IO.getEnvironmentVariable = name => ts.sys.getEnvironmentVariable(name);
|
||||
|
||||
export function createDirectory(path: string) {
|
||||
if (directoryExists(path)) {
|
||||
@@ -587,6 +590,13 @@ namespace Harness {
|
||||
export const log: typeof IO.log = s => console.log(s);
|
||||
|
||||
export const readDirectory: typeof IO.readDirectory = (path, extension, exclude) => ts.sys.readDirectory(path, extension, exclude);
|
||||
export const getEnvironmentVariable: typeof IO.getEnvironmentVariable = name => ts.sys.getEnvironmentVariable(name);
|
||||
|
||||
export function tryEnableSourceMapsForHost() {
|
||||
if (ts.sys.tryEnableSourceMapsForHost) {
|
||||
ts.sys.tryEnableSourceMapsForHost();
|
||||
}
|
||||
}
|
||||
|
||||
export function createDirectory(path: string) {
|
||||
if (!directoryExists(path)) {
|
||||
@@ -741,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);
|
||||
@@ -1681,8 +1700,8 @@ namespace Harness {
|
||||
if (Error) (<any>Error).stackTraceLimit = 1;
|
||||
}
|
||||
|
||||
if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
|
||||
ts.sys.tryEnableSourceMapsForHost();
|
||||
if (Harness.IO.tryEnableSourceMapsForHost && /^development$/i.test(Harness.IO.getEnvironmentVariable("NODE_ENV"))) {
|
||||
Harness.IO.tryEnableSourceMapsForHost();
|
||||
}
|
||||
|
||||
// TODO: not sure why Utils.evalFile isn't working with this, eventually will concat it like old compiler instead of eval
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
+10
-4
@@ -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;
|
||||
}
|
||||
|
||||
+4
-4
@@ -33,8 +33,8 @@ var Point = (function () {
|
||||
}());
|
||||
var Point;
|
||||
(function (Point) {
|
||||
function Origin() { return null; }
|
||||
Point.Origin = Origin; //expected duplicate identifier error
|
||||
function Origin() { return null; } //expected duplicate identifier error
|
||||
Point.Origin = Origin;
|
||||
})(Point || (Point = {}));
|
||||
var A;
|
||||
(function (A) {
|
||||
@@ -49,7 +49,7 @@ var A;
|
||||
A.Point = Point;
|
||||
var Point;
|
||||
(function (Point) {
|
||||
function Origin() { return ""; }
|
||||
Point.Origin = Origin; //expected duplicate identifier error
|
||||
function Origin() { return ""; } //expected duplicate identifier error
|
||||
Point.Origin = Origin;
|
||||
})(Point = A.Point || (A.Point = {}));
|
||||
})(A || (A = {}));
|
||||
|
||||
@@ -5,7 +5,7 @@ function* foo() {
|
||||
}
|
||||
|
||||
//// [YieldExpression3_es6.js]
|
||||
function foo() {
|
||||
function* foo() {
|
||||
yield;
|
||||
yield;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ function* foo() {
|
||||
}
|
||||
|
||||
//// [YieldExpression4_es6.js]
|
||||
function foo() {
|
||||
function* foo() {
|
||||
yield;
|
||||
yield;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ function* foo() {
|
||||
}
|
||||
|
||||
//// [YieldExpression5_es6.js]
|
||||
function foo() {
|
||||
function* foo() {
|
||||
yield* ;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ function* foo() {
|
||||
}
|
||||
|
||||
//// [YieldExpression6_es6.js]
|
||||
function foo() {
|
||||
function* foo() {
|
||||
yield* foo;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ function* foo() {
|
||||
}
|
||||
|
||||
//// [YieldExpression7_es6.js]
|
||||
function foo() {
|
||||
function* foo() {
|
||||
yield foo;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ function* foo() {
|
||||
|
||||
//// [YieldExpression8_es6.js]
|
||||
yield(foo);
|
||||
function foo() {
|
||||
function* foo() {
|
||||
yield (foo);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ var v = function*() {
|
||||
}
|
||||
|
||||
//// [YieldExpression9_es6.js]
|
||||
var v = function () {
|
||||
var v = function* () {
|
||||
yield (foo);
|
||||
};
|
||||
|
||||
@@ -4,6 +4,6 @@ function *g() {
|
||||
}
|
||||
|
||||
//// [YieldStarExpression3_es6.js]
|
||||
function g() {
|
||||
function* g() {
|
||||
yield* ;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ function *g() {
|
||||
}
|
||||
|
||||
//// [YieldStarExpression4_es6.js]
|
||||
function g() {
|
||||
function* g() {
|
||||
yield* [];
|
||||
}
|
||||
|
||||
@@ -29,6 +29,6 @@ var n: number;
|
||||
//// [consumer.js]
|
||||
"use strict";
|
||||
// Ambient external module members are always exported with or without export keyword when module lacks export assignment
|
||||
var imp3 = require('equ2');
|
||||
var imp3 = require("equ2");
|
||||
var n = imp3.x;
|
||||
var n;
|
||||
|
||||
@@ -20,7 +20,7 @@ var c = new A();
|
||||
|
||||
//// [ambientExternalModuleWithInternalImportDeclaration_0.js]
|
||||
//// [ambientExternalModuleWithInternalImportDeclaration_1.js]
|
||||
define(["require", "exports", 'M'], function (require, exports, A) {
|
||||
define(["require", "exports", "M"], function (require, exports, A) {
|
||||
"use strict";
|
||||
var c = new A();
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ var c = new A();
|
||||
|
||||
//// [ambientExternalModuleWithoutInternalImportDeclaration_0.js]
|
||||
//// [ambientExternalModuleWithoutInternalImportDeclaration_1.js]
|
||||
define(["require", "exports", 'M'], function (require, exports, A) {
|
||||
define(["require", "exports", "M"], function (require, exports, A) {
|
||||
"use strict";
|
||||
var c = new A();
|
||||
});
|
||||
|
||||
@@ -40,8 +40,8 @@ define(["require", "exports"], function (require, exports) {
|
||||
}
|
||||
return C1;
|
||||
}());
|
||||
C1.s1 = true;
|
||||
exports.C1 = C1;
|
||||
C1.s1 = true;
|
||||
(function (E1) {
|
||||
E1[E1["A"] = 0] = "A";
|
||||
E1[E1["B"] = 1] = "B";
|
||||
|
||||
@@ -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 = {}));
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
var v = a => <any>{}
|
||||
|
||||
//// [arrowFunctionWithObjectLiteralBody1.js]
|
||||
var v = function (a) { return {}; };
|
||||
var v = function (a) { return ({}); };
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
var v = a => <any><any>{}
|
||||
|
||||
//// [arrowFunctionWithObjectLiteralBody2.js]
|
||||
var v = function (a) { return {}; };
|
||||
var v = function (a) { return ({}); };
|
||||
|
||||
@@ -18,7 +18,7 @@ function foo() { }
|
||||
exports.foo = foo;
|
||||
//// [bar.js]
|
||||
"use strict";
|
||||
var foo_1 = require('./foo');
|
||||
var foo_1 = require("./foo");
|
||||
// These should emit identically
|
||||
foo_1.foo;
|
||||
foo_1.foo;
|
||||
|
||||
@@ -113,7 +113,7 @@ false = value;
|
||||
}
|
||||
value;
|
||||
// array literals
|
||||
'' = value[0], '' = value[1];
|
||||
"" = value[0], "" = value[1];
|
||||
// super
|
||||
var Derived = (function (_super) {
|
||||
__extends(Derived, _super);
|
||||
|
||||
@@ -12,6 +12,6 @@ var M;
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
}());
|
||||
M.C = C; // this should be an unresolved symbol I error
|
||||
}()); // this should be an unresolved symbol I error
|
||||
M.C = C;
|
||||
})(M || (M = {}));
|
||||
|
||||
@@ -48,7 +48,8 @@ var b = {
|
||||
foo: function (x) {
|
||||
if (x === void 0) { x = 1; }
|
||||
},
|
||||
foo: function (x) {
|
||||
foo: // error
|
||||
function (x) {
|
||||
if (x === void 0) { x = 1; }
|
||||
}
|
||||
};
|
||||
|
||||
@@ -114,15 +114,15 @@ for (const y = 0; y < 1;) {
|
||||
}
|
||||
|
||||
//// [capturedLetConstInLoop1.js]
|
||||
//==== let
|
||||
var _loop_1 = function(x) {
|
||||
var _loop_1 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
};
|
||||
//==== let
|
||||
for (var x in {}) {
|
||||
_loop_1(x);
|
||||
}
|
||||
var _loop_2 = function(x) {
|
||||
var _loop_2 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
};
|
||||
@@ -130,14 +130,14 @@ for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
var x = _a[_i];
|
||||
_loop_2(x);
|
||||
}
|
||||
var _loop_3 = function(x) {
|
||||
var _loop_3 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
};
|
||||
for (var x = 0; x < 1; ++x) {
|
||||
_loop_3(x);
|
||||
}
|
||||
var _loop_4 = function() {
|
||||
var _loop_4 = function () {
|
||||
var x;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -145,7 +145,7 @@ var _loop_4 = function() {
|
||||
while (1 === 1) {
|
||||
_loop_4();
|
||||
}
|
||||
var _loop_5 = function() {
|
||||
var _loop_5 = function () {
|
||||
var x;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -153,7 +153,7 @@ var _loop_5 = function() {
|
||||
do {
|
||||
_loop_5();
|
||||
} while (1 === 1);
|
||||
var _loop_6 = function(y) {
|
||||
var _loop_6 = function (y) {
|
||||
var x = 1;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -161,14 +161,14 @@ var _loop_6 = function(y) {
|
||||
for (var y = 0; y < 1; ++y) {
|
||||
_loop_6(y);
|
||||
}
|
||||
var _loop_7 = function(x, y) {
|
||||
var _loop_7 = function (x, y) {
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
};
|
||||
for (var x = 0, y = 1; x < 1; ++x) {
|
||||
_loop_7(x, y);
|
||||
}
|
||||
var _loop_8 = function() {
|
||||
var _loop_8 = function () {
|
||||
var x, y;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -176,7 +176,7 @@ var _loop_8 = function() {
|
||||
while (1 === 1) {
|
||||
_loop_8();
|
||||
}
|
||||
var _loop_9 = function() {
|
||||
var _loop_9 = function () {
|
||||
var x, y;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -184,7 +184,7 @@ var _loop_9 = function() {
|
||||
do {
|
||||
_loop_9();
|
||||
} while (1 === 1);
|
||||
var _loop_10 = function(y) {
|
||||
var _loop_10 = function (y) {
|
||||
var x = 1;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -192,15 +192,15 @@ var _loop_10 = function(y) {
|
||||
for (var y = 0; y < 1; ++y) {
|
||||
_loop_10(y);
|
||||
}
|
||||
//=========const
|
||||
var _loop_11 = function(x) {
|
||||
var _loop_11 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
};
|
||||
//=========const
|
||||
for (var x in {}) {
|
||||
_loop_11(x);
|
||||
}
|
||||
var _loop_12 = function(x) {
|
||||
var _loop_12 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
};
|
||||
@@ -208,14 +208,14 @@ for (var _b = 0, _c = []; _b < _c.length; _b++) {
|
||||
var x = _c[_b];
|
||||
_loop_12(x);
|
||||
}
|
||||
var _loop_13 = function(x) {
|
||||
var _loop_13 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
};
|
||||
for (var x = 0; x < 1;) {
|
||||
_loop_13(x);
|
||||
}
|
||||
var _loop_14 = function() {
|
||||
var _loop_14 = function () {
|
||||
var x = 1;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -223,7 +223,7 @@ var _loop_14 = function() {
|
||||
while (1 === 1) {
|
||||
_loop_14();
|
||||
}
|
||||
var _loop_15 = function() {
|
||||
var _loop_15 = function () {
|
||||
var x = 1;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -231,7 +231,7 @@ var _loop_15 = function() {
|
||||
do {
|
||||
_loop_15();
|
||||
} while (1 === 1);
|
||||
var _loop_16 = function(y) {
|
||||
var _loop_16 = function (y) {
|
||||
var x = 1;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -239,14 +239,14 @@ var _loop_16 = function(y) {
|
||||
for (var y = 0; y < 1;) {
|
||||
_loop_16(y);
|
||||
}
|
||||
var _loop_17 = function(x, y) {
|
||||
var _loop_17 = function (x, y) {
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
};
|
||||
for (var x = 0, y = 1; x < 1;) {
|
||||
_loop_17(x, y);
|
||||
}
|
||||
var _loop_18 = function() {
|
||||
var _loop_18 = function () {
|
||||
var x = 1, y = 1;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -254,7 +254,7 @@ var _loop_18 = function() {
|
||||
while (1 === 1) {
|
||||
_loop_18();
|
||||
}
|
||||
var _loop_19 = function() {
|
||||
var _loop_19 = function () {
|
||||
var x = 1, y = 1;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -262,7 +262,7 @@ var _loop_19 = function() {
|
||||
do {
|
||||
_loop_19();
|
||||
} while (1 === 1);
|
||||
var _loop_20 = function(y) {
|
||||
var _loop_20 = function (y) {
|
||||
var x = 1;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
|
||||
@@ -239,8 +239,7 @@ for (const y = 0; y < 1;) {
|
||||
|
||||
|
||||
//// [capturedLetConstInLoop6.js]
|
||||
// ====let
|
||||
var _loop_1 = function(x) {
|
||||
var _loop_1 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
if (x == 1) {
|
||||
@@ -250,12 +249,14 @@ var _loop_1 = function(x) {
|
||||
return "continue";
|
||||
}
|
||||
};
|
||||
// ====let
|
||||
for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
var x = _a[_i];
|
||||
var state_1 = _loop_1(x);
|
||||
if (state_1 === "break") break;
|
||||
if (state_1 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_2 = function(x) {
|
||||
var _loop_2 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
if (x == "1") {
|
||||
@@ -267,9 +268,10 @@ var _loop_2 = function(x) {
|
||||
};
|
||||
for (var x in []) {
|
||||
var state_2 = _loop_2(x);
|
||||
if (state_2 === "break") break;
|
||||
if (state_2 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_3 = function(x) {
|
||||
var _loop_3 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
if (x == 1) {
|
||||
@@ -281,9 +283,10 @@ var _loop_3 = function(x) {
|
||||
};
|
||||
for (var x = 0; x < 1; ++x) {
|
||||
var state_3 = _loop_3(x);
|
||||
if (state_3 === "break") break;
|
||||
if (state_3 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_4 = function() {
|
||||
var _loop_4 = function () {
|
||||
var x;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -296,9 +299,10 @@ var _loop_4 = function() {
|
||||
};
|
||||
while (1 === 1) {
|
||||
var state_4 = _loop_4();
|
||||
if (state_4 === "break") break;
|
||||
if (state_4 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_5 = function() {
|
||||
var _loop_5 = function () {
|
||||
var x;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -311,9 +315,10 @@ var _loop_5 = function() {
|
||||
};
|
||||
do {
|
||||
var state_5 = _loop_5();
|
||||
if (state_5 === "break") break;
|
||||
if (state_5 === "break")
|
||||
break;
|
||||
} while (1 === 1);
|
||||
var _loop_6 = function(y) {
|
||||
var _loop_6 = function (y) {
|
||||
var x = 1;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -326,9 +331,10 @@ var _loop_6 = function(y) {
|
||||
};
|
||||
for (var y = 0; y < 1; ++y) {
|
||||
var state_6 = _loop_6(y);
|
||||
if (state_6 === "break") break;
|
||||
if (state_6 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_7 = function(x, y) {
|
||||
var _loop_7 = function (x, y) {
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
if (x == 1) {
|
||||
@@ -340,9 +346,10 @@ var _loop_7 = function(x, y) {
|
||||
};
|
||||
for (var x = 0, y = 1; x < 1; ++x) {
|
||||
var state_7 = _loop_7(x, y);
|
||||
if (state_7 === "break") break;
|
||||
if (state_7 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_8 = function() {
|
||||
var _loop_8 = function () {
|
||||
var x, y;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -355,9 +362,10 @@ var _loop_8 = function() {
|
||||
};
|
||||
while (1 === 1) {
|
||||
var state_8 = _loop_8();
|
||||
if (state_8 === "break") break;
|
||||
if (state_8 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_9 = function() {
|
||||
var _loop_9 = function () {
|
||||
var x, y;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -370,9 +378,10 @@ var _loop_9 = function() {
|
||||
};
|
||||
do {
|
||||
var state_9 = _loop_9();
|
||||
if (state_9 === "break") break;
|
||||
if (state_9 === "break")
|
||||
break;
|
||||
} while (1 === 1);
|
||||
var _loop_10 = function(y) {
|
||||
var _loop_10 = function (y) {
|
||||
var x = 1;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -385,10 +394,10 @@ var _loop_10 = function(y) {
|
||||
};
|
||||
for (var y = 0; y < 1; ++y) {
|
||||
var state_10 = _loop_10(y);
|
||||
if (state_10 === "break") break;
|
||||
if (state_10 === "break")
|
||||
break;
|
||||
}
|
||||
// ====const
|
||||
var _loop_11 = function(x) {
|
||||
var _loop_11 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
if (x == 1) {
|
||||
@@ -398,12 +407,14 @@ var _loop_11 = function(x) {
|
||||
return "continue";
|
||||
}
|
||||
};
|
||||
// ====const
|
||||
for (var _b = 0, _c = []; _b < _c.length; _b++) {
|
||||
var x = _c[_b];
|
||||
var state_11 = _loop_11(x);
|
||||
if (state_11 === "break") break;
|
||||
if (state_11 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_12 = function(x) {
|
||||
var _loop_12 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
if (x == "1") {
|
||||
@@ -415,9 +426,10 @@ var _loop_12 = function(x) {
|
||||
};
|
||||
for (var x in []) {
|
||||
var state_12 = _loop_12(x);
|
||||
if (state_12 === "break") break;
|
||||
if (state_12 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_13 = function(x) {
|
||||
var _loop_13 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
if (x == 1) {
|
||||
@@ -429,9 +441,10 @@ var _loop_13 = function(x) {
|
||||
};
|
||||
for (var x = 0; x < 1;) {
|
||||
var state_13 = _loop_13(x);
|
||||
if (state_13 === "break") break;
|
||||
if (state_13 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_14 = function() {
|
||||
var _loop_14 = function () {
|
||||
var x = 1;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -444,9 +457,10 @@ var _loop_14 = function() {
|
||||
};
|
||||
while (1 === 1) {
|
||||
var state_14 = _loop_14();
|
||||
if (state_14 === "break") break;
|
||||
if (state_14 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_15 = function() {
|
||||
var _loop_15 = function () {
|
||||
var x = 1;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -459,9 +473,10 @@ var _loop_15 = function() {
|
||||
};
|
||||
do {
|
||||
var state_15 = _loop_15();
|
||||
if (state_15 === "break") break;
|
||||
if (state_15 === "break")
|
||||
break;
|
||||
} while (1 === 1);
|
||||
var _loop_16 = function(y) {
|
||||
var _loop_16 = function (y) {
|
||||
var x = 1;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -474,9 +489,10 @@ var _loop_16 = function(y) {
|
||||
};
|
||||
for (var y = 0; y < 1;) {
|
||||
var state_16 = _loop_16(y);
|
||||
if (state_16 === "break") break;
|
||||
if (state_16 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_17 = function(x, y) {
|
||||
var _loop_17 = function (x, y) {
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
if (x == 1) {
|
||||
@@ -488,9 +504,10 @@ var _loop_17 = function(x, y) {
|
||||
};
|
||||
for (var x = 0, y = 1; x < 1;) {
|
||||
var state_17 = _loop_17(x, y);
|
||||
if (state_17 === "break") break;
|
||||
if (state_17 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_18 = function() {
|
||||
var _loop_18 = function () {
|
||||
var x = 1, y = 1;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -503,9 +520,10 @@ var _loop_18 = function() {
|
||||
};
|
||||
while (1 === 1) {
|
||||
var state_18 = _loop_18();
|
||||
if (state_18 === "break") break;
|
||||
if (state_18 === "break")
|
||||
break;
|
||||
}
|
||||
var _loop_19 = function() {
|
||||
var _loop_19 = function () {
|
||||
var x = 1, y = 1;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -518,9 +536,10 @@ var _loop_19 = function() {
|
||||
};
|
||||
do {
|
||||
var state_19 = _loop_19();
|
||||
if (state_19 === "break") break;
|
||||
if (state_19 === "break")
|
||||
break;
|
||||
} while (1 === 1);
|
||||
var _loop_20 = function(y) {
|
||||
var _loop_20 = function (y) {
|
||||
var x = 1;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -533,5 +552,6 @@ var _loop_20 = function(y) {
|
||||
};
|
||||
for (var y = 0; y < 1;) {
|
||||
var state_20 = _loop_20(y);
|
||||
if (state_20 === "break") break;
|
||||
if (state_20 === "break")
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -376,8 +376,7 @@ for (const y = 0; y < 1;) {
|
||||
}
|
||||
|
||||
//// [capturedLetConstInLoop7.js]
|
||||
//===let
|
||||
var _loop_1 = function(x) {
|
||||
var _loop_1 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
if (x == 1) {
|
||||
@@ -393,16 +392,18 @@ var _loop_1 = function(x) {
|
||||
return "continue-l0";
|
||||
}
|
||||
};
|
||||
//===let
|
||||
l0: for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
var x = _a[_i];
|
||||
var state_1 = _loop_1(x);
|
||||
if (state_1 === "break") break;
|
||||
switch(state_1) {
|
||||
if (state_1 === "break")
|
||||
break;
|
||||
switch (state_1) {
|
||||
case "break-l0": break l0;
|
||||
case "continue-l0": continue l0;
|
||||
}
|
||||
}
|
||||
var _loop_2 = function(x) {
|
||||
var _loop_2 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
if (x == "1") {
|
||||
@@ -420,13 +421,14 @@ var _loop_2 = function(x) {
|
||||
};
|
||||
l00: for (var x in []) {
|
||||
var state_2 = _loop_2(x);
|
||||
if (state_2 === "break") break;
|
||||
switch(state_2) {
|
||||
if (state_2 === "break")
|
||||
break;
|
||||
switch (state_2) {
|
||||
case "break-l00": break l00;
|
||||
case "continue-l00": continue l00;
|
||||
}
|
||||
}
|
||||
var _loop_3 = function(x) {
|
||||
var _loop_3 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
if (x == 1) {
|
||||
@@ -444,13 +446,14 @@ var _loop_3 = function(x) {
|
||||
};
|
||||
l1: for (var x = 0; x < 1; ++x) {
|
||||
var state_3 = _loop_3(x);
|
||||
if (state_3 === "break") break;
|
||||
switch(state_3) {
|
||||
if (state_3 === "break")
|
||||
break;
|
||||
switch (state_3) {
|
||||
case "break-l1": break l1;
|
||||
case "continue-l1": continue l1;
|
||||
}
|
||||
}
|
||||
var _loop_4 = function() {
|
||||
var _loop_4 = function () {
|
||||
var x;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -469,13 +472,14 @@ var _loop_4 = function() {
|
||||
};
|
||||
l2: while (1 === 1) {
|
||||
var state_4 = _loop_4();
|
||||
if (state_4 === "break") break;
|
||||
switch(state_4) {
|
||||
if (state_4 === "break")
|
||||
break;
|
||||
switch (state_4) {
|
||||
case "break-l2": break l2;
|
||||
case "continue-l2": continue l2;
|
||||
}
|
||||
}
|
||||
var _loop_5 = function() {
|
||||
var _loop_5 = function () {
|
||||
var x;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -494,13 +498,14 @@ var _loop_5 = function() {
|
||||
};
|
||||
l3: do {
|
||||
var state_5 = _loop_5();
|
||||
if (state_5 === "break") break;
|
||||
switch(state_5) {
|
||||
if (state_5 === "break")
|
||||
break;
|
||||
switch (state_5) {
|
||||
case "break-l3": break l3;
|
||||
case "continue-l3": continue l3;
|
||||
}
|
||||
} while (1 === 1);
|
||||
var _loop_6 = function(y) {
|
||||
var _loop_6 = function (y) {
|
||||
var x = 1;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -519,13 +524,14 @@ var _loop_6 = function(y) {
|
||||
};
|
||||
l4: for (var y = 0; y < 1; ++y) {
|
||||
var state_6 = _loop_6(y);
|
||||
if (state_6 === "break") break;
|
||||
switch(state_6) {
|
||||
if (state_6 === "break")
|
||||
break;
|
||||
switch (state_6) {
|
||||
case "break-l4": break l4;
|
||||
case "continue-l4": continue l4;
|
||||
}
|
||||
}
|
||||
var _loop_7 = function(x, y) {
|
||||
var _loop_7 = function (x, y) {
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
if (x == 1) {
|
||||
@@ -543,13 +549,14 @@ var _loop_7 = function(x, y) {
|
||||
};
|
||||
l5: for (var x = 0, y = 1; x < 1; ++x) {
|
||||
var state_7 = _loop_7(x, y);
|
||||
if (state_7 === "break") break;
|
||||
switch(state_7) {
|
||||
if (state_7 === "break")
|
||||
break;
|
||||
switch (state_7) {
|
||||
case "break-l5": break l5;
|
||||
case "continue-l5": continue l5;
|
||||
}
|
||||
}
|
||||
var _loop_8 = function() {
|
||||
var _loop_8 = function () {
|
||||
var x, y;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -568,13 +575,14 @@ var _loop_8 = function() {
|
||||
};
|
||||
l6: while (1 === 1) {
|
||||
var state_8 = _loop_8();
|
||||
if (state_8 === "break") break;
|
||||
switch(state_8) {
|
||||
if (state_8 === "break")
|
||||
break;
|
||||
switch (state_8) {
|
||||
case "break-l6": break l6;
|
||||
case "continue-l6": continue l6;
|
||||
}
|
||||
}
|
||||
var _loop_9 = function() {
|
||||
var _loop_9 = function () {
|
||||
var x, y;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -593,13 +601,14 @@ var _loop_9 = function() {
|
||||
};
|
||||
l7: do {
|
||||
var state_9 = _loop_9();
|
||||
if (state_9 === "break") break;
|
||||
switch(state_9) {
|
||||
if (state_9 === "break")
|
||||
break;
|
||||
switch (state_9) {
|
||||
case "break-l7": break l7;
|
||||
case "continue-l7": continue l7;
|
||||
}
|
||||
} while (1 === 1);
|
||||
var _loop_10 = function(y) {
|
||||
var _loop_10 = function (y) {
|
||||
var x = 1;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -618,14 +627,14 @@ var _loop_10 = function(y) {
|
||||
};
|
||||
l8: for (var y = 0; y < 1; ++y) {
|
||||
var state_10 = _loop_10(y);
|
||||
if (state_10 === "break") break;
|
||||
switch(state_10) {
|
||||
if (state_10 === "break")
|
||||
break;
|
||||
switch (state_10) {
|
||||
case "break-l8": break l8;
|
||||
case "continue-l8": continue l8;
|
||||
}
|
||||
}
|
||||
//===const
|
||||
var _loop_11 = function(x) {
|
||||
var _loop_11 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
if (x == 1) {
|
||||
@@ -641,16 +650,18 @@ var _loop_11 = function(x) {
|
||||
return "continue-l0_c";
|
||||
}
|
||||
};
|
||||
//===const
|
||||
l0_c: for (var _b = 0, _c = []; _b < _c.length; _b++) {
|
||||
var x = _c[_b];
|
||||
var state_11 = _loop_11(x);
|
||||
if (state_11 === "break") break;
|
||||
switch(state_11) {
|
||||
if (state_11 === "break")
|
||||
break;
|
||||
switch (state_11) {
|
||||
case "break-l0_c": break l0_c;
|
||||
case "continue-l0_c": continue l0_c;
|
||||
}
|
||||
}
|
||||
var _loop_12 = function(x) {
|
||||
var _loop_12 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
if (x == "1") {
|
||||
@@ -668,13 +679,14 @@ var _loop_12 = function(x) {
|
||||
};
|
||||
l00_c: for (var x in []) {
|
||||
var state_12 = _loop_12(x);
|
||||
if (state_12 === "break") break;
|
||||
switch(state_12) {
|
||||
if (state_12 === "break")
|
||||
break;
|
||||
switch (state_12) {
|
||||
case "break-l00_c": break l00_c;
|
||||
case "continue-l00_c": continue l00_c;
|
||||
}
|
||||
}
|
||||
var _loop_13 = function(x) {
|
||||
var _loop_13 = function (x) {
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
if (x == 1) {
|
||||
@@ -692,13 +704,14 @@ var _loop_13 = function(x) {
|
||||
};
|
||||
l1_c: for (var x = 0; x < 1;) {
|
||||
var state_13 = _loop_13(x);
|
||||
if (state_13 === "break") break;
|
||||
switch(state_13) {
|
||||
if (state_13 === "break")
|
||||
break;
|
||||
switch (state_13) {
|
||||
case "break-l1_c": break l1_c;
|
||||
case "continue-l1_c": continue l1_c;
|
||||
}
|
||||
}
|
||||
var _loop_14 = function() {
|
||||
var _loop_14 = function () {
|
||||
var x = 1;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -717,13 +730,14 @@ var _loop_14 = function() {
|
||||
};
|
||||
l2_c: while (1 === 1) {
|
||||
var state_14 = _loop_14();
|
||||
if (state_14 === "break") break;
|
||||
switch(state_14) {
|
||||
if (state_14 === "break")
|
||||
break;
|
||||
switch (state_14) {
|
||||
case "break-l2_c": break l2_c;
|
||||
case "continue-l2_c": continue l2_c;
|
||||
}
|
||||
}
|
||||
var _loop_15 = function() {
|
||||
var _loop_15 = function () {
|
||||
var x = 1;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -742,13 +756,14 @@ var _loop_15 = function() {
|
||||
};
|
||||
l3_c: do {
|
||||
var state_15 = _loop_15();
|
||||
if (state_15 === "break") break;
|
||||
switch(state_15) {
|
||||
if (state_15 === "break")
|
||||
break;
|
||||
switch (state_15) {
|
||||
case "break-l3_c": break l3_c;
|
||||
case "continue-l3_c": continue l3_c;
|
||||
}
|
||||
} while (1 === 1);
|
||||
var _loop_16 = function(y) {
|
||||
var _loop_16 = function (y) {
|
||||
var x = 1;
|
||||
(function () { return x; });
|
||||
(function () { return x; });
|
||||
@@ -767,13 +782,14 @@ var _loop_16 = function(y) {
|
||||
};
|
||||
l4_c: for (var y = 0; y < 1;) {
|
||||
var state_16 = _loop_16(y);
|
||||
if (state_16 === "break") break;
|
||||
switch(state_16) {
|
||||
if (state_16 === "break")
|
||||
break;
|
||||
switch (state_16) {
|
||||
case "break-l4_c": break l4_c;
|
||||
case "continue-l4_c": continue l4_c;
|
||||
}
|
||||
}
|
||||
var _loop_17 = function(x, y) {
|
||||
var _loop_17 = function (x, y) {
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
if (x == 1) {
|
||||
@@ -791,13 +807,14 @@ var _loop_17 = function(x, y) {
|
||||
};
|
||||
l5_c: for (var x = 0, y = 1; x < 1;) {
|
||||
var state_17 = _loop_17(x, y);
|
||||
if (state_17 === "break") break;
|
||||
switch(state_17) {
|
||||
if (state_17 === "break")
|
||||
break;
|
||||
switch (state_17) {
|
||||
case "break-l5_c": break l5_c;
|
||||
case "continue-l5_c": continue l5_c;
|
||||
}
|
||||
}
|
||||
var _loop_18 = function() {
|
||||
var _loop_18 = function () {
|
||||
var x = 1, y = 1;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -816,13 +833,14 @@ var _loop_18 = function() {
|
||||
};
|
||||
l6_c: while (1 === 1) {
|
||||
var state_18 = _loop_18();
|
||||
if (state_18 === "break") break;
|
||||
switch(state_18) {
|
||||
if (state_18 === "break")
|
||||
break;
|
||||
switch (state_18) {
|
||||
case "break-l6_c": break l6_c;
|
||||
case "continue-l6_c": continue l6_c;
|
||||
}
|
||||
}
|
||||
var _loop_19 = function() {
|
||||
var _loop_19 = function () {
|
||||
var x = 1, y = 1;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -841,13 +859,14 @@ var _loop_19 = function() {
|
||||
};
|
||||
l7_c: do {
|
||||
var state_19 = _loop_19();
|
||||
if (state_19 === "break") break;
|
||||
switch(state_19) {
|
||||
if (state_19 === "break")
|
||||
break;
|
||||
switch (state_19) {
|
||||
case "break-l7_c": break l7_c;
|
||||
case "continue-l7_c": continue l7_c;
|
||||
}
|
||||
} while (1 === 1);
|
||||
var _loop_20 = function(y) {
|
||||
var _loop_20 = function (y) {
|
||||
var x = 1;
|
||||
(function () { return x + y; });
|
||||
(function () { return x + y; });
|
||||
@@ -866,8 +885,9 @@ var _loop_20 = function(y) {
|
||||
};
|
||||
l8_c: for (var y = 0; y < 1;) {
|
||||
var state_20 = _loop_20(y);
|
||||
if (state_20 === "break") break;
|
||||
switch(state_20) {
|
||||
if (state_20 === "break")
|
||||
break;
|
||||
switch (state_20) {
|
||||
case "break-l8_c": break l8_c;
|
||||
case "continue-l8_c": continue l8_c;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ new (<any>A());
|
||||
//// [castExpressionParentheses.js]
|
||||
// parentheses should be omitted
|
||||
// literals
|
||||
{ a: 0 };
|
||||
({ a: 0 });
|
||||
[1, 3,];
|
||||
"string";
|
||||
23.0;
|
||||
|
||||
@@ -20,6 +20,6 @@ var m;
|
||||
})(m = exports.m || (exports.m = {}));
|
||||
//// [chainedImportAlias_file1.js]
|
||||
"use strict";
|
||||
var x = require('./chainedImportAlias_file0');
|
||||
var x = require("./chainedImportAlias_file0");
|
||||
var y = x;
|
||||
y.m.foo();
|
||||
|
||||
@@ -35,7 +35,7 @@ export module M1 {
|
||||
|
||||
//// [foo1.js]
|
||||
"use strict";
|
||||
var foo2 = require('./foo2');
|
||||
var foo2 = require("./foo2");
|
||||
var M1;
|
||||
(function (M1) {
|
||||
var C1 = (function () {
|
||||
@@ -50,7 +50,7 @@ var M1;
|
||||
})(M1 = exports.M1 || (exports.M1 = {}));
|
||||
//// [foo2.js]
|
||||
"use strict";
|
||||
var foo1 = require('./foo1');
|
||||
var foo1 = require("./foo1");
|
||||
var M1;
|
||||
(function (M1) {
|
||||
var C1 = (function () {
|
||||
|
||||
@@ -26,7 +26,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 a_1 = require('./a');
|
||||
var a_1 = require("./a");
|
||||
exports.b = {
|
||||
f: function () {
|
||||
var A = (function () {
|
||||
@@ -51,7 +51,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 b_1 = require('./b');
|
||||
var b_1 = require("./b");
|
||||
exports.a = {
|
||||
f: function () {
|
||||
var A = (function () {
|
||||
|
||||
@@ -32,7 +32,7 @@ define(["require", "exports"], function (require, exports) {
|
||||
exports.bar2 = bar2;
|
||||
});
|
||||
//// [collisionExportsRequireAndAlias_file2.js]
|
||||
define(["require", "exports", 'collisionExportsRequireAndAlias_file1', 'collisionExportsRequireAndAlias_file3333'], function (require, exports, require, exports) {
|
||||
define(["require", "exports", "collisionExportsRequireAndAlias_file1", "collisionExportsRequireAndAlias_file3333"], function (require, exports, require, exports) {
|
||||
"use strict";
|
||||
function foo() {
|
||||
require.bar();
|
||||
|
||||
@@ -84,7 +84,7 @@ function blah(a /* multiline trailing comment
|
||||
function blah2(a /* single line multiple trailing comments */ /* second */) {
|
||||
}
|
||||
function blah3(a // trailing commen single line
|
||||
) {
|
||||
) {
|
||||
}
|
||||
lambdaFoo = function (a, b) { return a * b; }; // This is trailing comment
|
||||
/*leading comment*/ (function () { return 0; }); // Needs to be wrapped in parens to be a valid expression (not declaration)
|
||||
|
||||
@@ -21,8 +21,8 @@ var C1 = (function () {
|
||||
}
|
||||
return C1;
|
||||
}());
|
||||
C1.s1 = true;
|
||||
exports.C1 = C1;
|
||||
C1.s1 = true;
|
||||
//// [foo_1.js]
|
||||
"use strict";
|
||||
var foo = require("./foo_0");
|
||||
|
||||
@@ -39,8 +39,8 @@ var C1 = (function () {
|
||||
}
|
||||
return C1;
|
||||
}());
|
||||
C1.s1 = true;
|
||||
exports.C1 = C1;
|
||||
C1.s1 = true;
|
||||
(function (E1) {
|
||||
E1[E1["A"] = 0] = "A";
|
||||
E1[E1["B"] = 1] = "B";
|
||||
|
||||
@@ -16,7 +16,7 @@ function Foo() { }
|
||||
exports.Foo = Foo;
|
||||
//// [main.js]
|
||||
"use strict";
|
||||
var _10_lib_1 = require('./10_lib');
|
||||
var _10_lib_1 = require("./10_lib");
|
||||
_10_lib_1.Foo();
|
||||
|
||||
|
||||
|
||||
@@ -46,6 +46,16 @@ var v = (_a = {},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, "", {
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, 0, {
|
||||
get: function () { return 0; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, a, {
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
|
||||
@@ -18,7 +18,8 @@ var C = (function () {
|
||||
var _this = this;
|
||||
(function () {
|
||||
var obj = (_a = {},
|
||||
_a[_this.bar()] = function () { },
|
||||
_a[_this.bar()] = function () { } // needs capture
|
||||
,
|
||||
_a);
|
||||
var _a;
|
||||
});
|
||||
|
||||
@@ -38,7 +38,8 @@ var C = (function (_super) {
|
||||
var _this = this;
|
||||
(function () {
|
||||
var obj = (_a = {},
|
||||
_a[_super.prototype.bar.call(_this)] = function () { },
|
||||
_a[_super.prototype.bar.call(_this)] = function () { } // needs capture
|
||||
,
|
||||
_a);
|
||||
var _a;
|
||||
});
|
||||
|
||||
@@ -54,7 +54,7 @@ define(["require", "exports"], function (require, exports) {
|
||||
exports.x = 0;
|
||||
});
|
||||
//// [constDeclarations_access_2.js]
|
||||
define(["require", "exports", 'constDeclarations_access_1'], function (require, exports, m) {
|
||||
define(["require", "exports", "constDeclarations_access_1"], function (require, exports, m) {
|
||||
"use strict";
|
||||
// Errors
|
||||
m.x = 1;
|
||||
|
||||
@@ -6,7 +6,7 @@ class foo {
|
||||
|
||||
//// [constructorArgsErrors1.js]
|
||||
var foo = (function () {
|
||||
function foo(a) {
|
||||
function foo(static a) {
|
||||
}
|
||||
return foo;
|
||||
}());
|
||||
|
||||
@@ -7,7 +7,7 @@ class foo {
|
||||
|
||||
//// [constructorArgsErrors5.js]
|
||||
var foo = (function () {
|
||||
function foo(a) {
|
||||
function foo(export a) {
|
||||
}
|
||||
return foo;
|
||||
}());
|
||||
|
||||
@@ -61,7 +61,7 @@ function getFoo1() {
|
||||
}());
|
||||
}
|
||||
function getFoo2() {
|
||||
return (_a = (function () {
|
||||
return _a = (function () {
|
||||
function class_2() {
|
||||
}
|
||||
return class_2;
|
||||
@@ -72,11 +72,11 @@ function getFoo2() {
|
||||
_a.method2 = function (arg) {
|
||||
arg.strProp = "hello";
|
||||
},
|
||||
_a);
|
||||
_a;
|
||||
var _a;
|
||||
}
|
||||
function getFoo3() {
|
||||
return (_a = (function () {
|
||||
return _a = (function () {
|
||||
function class_3() {
|
||||
}
|
||||
return class_3;
|
||||
@@ -87,6 +87,6 @@ function getFoo3() {
|
||||
_a.method2 = function (arg) {
|
||||
arg.strProp = "hello";
|
||||
},
|
||||
_a);
|
||||
_a;
|
||||
var _a;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ var z = b.x;
|
||||
//// [declFileForExportedImport_1.js]
|
||||
"use strict";
|
||||
///<reference path='declFileForExportedImport_0.ts'/>
|
||||
exports.a = require('./declFileForExportedImport_0');
|
||||
exports.a = require("./declFileForExportedImport_0");
|
||||
var y = exports.a.x;
|
||||
exports.b = exports.a;
|
||||
var z = exports.b.x;
|
||||
|
||||
@@ -10,6 +10,7 @@ export default {
|
||||
//// [declarationEmit_inferedDefaultExportType.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
// test.ts
|
||||
exports["default"] = {
|
||||
foo: [],
|
||||
bar: undefined,
|
||||
|
||||
@@ -10,5 +10,5 @@ export type MyClass = typeof myClass;
|
||||
//// [declarationEmit_invalidExport.js]
|
||||
"use strict";
|
||||
if (false) {
|
||||
exports.myClass = 0;
|
||||
export var myClass = 0;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ var f;
|
||||
module.exports = f;
|
||||
//// [declarationEmit_nameConflicts_0.js]
|
||||
"use strict";
|
||||
var im = require('./declarationEmit_nameConflicts_1');
|
||||
var im = require("./declarationEmit_nameConflicts_1");
|
||||
var M;
|
||||
(function (M) {
|
||||
function f() { }
|
||||
|
||||
@@ -13,19 +13,19 @@ var decorator: ClassDecorator;
|
||||
export default class {}
|
||||
|
||||
//// [a.js]
|
||||
System.register([], function(exports_1, context_1) {
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var decorator, Foo;
|
||||
return {
|
||||
setters:[],
|
||||
execute: function() {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
Foo = class Foo {
|
||||
};
|
||||
Foo = __decorate([
|
||||
@@ -33,22 +33,22 @@ System.register([], function(exports_1, context_1) {
|
||||
], Foo);
|
||||
exports_1("default", Foo);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
//// [b.js]
|
||||
System.register([], function(exports_1, context_1) {
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var decorator, default_1;
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var decorator, default_1_1;
|
||||
return {
|
||||
setters:[],
|
||||
execute: function() {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
default_1 = class {
|
||||
};
|
||||
default_1 = __decorate([
|
||||
@@ -56,5 +56,5 @@ System.register([], function(exports_1, context_1) {
|
||||
], default_1);
|
||||
exports_1("default", default_1);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var a_1 = require('./a');
|
||||
var a_1 = require("./a");
|
||||
function filter(handler) {
|
||||
return function (target, propertyKey) {
|
||||
// ...
|
||||
|
||||
@@ -33,8 +33,8 @@ var B = (function () {
|
||||
}
|
||||
return B;
|
||||
}());
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata('design:type', Object)
|
||||
], B.prototype, "x", void 0);
|
||||
exports.B = B;
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata("design:type", Object)
|
||||
], B.prototype, "x", void 0);
|
||||
|
||||
@@ -33,8 +33,8 @@ var B = (function () {
|
||||
}
|
||||
return B;
|
||||
}());
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata('design:type', A)
|
||||
], B.prototype, "x", void 0);
|
||||
exports.B = B;
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata("design:type", A)
|
||||
], B.prototype, "x", void 0);
|
||||
|
||||
@@ -35,7 +35,7 @@ var db = (function () {
|
||||
exports.db = db;
|
||||
//// [service.js]
|
||||
"use strict";
|
||||
var db_1 = require('./db');
|
||||
var db_1 = require("./db");
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ var MyClass = (function () {
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata('design:paramtypes', [db_1.db])
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db_1.db])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@@ -35,7 +35,7 @@ var db = (function () {
|
||||
exports.db = db;
|
||||
//// [service.js]
|
||||
"use strict";
|
||||
var db_1 = require('./db');
|
||||
var db_1 = require("./db");
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ var MyClass = (function () {
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata('design:paramtypes', [db_1.db])
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db_1.db])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@@ -35,7 +35,7 @@ var db = (function () {
|
||||
exports.db = db;
|
||||
//// [service.js]
|
||||
"use strict";
|
||||
var db = require('./db');
|
||||
var db = require("./db");
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ var MyClass = (function () {
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata('design:paramtypes', [db.db])
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db.db])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@@ -35,7 +35,7 @@ var db = (function () {
|
||||
exports.db = db;
|
||||
//// [service.js]
|
||||
"use strict";
|
||||
var db_1 = require('./db'); // error no default export
|
||||
var db_1 = require("./db"); // error no default export
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ var MyClass = (function () {
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata('design:paramtypes', [Object])
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = db;
|
||||
//// [service.js]
|
||||
"use strict";
|
||||
var db_1 = require('./db');
|
||||
var db_1 = require("./db");
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ var MyClass = (function () {
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata('design:paramtypes', [db_1.default])
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db_1.default])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = db;
|
||||
//// [service.js]
|
||||
"use strict";
|
||||
var db_1 = require('./db');
|
||||
var db_1 = require("./db");
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ var MyClass = (function () {
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata('design:paramtypes', [db_1.default])
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db_1.default])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = db;
|
||||
//// [service.js]
|
||||
"use strict";
|
||||
var db_1 = require('./db');
|
||||
var db_1 = require("./db");
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ var MyClass = (function () {
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata('design:paramtypes', [Object])
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@@ -35,7 +35,7 @@ var db = (function () {
|
||||
exports.db = db;
|
||||
//// [service.js]
|
||||
"use strict";
|
||||
var database = require('./db');
|
||||
var database = require("./db");
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ var MyClass = (function () {
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata('design:paramtypes', [database.db])
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [database.db])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@@ -21,7 +21,7 @@ define(["require", "exports"], function (require, exports) {
|
||||
exports.A = A;
|
||||
});
|
||||
//// [B.js]
|
||||
define(["require", "exports", 'A'], function (require, exports, a) {
|
||||
define(["require", "exports", "A"], function (require, exports, a) {
|
||||
"use strict";
|
||||
var A = a.A;
|
||||
return A;
|
||||
|
||||
@@ -32,10 +32,17 @@ function a(_a) {
|
||||
function a1(_a) {
|
||||
var public = _a.public;
|
||||
}
|
||||
function a4(_a) { }
|
||||
while (, )
|
||||
for (, public; ; )
|
||||
;
|
||||
{ }
|
||||
function a5() {
|
||||
var = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
while () { }
|
||||
function a6() {
|
||||
var public = [];
|
||||
|
||||
@@ -73,8 +73,8 @@ var M;
|
||||
function f() {
|
||||
}
|
||||
return f;
|
||||
}());
|
||||
M.f = f; // error
|
||||
}()); // error
|
||||
M.f = f;
|
||||
})(M || (M = {}));
|
||||
var M;
|
||||
(function (M) {
|
||||
@@ -86,8 +86,8 @@ var M;
|
||||
function g() {
|
||||
}
|
||||
return g;
|
||||
}());
|
||||
M.g = g; // no error
|
||||
}()); // no error
|
||||
M.g = g;
|
||||
})(M || (M = {}));
|
||||
var M;
|
||||
(function (M) {
|
||||
|
||||
@@ -92,8 +92,8 @@ define(["require", "exports"], function (require, exports) {
|
||||
(function (F) {
|
||||
var t;
|
||||
})(F || (F = {}));
|
||||
function F() { }
|
||||
M.F = F; // Only one error for duplicate identifier (don't consider visibility)
|
||||
function F() { } // Only one error for duplicate identifier (don't consider visibility)
|
||||
M.F = F;
|
||||
})(M || (M = {}));
|
||||
var M;
|
||||
(function (M) {
|
||||
|
||||
@@ -23,8 +23,8 @@ exports.main = 10;
|
||||
exports.main = 10;
|
||||
//// [elidingImportNames_test.js]
|
||||
"use strict";
|
||||
var a = require('./elidingImportNames_main'); // alias used in typeof
|
||||
var a = require("./elidingImportNames_main"); // alias used in typeof
|
||||
var b = a;
|
||||
var x;
|
||||
var a2 = require('./elidingImportNames_main1'); // alias not used in typeof
|
||||
var a2 = require("./elidingImportNames_main1"); // alias not used in typeof
|
||||
var b2 = a2;
|
||||
|
||||
@@ -41,9 +41,9 @@ var b = function () {
|
||||
};
|
||||
};
|
||||
function baz() {
|
||||
(() => {
|
||||
() => {
|
||||
var arg = arguments[0];
|
||||
});
|
||||
};
|
||||
}
|
||||
function foo(inputFunc) { }
|
||||
foo(() => {
|
||||
@@ -52,8 +52,8 @@ foo(() => {
|
||||
function bar() {
|
||||
var arg = arguments[0]; // no error
|
||||
}
|
||||
(() => {
|
||||
() => {
|
||||
function foo() {
|
||||
var arg = arguments[0]; // no error
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -17,10 +17,10 @@ function foo() {
|
||||
globalCounter += 1;
|
||||
return { 0: 2 };
|
||||
}
|
||||
(_a = foo(), _a[0] = Math.pow(_a[0], foo()[0]));
|
||||
var result_foo1 = (_b = foo(), _b[0] = Math.pow(_b[0], foo()[0]));
|
||||
(_c = foo(), _c[0] = Math.pow(_c[0], (_d = foo(), _d[0] = Math.pow(_d[0], 2))));
|
||||
var result_foo2 = (_e = foo(), _e[0] = Math.pow(_e[0], (_f = foo(), _f[0] = Math.pow(_f[0], 2))));
|
||||
(_g = foo(), _g[0] = Math.pow(_g[0], Math.pow(foo()[0], 2)));
|
||||
var result_foo3 = (_h = foo(), _h[0] = Math.pow(_h[0], Math.pow(foo()[0], 2)));
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h;
|
||||
(_a = foo())[_b = 0] = Math.pow(_a[_b], foo()[0]);
|
||||
var result_foo1 = (_c = foo())[_d = 0] = Math.pow(_c[_d], foo()[0]);
|
||||
(_e = foo())[_f = 0] = Math.pow(_e[_f], (_g = foo())[_h = 0] = Math.pow(_g[_h], 2));
|
||||
var result_foo2 = (_j = foo())[_k = 0] = Math.pow(_j[_k], (_l = foo())[_m = 0] = Math.pow(_l[_m], 2));
|
||||
(_o = foo())[_p = 0] = Math.pow(_o[_p], Math.pow(foo()[0], 2));
|
||||
var result_foo3 = (_q = foo())[_r = 0] = Math.pow(_q[_r], Math.pow(foo()[0], 2));
|
||||
var _a, _b, _c, _d, _g, _h, _e, _f, _l, _m, _j, _k, _o, _p, _q, _r;
|
||||
|
||||
@@ -23,7 +23,7 @@ var object = {
|
||||
this._0 = x;
|
||||
},
|
||||
};
|
||||
(_a = object, _a[0] = Math.pow(_a[0], object[0]));
|
||||
(_b = object, _b[0] = Math.pow(_b[0], (_c = object, _c[0] = Math.pow(_c[0], 2))));
|
||||
(_d = object, _d[0] = Math.pow(_d[0], Math.pow(object[0], 2)));
|
||||
var _a, _b, _c, _d;
|
||||
(_a = object)[_b = 0] = Math.pow(_a[_b], object[0]);
|
||||
(_c = object)[_d = 0] = Math.pow(_c[_d], (_e = object)[_f = 0] = Math.pow(_e[_f], 2));
|
||||
(_g = object)[_h = 0] = Math.pow(_g[_h], Math.pow(object[0], 2));
|
||||
var _a, _b, _e, _f, _c, _d, _g, _h;
|
||||
|
||||
@@ -16,14 +16,12 @@ class D {
|
||||
|
||||
//// [emitRestParametersMethodES6.js]
|
||||
class C {
|
||||
constructor(name, ...rest) {
|
||||
}
|
||||
constructor(name, ...rest) { }
|
||||
bar(...rest) { }
|
||||
foo(x, ...rest) { }
|
||||
}
|
||||
class D {
|
||||
constructor(...rest) {
|
||||
}
|
||||
constructor(...rest) { }
|
||||
bar(...rest) { }
|
||||
foo(x, ...rest) { }
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -9,8 +9,8 @@ let x, y, z, a1, a2, a3;
|
||||
//// [emptyAssignmentPatterns02_ES5.js]
|
||||
var a;
|
||||
var x, y, z, a1, a2, a3;
|
||||
((x = a.x, y = a.y, z = a.z, a));
|
||||
((a1 = a[0], a2 = a[1], a3 = a[2], a));
|
||||
(x = a.x, y = a.y, z = a.z, a);
|
||||
(a1 = a[0], a2 = a[1], a3 = a[2], a);
|
||||
|
||||
|
||||
//// [emptyAssignmentPatterns02_ES5.d.ts]
|
||||
|
||||
@@ -7,8 +7,8 @@ var a: any;
|
||||
|
||||
//// [emptyAssignmentPatterns03_ES5.js]
|
||||
var a;
|
||||
(a);
|
||||
(a);
|
||||
({} = a);
|
||||
([] = a);
|
||||
|
||||
|
||||
//// [emptyAssignmentPatterns03_ES5.d.ts]
|
||||
|
||||
@@ -9,8 +9,8 @@ let x, y, z, a1, a2, a3;
|
||||
//// [emptyAssignmentPatterns04_ES5.js]
|
||||
var a;
|
||||
var x, y, z, a1, a2, a3;
|
||||
(_a = a, x = _a.x, y = _a.y, z = _a.z, _a);
|
||||
(_b = a, a1 = _b[0], a2 = _b[1], a3 = _b[2], _b);
|
||||
(_a = {} = a, x = _a.x, y = _a.y, z = _a.z, _a);
|
||||
(_b = [] = a, a1 = _b[0], a2 = _b[1], a3 = _b[2], _b);
|
||||
var _a, _b;
|
||||
|
||||
|
||||
|
||||
@@ -19,5 +19,5 @@ var Mode = exports.Mode;
|
||||
//// [enumFromExternalModule_1.js]
|
||||
"use strict";
|
||||
///<reference path='enumFromExternalModule_0.ts'/>
|
||||
var f = require('./enumFromExternalModule_0');
|
||||
var f = require("./enumFromExternalModule_0");
|
||||
var x = f.Mode.Open;
|
||||
|
||||
@@ -10,9 +10,9 @@ enum Nums {
|
||||
//// [enumIdentifierLiterals.js]
|
||||
var Nums;
|
||||
(function (Nums) {
|
||||
Nums[Nums["1"] = 0] = "1";
|
||||
Nums[Nums["1.1"] = 1] = "1.1";
|
||||
Nums[Nums["1.2"] = 2] = "1.2";
|
||||
Nums[Nums[1] = 0] = 1;
|
||||
Nums[Nums[1.1] = 1] = 1.1;
|
||||
Nums[Nums[1.2] = 2] = 1.2;
|
||||
Nums[Nums["13e-1"] = 3] = "13e-1";
|
||||
Nums[Nums["61453"] = 4] = "61453";
|
||||
Nums[Nums[61453] = 4] = 61453;
|
||||
})(Nums || (Nums = {}));
|
||||
|
||||
@@ -6,9 +6,13 @@ tests/cases/compiler/es5ModuleInternalNamedImports.ts(27,5): error TS1194: Expor
|
||||
tests/cases/compiler/es5ModuleInternalNamedImports.ts(28,5): error TS1194: Export declarations are not permitted in a namespace.
|
||||
tests/cases/compiler/es5ModuleInternalNamedImports.ts(29,5): error TS1194: Export declarations are not permitted in a namespace.
|
||||
tests/cases/compiler/es5ModuleInternalNamedImports.ts(30,5): error TS1194: Export declarations are not permitted in a namespace.
|
||||
tests/cases/compiler/es5ModuleInternalNamedImports.ts(31,25): error TS1147: Import declarations in a namespace cannot reference a module.
|
||||
tests/cases/compiler/es5ModuleInternalNamedImports.ts(32,20): error TS1147: Import declarations in a namespace cannot reference a module.
|
||||
tests/cases/compiler/es5ModuleInternalNamedImports.ts(33,32): error TS1147: Import declarations in a namespace cannot reference a module.
|
||||
tests/cases/compiler/es5ModuleInternalNamedImports.ts(35,16): error TS2307: Cannot find module 'M3'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/es5ModuleInternalNamedImports.ts (8 errors) ====
|
||||
==== tests/cases/compiler/es5ModuleInternalNamedImports.ts (12 errors) ====
|
||||
|
||||
export module M {
|
||||
// variable
|
||||
@@ -55,5 +59,17 @@ tests/cases/compiler/es5ModuleInternalNamedImports.ts(30,5): error TS1194: Expor
|
||||
export {M_A as a};
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1194: Export declarations are not permitted in a namespace.
|
||||
import * as M2 from "M2";
|
||||
~~~~
|
||||
!!! error TS1147: Import declarations in a namespace cannot reference a module.
|
||||
import M4 from "M4";
|
||||
~~~~
|
||||
!!! error TS1147: Import declarations in a namespace cannot reference a module.
|
||||
export import M5 = require("M5");
|
||||
~~~~
|
||||
!!! error TS1147: Import declarations in a namespace cannot reference a module.
|
||||
}
|
||||
import M3 from "M3";
|
||||
~~~~
|
||||
!!! error TS2307: Cannot find module 'M3'.
|
||||
|
||||
@@ -29,7 +29,11 @@ export module M {
|
||||
export {M_F as f};
|
||||
export {M_E as e};
|
||||
export {M_A as a};
|
||||
import * as M2 from "M2";
|
||||
import M4 from "M4";
|
||||
export import M5 = require("M5");
|
||||
}
|
||||
import M3 from "M3";
|
||||
|
||||
|
||||
//// [es5ModuleInternalNamedImports.js]
|
||||
@@ -60,6 +64,5 @@ define(["require", "exports"], function (require, exports) {
|
||||
var M_E = M.M_E;
|
||||
// alias
|
||||
M.M_A = M_M;
|
||||
// Reexports
|
||||
})(M = exports.M || (exports.M = {}));
|
||||
});
|
||||
|
||||
@@ -7,7 +7,6 @@ export = f;
|
||||
|
||||
//// [es6ExportEquals.js]
|
||||
export function f() { }
|
||||
export = f;
|
||||
|
||||
|
||||
//// [es6ExportEquals.d.ts]
|
||||
|
||||
@@ -55,11 +55,4 @@ export var M;
|
||||
var M_E = M.M_E;
|
||||
// alias
|
||||
M.M_A = M_M;
|
||||
// Reexports
|
||||
export { M_V as v };
|
||||
export { M_C as c };
|
||||
export { M_M as m };
|
||||
export { M_F as f };
|
||||
export { M_E as e };
|
||||
export { M_A as a };
|
||||
})(M || (M = {}));
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user