Merge branch 'ts-master' into constructorAccessibility

Conflicts:
	src/compiler/checker.ts
This commit is contained in:
AbubakerB
2016-02-12 23:35:22 +00:00
305 changed files with 5986 additions and 1276 deletions
+3 -3
View File
@@ -28,9 +28,9 @@ build.json
*.actual
tests/webhost/*.d.ts
tests/webhost/webtsc.js
tests/*.js
tests/*.js.map
tests/*.d.ts
tests/**/*.js
tests/**/*.js.map
tests/**/*.d.ts
*.config
scripts/debug.bat
scripts/run.bat
+1 -1
View File
@@ -13,7 +13,7 @@ Issues that ask questions answered in the FAQ will be closed without elaboration
## 3. Do you have a question?
The issue tracker is for **issues**, in other words, bugs and suggestions.
If you have a *question*, please use [http://stackoverflow.com/questions/tagged/typescript](Stack Overflow), [https://gitter.im/Microsoft/TypeScript](Gitter), your favorite search engine, or other resources.
If you have a *question*, please use [Stack Overflow](http://stackoverflow.com/questions/tagged/typescript), [Gitter](https://gitter.im/Microsoft/TypeScript), your favorite search engine, or other resources.
Due to increased traffic, we can no longer answer questions in the issue tracker.
## 4. Did you find a bug?
+41 -34
View File
@@ -223,51 +223,59 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
* @param prereqs: prerequisite tasks to compiling the file
* @param prefixes: a list of files to prepend to the target file
* @param useBuiltCompiler: true to use the built compiler, false to use the LKG
* @param noOutFile: true to compile without using --out
* @param generateDeclarations: true to compile using --declaration
* @param outDir: true to compile using --outDir
* @param keepComments: false to compile using --removeComments
* @parap {Object} opts - property bag containing auxiliary options
* @param {boolean} opts.noOutFile: true to compile without using --out
* @param {boolean} opts.generateDeclarations: true to compile using --declaration
* @param {string} opts.outDir: value for '--outDir' command line option
* @param {boolean} opts.keepComments: false to compile using --removeComments
* @param {boolean} opts.preserveConstEnums: true if compiler should keep const enums in code
* @param {boolean} opts.noResolve: true if compiler should not include non-rooted files in compilation
* @param {boolean} opts.stripInternal: true if compiler should remove declarations marked as @internal
* @param {boolean} opts.noMapRoot: true if compiler omit mapRoot option
* @param callback: a function to execute after the compilation process ends
*/
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) {
file(outFile, prereqs, function() {
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
var options = "--noImplicitAny --noEmitOnError --pretty";
opts = opts || {};
// Keep comments when specifically requested
// or when in debug mode.
if (!(keepComments || useDebugMode)) {
if (!(opts.keepComments || useDebugMode)) {
options += " --removeComments";
}
if (generateDeclarations) {
if (opts.generateDeclarations) {
options += " --declaration";
}
if (preserveConstEnums || useDebugMode) {
if (opts.preserveConstEnums || useDebugMode) {
options += " --preserveConstEnums";
}
if (outDir) {
options += " --outDir " + outDir;
if (opts.outDir) {
options += " --outDir " + opts.outDir;
}
if (!noOutFile) {
if (!opts.noOutFile) {
options += " --out " + outFile;
}
else {
options += " --module commonjs"
}
if(noResolve) {
if(opts.noResolve) {
options += " --noResolve";
}
if (useDebugMode) {
options += " -sourcemap -mapRoot file:///" + path.resolve(path.dirname(outFile));
options += " -sourcemap";
if (!opts.noMapRoot) {
options += " -mapRoot file:///" + path.resolve(path.dirname(outFile));
}
}
if (stripInternal) {
if (opts.stripInternal) {
options += " --stripInternal"
}
@@ -382,13 +390,7 @@ compileFile(/*outfile*/configureNightlyJs,
/*prereqs*/ [configureNightlyTs],
/*prefixes*/ [],
/*useBuiltCompiler*/ false,
/*noOutFile*/ false,
/*generateDeclarations*/ false,
/*outDir*/ undefined,
/*preserveConstEnums*/ undefined,
/*keepComments*/ false,
/*noResolve*/ false,
/*stripInternal*/ false);
{ noOutFile: false, generateDeclarations: false, keepComments: false, noResolve: false, stripInternal: false });
task("setDebugMode", function() {
useDebugMode = true;
@@ -438,6 +440,7 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
var servicesFileInBrowserTest = path.join(builtLocalDirectory, "typescriptServicesInBrowserTest.js");
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
var nodePackageFile = path.join(builtLocalDirectory, "typescript.js");
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
@@ -446,13 +449,7 @@ var nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_s
compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
/*prefixes*/ [copyright],
/*useBuiltCompiler*/ true,
/*noOutFile*/ false,
/*generateDeclarations*/ true,
/*outDir*/ undefined,
/*preserveConstEnums*/ true,
/*keepComments*/ true,
/*noResolve*/ false,
/*stripInternal*/ true,
{ noOutFile: false, generateDeclarations: true, preserveConstEnums: true, keepComments: true, noResolve: false, stripInternal: true },
/*callback*/ function () {
jake.cpR(servicesFile, nodePackageFile, {silent: true});
@@ -475,6 +472,16 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents);
});
compileFile(servicesFileInBrowserTest, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
/*prefixes*/ [copyright],
/*useBuiltCompiler*/ true,
{ noOutFile: false, generateDeclarations: true, preserveConstEnums: true, keepComments: true, noResolve: false, stripInternal: true, noMapRoot: true },
/*callback*/ function () {
var content = fs.readFileSync(servicesFileInBrowserTest).toString();
var i = content.lastIndexOf("\n");
fs.writeFileSync(servicesFileInBrowserTest, content.substring(0, i) + "\r\n//# sourceURL=../built/local/typeScriptServices.js" + content.substring(i));
});
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);
@@ -486,8 +493,7 @@ compileFile(
[builtLocalDirectory, copyright].concat(languageServiceLibrarySources),
/*prefixes*/ [copyright],
/*useBuiltCompiler*/ true,
/*noOutFile*/ false,
/*generateDeclarations*/ true);
{ noOutFile: false, generateDeclarations: true });
// Local target to build the language service server library
desc("Builds language service server library");
@@ -720,7 +726,7 @@ task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
// Browser tests
var nodeServerOutFile = 'tests/webTestServer.js'
var nodeServerInFile = 'tests/webTestServer.ts'
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, /*noOutFile*/ true);
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() {
@@ -729,7 +735,7 @@ task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function()
}, {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], function() {
task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function() {
cleanTestDirs();
host = "node"
port = process.env.port || process.env.p || '8888';
@@ -881,7 +887,8 @@ var tslintRulesOutFiles = tslintRules.map(function(p) {
desc("Compiles tslint rules to js");
task("build-rules", tslintRulesOutFiles);
tslintRulesFiles.forEach(function(ruleFile, i) {
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, /*noOutFile*/ true, /*generateDeclarations*/ false, path.join(builtLocalDirectory, "tslint"));
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false,
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint")});
});
function getLinterOptions() {
+3 -1
View File
@@ -1,7 +1,9 @@
# Read This!
This directory contains miscellaneous documentation such as the TypeScript language specification and logo.
If you are looking for more introductory material, you might want to take a look at the [TypeScript Handbook](https://github.com/Microsoft/TypeScript-Handbook).
# Spec Contributions
The specification is first authored as a Microsoft Word (docx) file and then generated into Markdown and PDF formats.
Due to the binary format of docx files, and the merging difficulties that may come with it, it is preferred that any suggestions or problems found in the spec should be [filed as issues](https://github.com/Microsoft/TypeScript/issues/new) rather than sent as pull requests.
Due to the binary format of docx files, and the merging difficulties that may come with it, it is preferred that **any suggestions or problems found in the spec should be [filed as issues](https://github.com/Microsoft/TypeScript/issues/new)** rather than sent as pull requests.
+4
View File
@@ -0,0 +1,4 @@
# The TypeScript Handbook
The contents of the TypeScript Handbook can be read from [its GitHub repository](https://github.com/Microsoft/TypeScript-Handbook).
Issues and pull requests should be directed there.
+6
View File
@@ -0,0 +1,6 @@
# The TypeScript Wiki
To read the wiki, [visit the wiki on GitHub](https://github.com/Microsoft/TypeScript/wiki).
To contribute by filing an issue or sending a pull request, [visit the wiki repository](https://github.com/Microsoft/TypeScript-wiki).
+4 -3
View File
@@ -1,4 +1,5 @@
# Read this!
# Read This!
These files are not meant to be edited by hand.
If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory. Running `jake LKG` will then appropriately update the files in this directory.
**These files are not meant to be edited by hand.**
If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory.
Running `jake LKG` will then appropriately update the files in this directory.
+10 -10
View File
@@ -12,7 +12,7 @@ namespace ts {
}
const enum Reachability {
Unintialized = 1 << 0,
Uninitialized = 1 << 0,
Reachable = 1 << 1,
Unreachable = 1 << 2,
ReportedUnreachable = 1 << 3
@@ -393,7 +393,7 @@ namespace ts {
// the getLocalNameOfContainer function in the type checker to validate that the local name
// used for a container is unique.
function bindChildren(node: Node) {
// Before we recurse into a node's chilren, we first save the existing parent, container
// Before we recurse into a node's children, we first save the existing parent, container
// and block-container. Then after we pop out of processing the children, we restore
// these saved values.
const saveParent = parent;
@@ -418,7 +418,7 @@ namespace ts {
// Finally, if this is a block-container, then we clear out any existing .locals object
// it may contain within it. This happens in incremental scenarios. Because we can be
// reusing a node from a previous compilation, that node may have had 'locals' created
// for it. We must clear this so we don't accidently move any stale data forward from
// for it. We must clear this so we don't accidentally move any stale data forward from
// a previous compilation.
const containerFlags = getContainerFlags(node);
if (containerFlags & ContainerFlags.IsContainer) {
@@ -699,7 +699,7 @@ namespace ts {
const hasDefault = forEach(n.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause);
// post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case
// post switch state is unreachable if switch is exhaustive (has a default case ) and does not have fallthrough from the last case
const postSwitchState = hasDefault && currentReachabilityState !== Reachability.Reachable ? Reachability.Unreachable : preSwitchState;
popImplicitLabel(postSwitchLabel, postSwitchState);
@@ -766,7 +766,7 @@ namespace ts {
case SyntaxKind.Block:
// do not treat blocks directly inside a function as a block-scoped-container.
// Locals that reside in this block should go to the function locals. Othewise 'x'
// Locals that reside in this block should go to the function locals. Otherwise 'x'
// would not appear to be a redeclaration of a block scoped local in the following
// example:
//
@@ -956,7 +956,7 @@ namespace ts {
const identifier = <Identifier>prop.name;
// ECMA-262 11.1.5 Object Initialiser
// ECMA-262 11.1.5 Object Initializer
// If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
// a.This production is contained in strict code and IsDataDescriptor(previous) is true and
// IsDataDescriptor(propId.descriptor) is true.
@@ -1629,14 +1629,14 @@ namespace ts {
if (hasProperty(labelIndexMap, name.text)) {
return false;
}
labelIndexMap[name.text] = labelStack.push(Reachability.Unintialized) - 1;
labelIndexMap[name.text] = labelStack.push(Reachability.Uninitialized) - 1;
return true;
}
function pushImplicitLabel(): number {
initializeReachabilityStateIfNecessary();
const index = labelStack.push(Reachability.Unintialized) - 1;
const index = labelStack.push(Reachability.Uninitialized) - 1;
implicitLabels.push(index);
return index;
}
@@ -1666,7 +1666,7 @@ namespace ts {
}
function setCurrentStateAtLabel(innerMergedState: Reachability, outerState: Reachability, label: Identifier): void {
if (innerMergedState === Reachability.Unintialized) {
if (innerMergedState === Reachability.Uninitialized) {
if (label && !options.allowUnusedLabels) {
file.bindDiagnostics.push(createDiagnosticForNode(label, Diagnostics.Unused_label));
}
@@ -1687,7 +1687,7 @@ namespace ts {
return false;
}
const stateAtLabel = labelStack[index];
labelStack[index] = stateAtLabel === Reachability.Unintialized ? outerState : or(stateAtLabel, outerState);
labelStack[index] = stateAtLabel === Reachability.Uninitialized ? outerState : or(stateAtLabel, outerState);
return true;
}
+171 -157
View File
@@ -49,7 +49,7 @@ namespace ts {
const compilerOptions = host.getCompilerOptions();
const languageVersion = compilerOptions.target || ScriptTarget.ES3;
const modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None;
const modulekind = getEmitModuleKind(compilerOptions);
const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ModuleKind.System;
const emitResolver = createResolver();
@@ -467,10 +467,10 @@ namespace ts {
* @return a tuple of two symbols
*/
function getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): [Symbol, Symbol] {
const constructoDeclaration = parameter.parent;
const constructorDeclaration = parameter.parent;
const classDeclaration = parameter.parent.parent;
const parameterSymbol = getSymbol(constructoDeclaration.locals, parameterName, SymbolFlags.Value);
const parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, SymbolFlags.Value);
const propertySymbol = getSymbol(classDeclaration.symbol.members, parameterName, SymbolFlags.Value);
if (parameterSymbol && propertySymbol) {
@@ -1460,7 +1460,7 @@ namespace ts {
function isAccessible(symbolFromSymbolTable: Symbol, resolvedAliasSymbol?: Symbol) {
if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) {
// if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table)
// and if symbolfrom symbolTable or alias resolution matches the symbol,
// and if symbolFromSymbolTable or alias resolution matches the symbol,
// check the symbol can be qualified, it is only then this symbol is accessible
return !forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) &&
canQualifySymbol(symbolFromSymbolTable, meaning);
@@ -1531,7 +1531,7 @@ namespace ts {
return qualify;
}
function isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult {
function isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessibilityResult {
if (symbol && enclosingDeclaration && !(symbol.flags & SymbolFlags.TypeParameter)) {
const initialSymbol = symbol;
let meaningToLook = meaning;
@@ -1541,7 +1541,7 @@ namespace ts {
if (accessibleSymbolChain) {
const hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]);
if (!hasAccessibleDeclarations) {
return <SymbolAccessiblityResult>{
return <SymbolAccessibilityResult>{
accessibility: SymbolAccessibility.NotAccessible,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, SymbolFlags.Namespace) : undefined,
@@ -2150,10 +2150,10 @@ namespace ts {
}
}
function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags) {
function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags) {
const targetSymbol = getTargetSymbol(symbol);
if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface || targetSymbol.flags & SymbolFlags.TypeAlias) {
buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags);
buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaration, flags);
}
}
@@ -2623,7 +2623,7 @@ namespace ts {
function getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration): JSDocType {
// First, see if this node has an @type annotation on it directly.
const typeTag = getJSDocTypeTag(declaration);
if (typeTag) {
if (typeTag && typeTag.typeExpression) {
return typeTag.typeExpression.type;
}
@@ -2633,7 +2633,7 @@ namespace ts {
// @type annotation might have been on the variable statement, try that instead.
const annotation = getJSDocTypeTag(declaration.parent.parent);
if (annotation) {
if (annotation && annotation.typeExpression) {
return annotation.typeExpression.type;
}
}
@@ -3431,7 +3431,7 @@ namespace ts {
// Returns true if the class or interface member given by the symbol is free of "this" references. The
// function may return false for symbols that are actually free of "this" references because it is not
// feasible to perform a complete analysis in all cases. In particular, property members with types
// inferred from their initializers and function members with inferred return types are convervatively
// inferred from their initializers and function members with inferred return types are conservatively
// assumed not to be free of "this" references.
function isIndependentMember(symbol: Symbol): boolean {
if (symbol.declarations && symbol.declarations.length === 1) {
@@ -5601,7 +5601,7 @@ namespace ts {
}
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
if (!(target.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties) && someConstituentTypeHasKind(target, TypeFlags.ObjectType)) {
if (!(target.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties) && maybeTypeOfKind(target, TypeFlags.ObjectType)) {
for (const prop of getPropertiesOfObjectType(source)) {
if (!isKnownProperty(target, prop.name)) {
if (reportErrors) {
@@ -5902,7 +5902,7 @@ namespace ts {
if (kind === SignatureKind.Construct && sourceSignatures.length && targetSignatures.length) {
if (isAbstractConstructorType(source) && !isAbstractConstructorType(target)) {
// An abstract constructor type is not assignable to a non-abstract constructor type
// as it would otherwise be possible to new an abstract class. Note that the assignablity
// as it would otherwise be possible to new an abstract class. Note that the assignability
// check we perform for an extends clause excludes construct signatures from the target,
// so this check never proceeds.
if (reportErrors) {
@@ -6623,7 +6623,7 @@ namespace ts {
}
}
else if (source.flags & TypeFlags.UnionOrIntersection) {
// Source is a union or intersection type, infer from each consituent type
// Source is a union or intersection type, infer from each constituent type
const sourceTypes = (<UnionOrIntersectionType>source).types;
for (const sourceType of sourceTypes) {
inferFromTypes(sourceType, target);
@@ -7308,6 +7308,15 @@ namespace ts {
// mark iteration statement as containing block-scoped binding captured in some function
getNodeLinks(current).flags |= NodeCheckFlags.LoopWithCapturedBlockScopedBinding;
}
// mark variables that are declared in loop initializer and reassigned inside the body of ForStatement.
// if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back.
if (container.kind === SyntaxKind.ForStatement &&
getAncestor(symbol.valueDeclaration, SyntaxKind.VariableDeclarationList).parent === container &&
isAssignedInBodyOfForStatement(node, <ForStatement>container)) {
getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.NeedsLoopOutParameter;
}
// set 'declared inside loop' bit on the block-scoped binding
getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.BlockScopedBindingInLoop;
}
@@ -7317,6 +7326,41 @@ namespace ts {
}
}
function isAssignedInBodyOfForStatement(node: Identifier, container: ForStatement): boolean {
let current: Node = node;
// skip parenthesized nodes
while (current.parent.kind === SyntaxKind.ParenthesizedExpression) {
current = current.parent;
}
// check if node is used as LHS in some assignment expression
let isAssigned = false;
if (current.parent.kind === SyntaxKind.BinaryExpression) {
isAssigned = (<BinaryExpression>current.parent).left === current && isAssignmentOperator((<BinaryExpression>current.parent).operatorToken.kind);
}
if ((current.parent.kind === SyntaxKind.PrefixUnaryExpression || current.parent.kind === SyntaxKind.PostfixUnaryExpression)) {
const expr = <PrefixUnaryExpression | PostfixUnaryExpression>current.parent;
isAssigned = expr.operator === SyntaxKind.PlusPlusToken || expr.operator === SyntaxKind.MinusMinusToken;
}
if (!isAssigned) {
return false;
}
// at this point we know that node is the target of assignment
// now check that modification happens inside the statement part of the ForStatement
while (current !== container) {
if (current === container.statement) {
return true;
}
else {
current = current.parent;
}
}
return false;
}
function captureLexicalThis(node: Node, container: Node): void {
getNodeLinks(node).flags |= NodeCheckFlags.LexicalThis;
if (container.kind === SyntaxKind.PropertyDeclaration || container.kind === SyntaxKind.Constructor) {
@@ -7397,7 +7441,7 @@ namespace ts {
if (container.kind === SyntaxKind.FunctionExpression) {
if (getSpecialPropertyAssignmentKind(container.parent) === SpecialPropertyAssignmentKind.PrototypeProperty) {
// Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container')
const className = (((container.parent as BinaryExpression) // x.protoype.y = f
const className = (((container.parent as BinaryExpression) // x.prototype.y = f
.left as PropertyAccessExpression) // x.prototype.y
.expression as PropertyAccessExpression) // x.prototype
.expression; // x
@@ -7414,7 +7458,7 @@ namespace ts {
function getTypeForThisExpressionFromJSDoc(node: Node) {
const typeTag = getJSDocTypeTag(node);
if (typeTag && typeTag.typeExpression.type.kind === SyntaxKind.JSDocFunctionType) {
if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === SyntaxKind.JSDocFunctionType) {
const jsDocFunctionType = <JSDocFunctionType>typeTag.typeExpression.type;
if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === SyntaxKind.JSDocThisType) {
return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
@@ -7920,7 +7964,7 @@ namespace ts {
* Otherwise this may not be very useful.
*
* In cases where you *are* working on this function, you should understand
* when it is appropriate to use 'getContextualType' and 'getApparentTypeOfContetxualType'.
* when it is appropriate to use 'getContextualType' and 'getApparentTypeOfContextualType'.
*
* - Use 'getContextualType' when you are simply going to propagate the result to the expression.
* - Use 'getApparentTypeOfContextualType' when you're going to need the members of the type.
@@ -8178,7 +8222,7 @@ namespace ts {
}
function isTypeAnyOrAllConstituentTypesHaveKind(type: Type, kind: TypeFlags): boolean {
return isTypeAny(type) || allConstituentTypesHaveKind(type, kind);
return isTypeAny(type) || isTypeOfKind(type, kind);
}
function isNumericLiteralName(name: string) {
@@ -8365,7 +8409,7 @@ namespace ts {
checkJsxOpeningLikeElement(node.openingElement);
// Perform resolution on the closing tag so that rename/go to definition/etc work
getJsxElementTagSymbol(node.closingElement);
getJsxTagSymbol(node.closingElement);
// Check children
for (const child of node.children) {
@@ -8475,77 +8519,52 @@ namespace ts {
return jsxTypes[name];
}
/// Given a JSX opening element or self-closing element, return the symbol of the property that the tag name points to if
/// this is an intrinsic tag. This might be a named
/// property of the IntrinsicElements interface, or its string indexer.
/// If this is a class-based tag (otherwise returns undefined), returns the symbol of the class
/// type or factory function.
/// Otherwise, returns unknownSymbol.
function getJsxElementTagSymbol(node: JsxOpeningLikeElement | JsxClosingElement): Symbol {
function getJsxTagSymbol(node: JsxOpeningLikeElement | JsxClosingElement): Symbol {
if (isJsxIntrinsicIdentifier(node.tagName)) {
return getIntrinsicTagSymbol(node);
}
else {
return checkExpression(node.tagName).symbol;
}
}
/**
* Looks up an intrinsic tag name and returns a symbol that either points to an intrinsic
* property (in which case nodeLinks.jsxFlags will be IntrinsicNamedElement) or an intrinsic
* string index signature (in which case nodeLinks.jsxFlags will be IntrinsicIndexedElement).
* May also return unknownSymbol if both of these lookups fail.
*/
function getIntrinsicTagSymbol(node: JsxOpeningLikeElement | JsxClosingElement): Symbol {
const links = getNodeLinks(node);
if (!links.resolvedSymbol) {
if (isJsxIntrinsicIdentifier(node.tagName)) {
links.resolvedSymbol = lookupIntrinsicTag(node);
}
else {
links.resolvedSymbol = lookupClassTag(node);
}
}
return links.resolvedSymbol;
function lookupIntrinsicTag(node: JsxOpeningLikeElement | JsxClosingElement): Symbol {
const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements);
if (intrinsicElementsType !== unknownType) {
// Property case
const intrinsicProp = getPropertyOfType(intrinsicElementsType, (<Identifier>node.tagName).text);
if (intrinsicProp) {
links.jsxFlags |= JsxFlags.IntrinsicNamedElement;
return intrinsicProp;
return links.resolvedSymbol = intrinsicProp;
}
// Intrinsic string indexer case
const indexSignatureType = getIndexTypeOfType(intrinsicElementsType, IndexKind.String);
if (indexSignatureType) {
links.jsxFlags |= JsxFlags.IntrinsicIndexedElement;
return intrinsicElementsType.symbol;
return links.resolvedSymbol = intrinsicElementsType.symbol;
}
// Wasn't found
error(node, Diagnostics.Property_0_does_not_exist_on_type_1, (<Identifier>node.tagName).text, "JSX." + JsxNames.IntrinsicElements);
return unknownSymbol;
return links.resolvedSymbol = unknownSymbol;
}
else {
if (compilerOptions.noImplicitAny) {
error(node, Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements);
}
return unknownSymbol;
}
}
function lookupClassTag(node: JsxOpeningLikeElement | JsxClosingElement): Symbol {
const valueSymbol: Symbol = resolveJsxTagName(node);
// Look up the value in the current scope
if (valueSymbol && valueSymbol !== unknownSymbol) {
links.jsxFlags |= JsxFlags.ValueElement;
if (valueSymbol.flags & SymbolFlags.Alias) {
markAliasSymbolAsReferenced(valueSymbol);
}
}
return valueSymbol || unknownSymbol;
}
function resolveJsxTagName(node: JsxOpeningLikeElement | JsxClosingElement): Symbol {
if (node.tagName.kind === SyntaxKind.Identifier) {
const tag = <Identifier>node.tagName;
const sym = getResolvedSymbol(tag);
return sym.exportSymbol || sym;
}
else {
return checkQualifiedName(<QualifiedName>node.tagName).symbol;
return links.resolvedSymbol = unknownSymbol;
}
}
return links.resolvedSymbol;
}
/**
@@ -8554,17 +8573,8 @@ namespace ts {
* For example, in the element <MyClass>, the element instance type is `MyClass` (not `typeof MyClass`).
*/
function getJsxElementInstanceType(node: JsxOpeningLikeElement) {
// There is no such thing as an instance type for a non-class element. This
// line shouldn't be hit.
Debug.assert(!!(getNodeLinks(node).jsxFlags & JsxFlags.ValueElement), "Should not call getJsxElementInstanceType on non-class Element");
const valueType = checkExpression(node.tagName);
const classSymbol = getJsxElementTagSymbol(node);
if (classSymbol === unknownSymbol) {
// Couldn't find the class instance type. Error has already been issued
return anyType;
}
const valueType = getTypeOfSymbol(classSymbol);
if (isTypeAny(valueType)) {
// Short-circuit if the class tag is using an element type 'any'
return anyType;
@@ -8587,10 +8597,10 @@ namespace ts {
}
/// e.g. "props" for React.d.ts,
/// or 'undefined' if ElementAttributesPropery doesn't exist (which means all
/// or 'undefined' if ElementAttributesProperty doesn't exist (which means all
/// non-intrinsic elements' attributes type is 'any'),
/// or '' if it has 0 properties (which means every
/// non-instrinsic elements' attributes type is the element instance type)
/// non-intrinsic elements' attributes type is the element instance type)
function getJsxElementPropertiesName() {
// JSX
const jsxNamespace = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnosticMessage*/undefined);
@@ -8598,7 +8608,7 @@ namespace ts {
const attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, SymbolFlags.Type);
// JSX.ElementAttributesProperty [type]
const attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym);
// The properites of JSX.ElementAttributesProperty
// The properties of JSX.ElementAttributesProperty
const attribProperties = attribPropType && getPropertiesOfType(attribPropType);
if (attribProperties) {
@@ -8630,9 +8640,16 @@ namespace ts {
function getJsxElementAttributesType(node: JsxOpeningLikeElement): Type {
const links = getNodeLinks(node);
if (!links.resolvedJsxType) {
const sym = getJsxElementTagSymbol(node);
if (links.jsxFlags & JsxFlags.ValueElement) {
if (isJsxIntrinsicIdentifier(node.tagName)) {
const symbol = getIntrinsicTagSymbol(node);
if (links.jsxFlags & JsxFlags.IntrinsicNamedElement) {
return links.resolvedJsxType = getTypeOfSymbol(symbol);
}
else if (links.jsxFlags & JsxFlags.IntrinsicIndexedElement) {
return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, IndexKind.String).type;
}
}
else {
// Get the element instance type (the result of newing or invoking this tag)
const elemInstanceType = getJsxElementInstanceType(node);
@@ -8641,7 +8658,7 @@ namespace ts {
if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) {
// Is this is a stateless function component? See if its single signature's return type is
// assignable to the JSX Element Type
const elemType = getTypeOfSymbol(sym);
const elemType = checkExpression(node.tagName);
const callSignatures = elemType && getSignaturesOfType(elemType, SignatureKind.Call);
const callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0];
const callReturnType = callSignature && getReturnTypeOfSignature(callSignature);
@@ -8715,16 +8732,8 @@ namespace ts {
}
}
}
else if (links.jsxFlags & JsxFlags.IntrinsicNamedElement) {
return links.resolvedJsxType = getTypeOfSymbol(sym);
}
else if (links.jsxFlags & JsxFlags.IntrinsicIndexedElement) {
return links.resolvedJsxType = getIndexInfoOfSymbol(sym, IndexKind.String).type;
}
else {
// Resolution failed, so we don't know
return links.resolvedJsxType = anyType;
}
return links.resolvedJsxType = unknownType;
}
return links.resolvedJsxType;
@@ -9429,7 +9438,7 @@ namespace ts {
// Tagged template expressions will always have `undefined` for `excludeArgument[0]`.
if (excludeArgument) {
for (let i = 0; i < argCount; i++) {
// No need to check for omitted args and template expressions, their exlusion value is always undefined
// No need to check for omitted args and template expressions, their exclusion value is always undefined
if (excludeArgument[i] === false) {
const arg = args[i];
const paramType = getTypeAtPosition(signature, i);
@@ -9684,7 +9693,7 @@ namespace ts {
case SyntaxKind.ComputedPropertyName:
const nameType = checkComputedPropertyName(<ComputedPropertyName>element.name);
if (allConstituentTypesHaveKind(nameType, TypeFlags.ESSymbol)) {
if (isTypeOfKind(nameType, TypeFlags.ESSymbol)) {
return nameType;
}
else {
@@ -9710,7 +9719,7 @@ namespace ts {
*/
function getEffectiveDecoratorThirdArgumentType(node: Node) {
// The third argument to a decorator is either its `descriptor` for a method decorator
// or its `parameterIndex` for a paramter decorator
// or its `parameterIndex` for a parameter decorator
if (node.kind === SyntaxKind.ClassDeclaration) {
Debug.fail("Class decorators should not have a third synthetic argument.");
return unknownType;
@@ -10078,7 +10087,7 @@ namespace ts {
// We exclude union types because we may have a union of function types that happen to have
// no common signatures.
if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) {
// The unknownType indicates that an error already occured (and was reported). No
// The unknownType indicates that an error already occurred (and was reported). No
// need to report another error in this case.
if (funcType !== unknownType && node.typeArguments) {
error(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
@@ -10322,10 +10331,10 @@ namespace ts {
const signature = getResolvedSignature(node);
if (node.expression.kind === SyntaxKind.SuperKeyword) {
const containgFunction = getContainingFunction(node.expression);
const containingFunction = getContainingFunction(node.expression);
if (containgFunction && containgFunction.kind === SyntaxKind.Constructor) {
getNodeLinks(containgFunction).flags |= NodeCheckFlags.HasSeenSuperCall;
if (containingFunction && containingFunction.kind === SyntaxKind.Constructor) {
getNodeLinks(containingFunction).flags |= NodeCheckFlags.HasSeenSuperCall;
}
return voidType;
}
@@ -10371,9 +10380,8 @@ namespace ts {
const widenedType = getWidenedType(exprType);
// Permit 'number[] | "foo"' to be asserted to 'string'.
const bothAreStringLike =
someConstituentTypeHasKind(targetType, TypeFlags.StringLike) &&
someConstituentTypeHasKind(widenedType, TypeFlags.StringLike);
const bothAreStringLike = maybeTypeOfKind(targetType, TypeFlags.StringLike) &&
maybeTypeOfKind(widenedType, TypeFlags.StringLike);
if (!bothAreStringLike && !(isTypeAssignableTo(targetType, widenedType))) {
checkTypeAssignableTo(exprType, targetType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
}
@@ -10628,7 +10636,7 @@ namespace ts {
}
// Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions.
if (returnType === voidType || isTypeAny(returnType) || (returnType && (returnType.flags & TypeFlags.Union) && someConstituentTypeHasKind(returnType, TypeFlags.Any | TypeFlags.Void))) {
if (returnType && maybeTypeOfKind(returnType, TypeFlags.Any | TypeFlags.Void)) {
return;
}
@@ -10884,7 +10892,7 @@ namespace ts {
case SyntaxKind.PlusToken:
case SyntaxKind.MinusToken:
case SyntaxKind.TildeToken:
if (someConstituentTypeHasKind(operandType, TypeFlags.ESSymbol)) {
if (maybeTypeOfKind(operandType, TypeFlags.ESSymbol)) {
error(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator));
}
return numberType;
@@ -10916,38 +10924,47 @@ namespace ts {
return numberType;
}
// Just like isTypeOfKind below, except that it returns true if *any* constituent
// has this kind.
function someConstituentTypeHasKind(type: Type, kind: TypeFlags): boolean {
// Return true if type might be of the given kind. A union or intersection type might be of a given
// kind if at least one constituent type is of the given kind.
function maybeTypeOfKind(type: Type, kind: TypeFlags): boolean {
if (type.flags & kind) {
return true;
}
if (type.flags & TypeFlags.UnionOrIntersection) {
const types = (<UnionOrIntersectionType>type).types;
for (const current of types) {
if (current.flags & kind) {
for (const t of types) {
if (maybeTypeOfKind(t, kind)) {
return true;
}
}
return false;
}
return false;
}
// Return true if type has the given flags, or is a union or intersection type composed of types that all have those flags.
function allConstituentTypesHaveKind(type: Type, kind: TypeFlags): boolean {
// Return true if type is of the given kind. A union type is of a given kind if all constituent types
// are of the given kind. An intersection type is of a given kind if at least one constituent type is
// of the given kind.
function isTypeOfKind(type: Type, kind: TypeFlags): boolean {
if (type.flags & kind) {
return true;
}
if (type.flags & TypeFlags.UnionOrIntersection) {
if (type.flags & TypeFlags.Union) {
const types = (<UnionOrIntersectionType>type).types;
for (const current of types) {
if (!(current.flags & kind)) {
for (const t of types) {
if (!isTypeOfKind(t, kind)) {
return false;
}
}
return true;
}
if (type.flags & TypeFlags.Intersection) {
const types = (<UnionOrIntersectionType>type).types;
for (const t of types) {
if (isTypeOfKind(t, kind)) {
return true;
}
}
}
return false;
}
@@ -10965,7 +10982,7 @@ namespace ts {
// and the right operand to be of type Any or a subtype of the 'Function' interface type.
// The result is always of the Boolean primitive type.
// NOTE: do not raise error if leftType is unknown as related error was already reported
if (allConstituentTypesHaveKind(leftType, TypeFlags.Primitive)) {
if (isTypeOfKind(leftType, TypeFlags.Primitive)) {
error(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
// NOTE: do not raise error if right is unknown as related error was already reported
@@ -11180,13 +11197,13 @@ namespace ts {
if (rightType.flags & (TypeFlags.Undefined | TypeFlags.Null)) rightType = leftType;
let resultType: Type;
if (allConstituentTypesHaveKind(leftType, TypeFlags.NumberLike) && allConstituentTypesHaveKind(rightType, TypeFlags.NumberLike)) {
if (isTypeOfKind(leftType, TypeFlags.NumberLike) && isTypeOfKind(rightType, TypeFlags.NumberLike)) {
// Operands of an enum type are treated as having the primitive type Number.
// If both operands are of the Number primitive type, the result is of the Number primitive type.
resultType = numberType;
}
else {
if (allConstituentTypesHaveKind(leftType, TypeFlags.StringLike) || allConstituentTypesHaveKind(rightType, TypeFlags.StringLike)) {
if (isTypeOfKind(leftType, TypeFlags.StringLike) || isTypeOfKind(rightType, TypeFlags.StringLike)) {
// If one or both operands are of the String primitive type, the result is of the String primitive type.
resultType = stringType;
}
@@ -11224,7 +11241,7 @@ namespace ts {
case SyntaxKind.EqualsEqualsEqualsToken:
case SyntaxKind.ExclamationEqualsEqualsToken:
// Permit 'number[] | "foo"' to be asserted to 'string'.
if (someConstituentTypeHasKind(leftType, TypeFlags.StringLike) && someConstituentTypeHasKind(rightType, TypeFlags.StringLike)) {
if (maybeTypeOfKind(leftType, TypeFlags.StringLike) && maybeTypeOfKind(rightType, TypeFlags.StringLike)) {
return booleanType;
}
if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) {
@@ -11249,8 +11266,8 @@ namespace ts {
// Return true if there was no error, false if there was an error.
function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean {
const offendingSymbolOperand =
someConstituentTypeHasKind(leftType, TypeFlags.ESSymbol) ? left :
someConstituentTypeHasKind(rightType, TypeFlags.ESSymbol) ? right :
maybeTypeOfKind(leftType, TypeFlags.ESSymbol) ? left :
maybeTypeOfKind(rightType, TypeFlags.ESSymbol) ? right :
undefined;
if (offendingSymbolOperand) {
error(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator));
@@ -11846,7 +11863,7 @@ namespace ts {
function checkConstructorDeclaration(node: ConstructorDeclaration) {
// Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function.
checkSignatureDeclaration(node);
// Grammar check for checking only related to constructoDeclaration
// Grammar check for checking only related to constructorDeclaration
checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node);
checkSourceElement(node.body);
@@ -11868,10 +11885,6 @@ namespace ts {
return;
}
function isSuperCallExpression(n: Node): boolean {
return n.kind === SyntaxKind.CallExpression && (<CallExpression>n).expression.kind === SyntaxKind.SuperKeyword;
}
function containsSuperCallAsComputedPropertyName(n: Declaration): boolean {
return n.name && containsSuperCall(n.name);
}
@@ -12362,7 +12375,7 @@ namespace ts {
}
}
// Spaces for anyting not declared a 'default export'.
// Spaces for anything not declared a 'default export'.
const nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces;
const commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces;
@@ -12373,7 +12386,7 @@ namespace ts {
for (const d of symbol.declarations) {
const declarationSpaces = getDeclarationSpaces(d);
// Only error on the declarations that conributed to the intersecting spaces.
// Only error on the declarations that contributed to the intersecting spaces.
if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) {
error(d.name, Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, declarationNameToString(d.name));
}
@@ -13589,7 +13602,7 @@ namespace ts {
* This function does the following steps:
* 1. Break up arrayOrStringType (possibly a union) into its string constituents and array constituents.
* 2. Take the element types of the array constituents.
* 3. Return the union of the element types, and string if there was a string constitutent.
* 3. Return the union of the element types, and string if there was a string constituent.
*
* For example:
* string -> string
@@ -13663,7 +13676,7 @@ namespace ts {
// TODO: Check that target label is valid
}
function isGetAccessorWithAnnotatatedSetAccessor(node: FunctionLikeDeclaration) {
function isGetAccessorWithAnnotatedSetAccessor(node: FunctionLikeDeclaration) {
return !!(node.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<AccessorDeclaration>getDeclarationOfKind(node.symbol, SyntaxKind.SetAccessor)));
}
@@ -13699,7 +13712,7 @@ namespace ts {
error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
}
}
else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || returnType.flags & TypeFlags.PredicateType) {
else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func) || returnType.flags & TypeFlags.PredicateType) {
if (isAsyncFunctionLike(func)) {
const promisedType = getPromisedType(returnType);
const awaitedType = checkAwaitedType(exprType, node.expression, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member);
@@ -13738,7 +13751,7 @@ namespace ts {
let hasDuplicateDefaultClause = false;
const expressionType = checkExpression(node.expression);
const expressionTypeIsStringLike = someConstituentTypeHasKind(expressionType, TypeFlags.StringLike);
const expressionTypeIsStringLike = maybeTypeOfKind(expressionType, TypeFlags.StringLike);
forEach(node.caseBlock.clauses, clause => {
// Grammar check for duplicate default clauses, skip if we already report duplicate default clause
if (clause.kind === SyntaxKind.DefaultClause && !hasDuplicateDefaultClause) {
@@ -13762,7 +13775,7 @@ namespace ts {
const expressionTypeIsAssignableToCaseType =
// Permit 'number[] | "foo"' to be asserted to 'string'.
(expressionTypeIsStringLike && someConstituentTypeHasKind(caseType, TypeFlags.StringLike)) ||
(expressionTypeIsStringLike && maybeTypeOfKind(caseType, TypeFlags.StringLike)) ||
isTypeAssignableTo(expressionType, caseType);
if (!expressionTypeIsAssignableToCaseType) {
@@ -14113,7 +14126,7 @@ namespace ts {
Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
if (derived) {
// In order to resolve whether the inherited method was overriden in the base class or not,
// In order to resolve whether the inherited method was overridden in the base class or not,
// we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated*
// type declaration, derived and base resolve to the same symbol even in the case of generic classes.
if (derived === base) {
@@ -15015,7 +15028,7 @@ namespace ts {
const kind = node.kind;
if (cancellationToken) {
// Only bother checking on a few construct kinds. We don't want to be excessivly
// Only bother checking on a few construct kinds. We don't want to be excessively
// hitting the cancellation token on every node we check.
switch (kind) {
case SyntaxKind.ModuleDeclaration:
@@ -15472,7 +15485,8 @@ namespace ts {
else if ((entityName.parent.kind === SyntaxKind.JsxOpeningElement) ||
(entityName.parent.kind === SyntaxKind.JsxSelfClosingElement) ||
(entityName.parent.kind === SyntaxKind.JsxClosingElement)) {
return getJsxElementTagSymbol(<JsxOpeningLikeElement>entityName.parent);
return getJsxTagSymbol(<JsxOpeningLikeElement>entityName.parent);
}
else if (isExpression(entityName)) {
if (nodeIsMissing(entityName)) {
@@ -15796,13 +15810,13 @@ namespace ts {
function isSymbolOfDeclarationWithCollidingName(symbol: Symbol): boolean {
if (symbol.flags & SymbolFlags.BlockScoped) {
const links = getSymbolLinks(symbol);
if (links.isDeclaratonWithCollidingName === undefined) {
if (links.isDeclarationWithCollidingName === undefined) {
const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration);
if (isStatementWithLocals(container)) {
const nodeLinks = getNodeLinks(symbol.valueDeclaration);
if (!!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) {
// redeclaration - always should be renamed
links.isDeclaratonWithCollidingName = true;
links.isDeclarationWithCollidingName = true;
}
else if (nodeLinks.flags & NodeCheckFlags.CapturedBlockScopedBinding) {
// binding is captured in the function
@@ -15817,21 +15831,21 @@ namespace ts {
// console.log(b()); // should print '100'
// OR
// - binding is declared inside loop but not in inside initializer of iteration statement or directly inside loop body
// * variables from initializer are passed to rewritted loop body as parameters so they are not captured directly
// * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly
// * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus
// they will not collide with anything
const isDeclaredInLoop = nodeLinks.flags & NodeCheckFlags.BlockScopedBindingInLoop;
const inLoopInitializer = isIterationStatement(container, /*lookInLabeledStatements*/ false);
const inLoopBodyBlock = container.kind === SyntaxKind.Block && isIterationStatement(container.parent, /*lookInLabeledStatements*/ false);
links.isDeclaratonWithCollidingName = !isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock));
links.isDeclarationWithCollidingName = !isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock));
}
else {
links.isDeclaratonWithCollidingName = false;
links.isDeclarationWithCollidingName = false;
}
}
}
return links.isDeclaratonWithCollidingName;
return links.isDeclarationWithCollidingName;
}
return false;
}
@@ -15882,7 +15896,7 @@ namespace ts {
if (target === unknownSymbol && compilerOptions.isolatedModules) {
return true;
}
// const enums and modules that contain only const enums are not considered values from the emit perespective
// const enums and modules that contain only const enums are not considered values from the emit perspective
// unless 'preserveConstEnums' option is set to true
return target !== unknownSymbol &&
target &&
@@ -15979,22 +15993,22 @@ namespace ts {
else if (type.flags & TypeFlags.Any) {
return TypeReferenceSerializationKind.ObjectType;
}
else if (allConstituentTypesHaveKind(type, TypeFlags.Void)) {
else if (isTypeOfKind(type, TypeFlags.Void)) {
return TypeReferenceSerializationKind.VoidType;
}
else if (allConstituentTypesHaveKind(type, TypeFlags.Boolean)) {
else if (isTypeOfKind(type, TypeFlags.Boolean)) {
return TypeReferenceSerializationKind.BooleanType;
}
else if (allConstituentTypesHaveKind(type, TypeFlags.NumberLike)) {
else if (isTypeOfKind(type, TypeFlags.NumberLike)) {
return TypeReferenceSerializationKind.NumberLikeType;
}
else if (allConstituentTypesHaveKind(type, TypeFlags.StringLike)) {
else if (isTypeOfKind(type, TypeFlags.StringLike)) {
return TypeReferenceSerializationKind.StringLikeType;
}
else if (allConstituentTypesHaveKind(type, TypeFlags.Tuple)) {
else if (isTypeOfKind(type, TypeFlags.Tuple)) {
return TypeReferenceSerializationKind.ArrayLikeType;
}
else if (allConstituentTypesHaveKind(type, TypeFlags.ESSymbol)) {
else if (isTypeOfKind(type, TypeFlags.ESSymbol)) {
return TypeReferenceSerializationKind.ESSymbolType;
}
else if (isFunctionType(type)) {
@@ -16299,7 +16313,7 @@ namespace ts {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "async");
}
else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text);
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text);
}
else if (flags & NodeFlags.Abstract) {
if (modifier.kind === SyntaxKind.PrivateKeyword) {
@@ -16323,7 +16337,7 @@ namespace ts {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "async");
}
else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static");
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static");
}
else if (node.kind === SyntaxKind.Parameter) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static");
@@ -16732,8 +16746,8 @@ namespace ts {
const seen: Map<SymbolFlags> = {};
const Property = 1;
const GetAccessor = 2;
const SetAccesor = 4;
const GetOrSetAccessor = GetAccessor | SetAccesor;
const SetAccessor = 4;
const GetOrSetAccessor = GetAccessor | SetAccessor;
for (const prop of node.properties) {
const name = prop.name;
@@ -16757,7 +16771,7 @@ namespace ts {
}
});
// ECMA-262 11.1.5 Object Initialiser
// ECMA-262 11.1.5 Object Initializer
// If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
// a.This production is contained in strict code and IsDataDescriptor(previous) is true and
// IsDataDescriptor(propId.descriptor) is true.
@@ -16767,7 +16781,7 @@ namespace ts {
// and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields
let currentKind: number;
if (prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment) {
// Grammar checking for computedPropertName and shorthandPropertyAssignment
// Grammar checking for computedPropertyName and shorthandPropertyAssignment
checkGrammarForInvalidQuestionMark(prop, (<PropertyAssignment>prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional);
if (name.kind === SyntaxKind.NumericLiteral) {
checkGrammarNumericLiteral(<LiteralExpression>name);
@@ -16781,7 +16795,7 @@ namespace ts {
currentKind = GetAccessor;
}
else if (prop.kind === SyntaxKind.SetAccessor) {
currentKind = SetAccesor;
currentKind = SetAccessor;
}
else {
Debug.fail("Unexpected syntax kind:" + prop.kind);
@@ -17253,7 +17267,7 @@ namespace ts {
// We are either parented by another statement, or some sort of block.
// If we're in a block, we only want to really report an error once
// to prevent noisyness. So use a bit on the block to indicate if
// to prevent noisiness. So use a bit on the block to indicate if
// this has already been reported, and don't report if it has.
//
if (node.parent.kind === SyntaxKind.Block || node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) {
+27 -3
View File
@@ -78,6 +78,7 @@ namespace ts {
name: "module",
shortName: "m",
type: {
"none": ModuleKind.None,
"commonjs": ModuleKind.CommonJS,
"amd": ModuleKind.AMD,
"system": ModuleKind.System,
@@ -87,7 +88,7 @@ namespace ts {
},
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015,
paramType: Diagnostics.KIND,
error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015
error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none
},
{
name: "newLine",
@@ -320,6 +321,11 @@ namespace ts {
name: "allowSyntheticDefaultImports",
type: "boolean",
description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking
},
{
name: "noImplicitUseStrict",
type: "boolean",
description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output
}
];
@@ -546,7 +552,21 @@ namespace ts {
}
else {
const filesSeen: Map<boolean> = {};
const exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
let exclude: string[] = [];
if (json["exclude"] instanceof Array) {
exclude = json["exclude"];
}
else {
// by default exclude node_modules, and any specificied output directory
exclude = ["node_modules"];
const outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"];
if (outDir) {
exclude.push(outDir);
}
}
exclude = map(exclude, normalizeSlashes);
const supportedExtensions = getSupportedExtensions(options);
Debug.assert(indexOf(supportedExtensions, ".ts") < indexOf(supportedExtensions, ".d.ts"), "Changed priority of extensions to pick");
@@ -560,6 +580,11 @@ namespace ts {
continue;
}
// Skip over any minified JavaScript files (ending in ".min.js")
if (/\.min\.js$/.test(fileName)) {
continue;
}
// If this is one of the output extension (which would be .d.ts and .js if we are allowing compilation of js files)
// do not include this file if we included .ts or .tsx file with same base name as it could be output of the earlier compilation
if (extension === ".d.ts" || (options.allowJs && contains(supportedJavascriptExtensions, extension))) {
@@ -583,7 +608,6 @@ namespace ts {
const errors: Diagnostic[] = [];
if (configFileName && getBaseFileName(configFileName) === "jsconfig.json") {
options.module = ModuleKind.CommonJS;
options.allowJs = true;
}
+2 -2
View File
@@ -667,7 +667,7 @@ namespace ts {
}
function getNormalizedPathComponentsOfUrl(url: string) {
// Get root length of http://www.website.com/folder1/foler2/
// Get root length of http://www.website.com/folder1/folder2/
// In this example the root is: http://www.website.com/
// normalized path components should be ["http://www.website.com/", "folder1", "folder2"]
@@ -695,7 +695,7 @@ namespace ts {
const indexOfNextSlash = url.indexOf(directorySeparator, rootLength);
if (indexOfNextSlash !== -1) {
// Found the "/" after the website.com so the root is length of http://www.website.com/
// and get components afetr the root normally like any other folder components
// and get components after the root normally like any other folder components
rootLength = indexOfNextSlash + 1;
return normalizedPathComponents(url, rootLength);
}
+66 -69
View File
@@ -18,7 +18,7 @@ namespace ts {
referencePathsOutput: string;
}
type GetSymbolAccessibilityDiagnostic = (symbolAccesibilityResult: SymbolAccessiblityResult) => SymbolAccessibilityDiagnostic;
type GetSymbolAccessibilityDiagnostic = (symbolAccessibilityResult: SymbolAccessibilityResult) => SymbolAccessibilityDiagnostic;
interface EmitTextWriterWithSymbolWriter extends EmitTextWriter, SymbolWriter {
getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic;
@@ -51,7 +51,9 @@ namespace ts {
let decreaseIndent: () => void;
let writeTextOfNode: (text: string, node: Node) => void;
let writer = createAndSetNewTextWriterWithSymbolWriter();
let writer: EmitTextWriterWithSymbolWriter;
createAndSetNewTextWriterWithSymbolWriter();
let enclosingDeclaration: Node;
let resultHasExternalModuleIndicator: boolean;
@@ -174,7 +176,7 @@ namespace ts {
}
}
function createAndSetNewTextWriterWithSymbolWriter(): EmitTextWriterWithSymbolWriter {
function createAndSetNewTextWriterWithSymbolWriter(): void {
const writer = <EmitTextWriterWithSymbolWriter>createTextWriter(newLine);
writer.trackSymbol = trackSymbol;
writer.reportInaccessibleThisError = reportInaccessibleThisError;
@@ -186,7 +188,6 @@ namespace ts {
writer.writeParameter = writer.write;
writer.writeSymbol = writer.write;
setWriter(writer);
return writer;
}
function setWriter(newWriter: EmitTextWriterWithSymbolWriter) {
@@ -252,30 +253,30 @@ namespace ts {
setWriter(oldWriter);
}
function handleSymbolAccessibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) {
if (symbolAccesibilityResult.accessibility === SymbolAccessibility.Accessible) {
function handleSymbolAccessibilityError(symbolAccessibilityResult: SymbolAccessibilityResult) {
if (symbolAccessibilityResult.accessibility === SymbolAccessibility.Accessible) {
// write the aliases
if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) {
writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible);
if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
writeAsynchronousModuleElements(symbolAccessibilityResult.aliasesToMakeVisible);
}
}
else {
// Report error
reportedDeclarationError = true;
const errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult);
const errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
if (errorInfo) {
if (errorInfo.typeName) {
emitterDiagnostics.add(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode,
emitterDiagnostics.add(createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode,
errorInfo.diagnosticMessage,
getTextOfNodeFromSourceText(currentText, errorInfo.typeName),
symbolAccesibilityResult.errorSymbolName,
symbolAccesibilityResult.errorModuleName));
symbolAccessibilityResult.errorSymbolName,
symbolAccessibilityResult.errorModuleName));
}
else {
emitterDiagnostics.add(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode,
emitterDiagnostics.add(createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode,
errorInfo.diagnosticMessage,
symbolAccesibilityResult.errorSymbolName,
symbolAccesibilityResult.errorModuleName));
symbolAccessibilityResult.errorSymbolName,
symbolAccessibilityResult.errorModuleName));
}
}
}
@@ -548,7 +549,7 @@ namespace ts {
writeAsynchronousModuleElements(nodes);
}
function getDefaultExportAccessibilityDiagnostic(diagnostic: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
function getDefaultExportAccessibilityDiagnostic(diagnostic: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
return {
diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
errorNode: node
@@ -677,7 +678,7 @@ namespace ts {
}
writer.writeLine();
function getImportEntityNameVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
function getImportEntityNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
return {
diagnosticMessage: Diagnostics.Import_declaration_0_is_using_private_name_1,
errorNode: node,
@@ -698,10 +699,6 @@ namespace ts {
}
function writeImportDeclaration(node: ImportDeclaration) {
if (!node.importClause && !(node.flags & NodeFlags.Export)) {
// do not write non-exported import declarations that don't have import clauses
return;
}
emitJsDocComments(node);
if (node.flags & NodeFlags.Export) {
write("export ");
@@ -737,7 +734,7 @@ namespace ts {
function emitExternalModuleSpecifier(parent: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration) {
// emitExternalModuleSpecifier is usually called when we emit something in the.d.ts file that will make it an external module (i.e. import/export declarations).
// the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered
// external modules since they are indistingushable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}'
// external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}'
// so compiler will treat them as external modules.
resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== SyntaxKind.ModuleDeclaration;
let moduleSpecifier: Node;
@@ -854,7 +851,7 @@ namespace ts {
writeLine();
enclosingDeclaration = prevEnclosingDeclaration;
function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
return {
diagnosticMessage: Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
errorNode: node.type,
@@ -921,7 +918,7 @@ namespace ts {
}
}
function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
// Type parameter constraints are named by user so we should always be able to name it
let diagnosticMessage: DiagnosticMessage;
switch (node.parent.kind) {
@@ -991,7 +988,7 @@ namespace ts {
write("null");
}
function getHeritageClauseVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
function getHeritageClauseVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
let diagnosticMessage: DiagnosticMessage;
// Heritage clause is written by user so it can always be named
if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
@@ -1108,10 +1105,10 @@ namespace ts {
}
}
function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult: SymbolAccessiblityResult) {
function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) {
if (node.kind === SyntaxKind.VariableDeclaration) {
return symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
@@ -1120,30 +1117,30 @@ namespace ts {
else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) {
// TODO(jfreeman): Deal with computed properties in error reporting.
if (node.flags & NodeFlags.Static) {
return symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
}
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
return symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
}
else {
// Interfaces cannot have types that cannot be named
return symbolAccesibilityResult.errorModuleName ?
return symbolAccessibilityResult.errorModuleName ?
Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
}
}
}
function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
return diagnosticMessage !== undefined ? {
diagnosticMessage,
errorNode: node,
@@ -1167,8 +1164,8 @@ namespace ts {
}
function emitBindingElement(bindingElement: BindingElement) {
function getBindingElementTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
function getBindingElementTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
return diagnosticMessage !== undefined ? {
diagnosticMessage,
errorNode: bindingElement,
@@ -1259,17 +1256,17 @@ namespace ts {
}
}
function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
let diagnosticMessage: DiagnosticMessage;
if (accessorWithTypeAnnotation.kind === SyntaxKind.SetAccessor) {
// Setters have to have type named and cannot infer it so, the type should always be named
if (accessorWithTypeAnnotation.parent.flags & NodeFlags.Static) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1;
}
else {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1;
}
@@ -1282,15 +1279,15 @@ namespace ts {
}
else {
if (accessorWithTypeAnnotation.flags & NodeFlags.Static) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0;
}
else {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0;
@@ -1389,26 +1386,26 @@ namespace ts {
writeLine();
}
function getReturnTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
function getReturnTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
let diagnosticMessage: DiagnosticMessage;
switch (node.kind) {
case SyntaxKind.ConstructSignature:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
case SyntaxKind.CallSignature:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
case SyntaxKind.IndexSignature:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
@@ -1416,30 +1413,30 @@ namespace ts {
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
if (node.flags & NodeFlags.Static) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
}
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
}
else {
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
}
break;
case SyntaxKind.FunctionDeclaration:
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
@@ -1485,8 +1482,8 @@ namespace ts {
writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError);
}
function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
const diagnosticMessage: DiagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
const diagnosticMessage: DiagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
return diagnosticMessage !== undefined ? {
diagnosticMessage,
errorNode: node,
@@ -1494,53 +1491,53 @@ namespace ts {
} : undefined;
}
function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult: SymbolAccessiblityResult): DiagnosticMessage {
function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult): DiagnosticMessage {
switch (node.parent.kind) {
case SyntaxKind.Constructor:
return symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
case SyntaxKind.ConstructSignature:
// Interfaces cannot have parameter types that cannot be named
return symbolAccesibilityResult.errorModuleName ?
return symbolAccessibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
case SyntaxKind.CallSignature:
// Interfaces cannot have parameter types that cannot be named
return symbolAccesibilityResult.errorModuleName ?
return symbolAccessibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
if (node.parent.flags & NodeFlags.Static) {
return symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
}
else if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
return symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
}
else {
// Interfaces cannot have parameter types that cannot be named
return symbolAccesibilityResult.errorModuleName ?
return symbolAccessibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
}
case SyntaxKind.FunctionDeclaration:
return symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
+25 -23
View File
@@ -1,4 +1,4 @@
{
{
"Unterminated string literal.": {
"category": "Error",
"code": 1002
@@ -123,7 +123,7 @@
"category": "Error",
"code": 1043
},
"'{0}' modifier cannot appear on a module element.": {
"'{0}' modifier cannot appear on a module or namespace element.": {
"category": "Error",
"code": 1044
},
@@ -447,7 +447,7 @@
"category": "Error",
"code": 1147
},
"Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.": {
"Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file.": {
"category": "Error",
"code": 1148
},
@@ -1279,10 +1279,6 @@
"category": "Error",
"code": 2417
},
"Type name '{0}' in extends clause does not reference constructor function for '{0}'.": {
"category": "Error",
"code": 2419
},
"Class '{0}' incorrectly implements interface '{1}'.": {
"category": "Error",
"code": 2420
@@ -2207,6 +2203,7 @@
"category": "Error",
"code": 5062
},
"Concatenate and emit output to single file.": {
"category": "Message",
"code": 6001
@@ -2251,10 +2248,10 @@
"category": "Message",
"code": 6011
},
"Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)": {
"category": "Message",
"code": 6015
},
"Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)": {
"category": "Message",
"code": 6015
},
"Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'": {
"category": "Message",
"code": 6016
@@ -2339,7 +2336,7 @@
"category": "Error",
"code": 6045
},
"Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'.": {
"Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'none'.": {
"category": "Error",
"code": 6046
},
@@ -2591,6 +2588,11 @@
"category": "Message",
"code": 6111
},
"Do not emit 'use strict' directives in module output.": {
"category": "Message",
"code": 6112
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
"code": 7005
@@ -2777,23 +2779,23 @@
"code": 17004
},
"A constructor cannot contain a 'super' call when its class extends 'null'": {
"category": "Error",
"code": 17005
"category": "Error",
"code": 17005
},
"An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.": {
"category": "Error",
"code": 17006
"category": "Error",
"code": 17006
},
"A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.": {
"category": "Error",
"code": 17007
"category": "Error",
"code": 17007
},
"JSX element '{0}' has no corresponding closing tag.": {
"category": "Error",
"code": 17008
"category": "Error",
"code": 17008
},
"'super' must be called before accessing 'this' in the constructor of a derived class.": {
"category": "Error",
"code": 17009
"category": "Error",
"code": 17009
}
}
}
+160 -47
View File
@@ -287,6 +287,54 @@ namespace ts {
_i = 0x10000000, // Use/preference flag for '_i'
}
const enum CopyDirection {
ToOriginal,
ToOutParameter
}
/**
* If loop contains block scoped binding captured in some function then loop body is converted to a function.
* Lexical bindings declared in loop initializer will be passed into the loop body function as parameters,
* however if this binding is modified inside the body - this new value should be propagated back to the original binding.
* This is done by declaring new variable (out parameter holder) outside of the loop for every binding that is reassigned inside the body.
* On every iteration this variable is initialized with value of corresponding binding.
* At every point where control flow leaves the loop either explicitly (break/continue) or implicitly (at the end of loop body)
* we copy the value inside the loop to the out parameter holder.
*
* for (let x;;) {
* let a = 1;
* let b = () => a;
* x++
* if (...) break;
* ...
* }
*
* will be converted to
*
* var out_x;
* var loop = function(x) {
* var a = 1;
* var b = function() { return a; }
* x++;
* if (...) return out_x = x, "break";
* ...
* out_x = x;
* }
* for (var x;;) {
* out_x = x;
* var state = loop(x);
* x = out_x;
* if (state === "break") break;
* }
*
* NOTE: values to out parameters are not copies if loop is abrupted with 'return' - in this case this will end the entire enclosing function
* so nobody can observe this new value.
*/
interface LoopOutParameter {
originalName: Identifier;
outParamName: string;
}
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile): EmitResult {
// emit output for the __extends helper function
@@ -359,14 +407,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
interface ConvertedLoopState {
/*
* set of labels that occured inside the converted loop
* set of labels that occurred inside the converted loop
* used to determine if labeled jump can be emitted as is or it should be dispatched to calling code
*/
labels?: Map<string>;
/*
* collection of labeled jumps that transfer control outside the converted loop.
* maps store association 'label -> labelMarker' where
* - label - value of label as it apprear in code
* - label - value of label as it appear in code
* - label marker - return value that should be interpreted by calling code as 'jump to <label>'
*/
labeledNonLocalBreaks?: Map<string>;
@@ -389,7 +437,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
* i.e.
* for (let x;;) <statement that captures x in closure and uses 'arguments'>
* should be converted to
* var loop = function(x) { <code where 'arguments' is replaced witg 'arguments_1'> }
* var loop = function(x) { <code where 'arguments' is replaced with 'arguments_1'> }
* var arguments_1 = arguments
* for (var x;;) loop(x);
* otherwise semantics of the code will be different since 'arguments' inside converted loop body
@@ -419,6 +467,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
* for (var x;;) loop(x);
*/
hoistedLocalVariables?: Identifier[];
/**
* List of loop out parameters - detailed descripion can be found in the comment to LoopOutParameter
*/
loopOutParameters?: LoopOutParameter[];
}
function setLabeledJump(state: ConvertedLoopState, isBreak: boolean, labelText: string, labelMarker: string): void {
@@ -952,7 +1005,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
// Examples: `\n` is converted to "\\n", a template string with a newline to "\n".
let text = getTextOfNodeFromSourceText(currentText, node);
// text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"),
// text contains the original source, it will also contain quotes ("`"), dollar signs and braces ("${" and "}"),
// thus we need to remove those characters.
// First template piece starts with "`", others with "}"
// Last template piece ends with "`", others with "${"
@@ -2968,11 +3021,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}
let loopParameters: string[];
let loopOutParameters: LoopOutParameter[];
if (loopInitializer && (getCombinedNodeFlags(loopInitializer) & NodeFlags.BlockScoped)) {
// if loop initializer contains block scoped variables - they should be passed to converted loop body as parameters
loopParameters = [];
for (const varDeclaration of loopInitializer.declarations) {
collectNames(varDeclaration.name);
processVariableDeclaration(varDeclaration.name);
}
}
@@ -2982,14 +3036,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
writeLine();
write(`var ${functionName} = function(${paramList})`);
if (!bodyIsBlock) {
write(" {");
writeLine();
increaseIndent();
}
const convertedOuterLoopState = convertedLoopState;
convertedLoopState = {};
convertedLoopState = { loopOutParameters };
if (convertedOuterLoopState) {
// convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop.
@@ -3013,16 +3061,38 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}
}
emitEmbeddedStatement(node.statement);
write(" {");
writeLine();
increaseIndent();
if (!bodyIsBlock) {
decreaseIndent();
writeLine();
write("}");
if (bodyIsBlock) {
emitLines((<Block>node.statement).statements);
}
write(";");
else {
emit(node.statement);
}
writeLine();
// end of loop body -> copy out parameter
copyLoopOutParameters(convertedLoopState, CopyDirection.ToOutParameter, /*emitAsStatements*/true);
decreaseIndent();
writeLine();
write("};");
writeLine();
if (loopOutParameters) {
// declare variables to hold out params for loop body
write(`var `);
for (let i = 0; i < loopOutParameters.length; i++) {
if (i !== 0) {
write(", ");
}
write(loopOutParameters[i].outParamName);
}
write(";");
writeLine();
}
if (convertedLoopState.argumentsName) {
// if alias for arguments is set
if (convertedOuterLoopState) {
@@ -3086,14 +3156,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
return { functionName, paramList, state: currentLoopState };
function collectNames(name: Identifier | BindingPattern): void {
function processVariableDeclaration(name: Identifier | BindingPattern): void {
if (name.kind === SyntaxKind.Identifier) {
const nameText = isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(<Identifier>name) ? getGeneratedNameForNode(name) : (<Identifier>name).text;
const nameText = isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(<Identifier>name)
? getGeneratedNameForNode(name)
: (<Identifier>name).text;
loopParameters.push(nameText);
if (resolver.getNodeCheckFlags(name.parent) & NodeCheckFlags.NeedsLoopOutParameter) {
const reassignedVariable = { originalName: <Identifier>name, outParamName: makeUniqueName(`out_${nameText}`) };
(loopOutParameters || (loopOutParameters = [])).push(reassignedVariable);
}
}
else {
for (const element of (<BindingPattern>name).elements) {
collectNames(element.name);
processVariableDeclaration(element.name);
}
}
}
@@ -3124,6 +3201,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}
}
function copyLoopOutParameters(state: ConvertedLoopState, copyDirection: CopyDirection, emitAsStatements: boolean) {
if (state.loopOutParameters) {
for (const outParam of state.loopOutParameters) {
if (copyDirection === CopyDirection.ToOriginal) {
emitIdentifier(outParam.originalName);
write(` = ${outParam.outParamName}`);
}
else {
write(`${outParam.outParamName} = `);
emitIdentifier(outParam.originalName);
}
if (emitAsStatements) {
write(";");
writeLine();
}
else {
write(", ");
}
}
}
}
function emitConvertedLoopCall(loop: ConvertedLoop, emitAsBlock: boolean): void {
if (emitAsBlock) {
write(" {");
@@ -3144,6 +3243,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}
write(`${loop.functionName}(${loop.paramList});`);
writeLine();
copyLoopOutParameters(loop.state, CopyDirection.ToOriginal, /*emitAsStatements*/ true);
if (!isSimpleLoop) {
// for non simple loops we need to store result returned from converted loop function and use it to do dispatching
@@ -3463,14 +3565,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
(!node.label && (convertedLoopState.allowedNonLabeledJumps & jump));
if (!canUseBreakOrContinue) {
write ("return ");
// explicit exit from loop -> copy out parameters
copyLoopOutParameters(convertedLoopState, CopyDirection.ToOutParameter, /*emitAsStatements*/ false);
if (!node.label) {
if (node.kind === SyntaxKind.BreakStatement) {
convertedLoopState.nonLocalJumps |= Jump.Break;
write(`return "break";`);
write(`"break";`);
}
else {
convertedLoopState.nonLocalJumps |= Jump.Continue;
write(`return "continue";`);
write(`"continue";`);
}
}
else {
@@ -3483,7 +3588,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
labelMarker = `continue-${node.label.text}`;
setLabeledJump(convertedLoopState, /*isBreak*/ false, node.label.text, labelMarker);
}
write(`return "${labelMarker}";`);
write(`"${labelMarker}";`);
}
return;
@@ -3959,14 +4064,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
if (properties.length !== 1) {
// For anything but a single element destructuring we need to generate a temporary
// to ensure value is evaluated exactly once.
// When doing so we want to hightlight the passed in source map node since thats the one needing this temp assignment
// When doing so we want to highlight the passed in source map node since thats the one needing this temp assignment
value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, sourceMapNode);
}
for (const p of properties) {
if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) {
const propName = <Identifier | LiteralExpression>(<PropertyAssignment>p).name;
const target = p.kind === SyntaxKind.ShorthandPropertyAssignment ? <ShorthandPropertyAssignment>p : (<PropertyAssignment>p).initializer || propName;
// Assignment for target = value.propName should highligh whole property, hence use p as source map node
// Assignment for target = value.propName should highlight whole property, hence use p as source map node
emitDestructuringAssignment(target, createPropertyAccessForDestructuringProperty(value, propName), p);
}
}
@@ -3977,13 +4082,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
if (elements.length !== 1) {
// For anything but a single element destructuring we need to generate a temporary
// to ensure value is evaluated exactly once.
// When doing so we want to hightlight the passed in source map node since thats the one needing this temp assignment
// When doing so we want to highlight the passed in source map node since thats the one needing this temp assignment
value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, sourceMapNode);
}
for (let i = 0; i < elements.length; i++) {
const e = elements[i];
if (e.kind !== SyntaxKind.OmittedExpression) {
// Assignment for target = value.propName should highligh whole property, hence use e as source map node
// Assignment for target = value.propName should highlight whole property, hence use e as source map node
if (e.kind !== SyntaxKind.SpreadElementExpression) {
emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i)), e);
}
@@ -4790,18 +4895,24 @@ const _super = (function (geti, seti) {
emitToken(SyntaxKind.CloseBraceToken, body.statements.end);
}
function findInitialSuperCall(ctor: ConstructorDeclaration): ExpressionStatement {
if (ctor.body) {
const statement = (<Block>ctor.body).statements[0];
if (statement && statement.kind === SyntaxKind.ExpressionStatement) {
const expr = (<ExpressionStatement>statement).expression;
if (expr && expr.kind === SyntaxKind.CallExpression) {
const func = (<CallExpression>expr).expression;
if (func && func.kind === SyntaxKind.SuperKeyword) {
return <ExpressionStatement>statement;
}
}
}
/**
* Return the statement at a given index if it is a super-call statement
* @param ctor a constructor declaration
* @param index an index to constructor's body to check
*/
function getSuperCallAtGivenIndex(ctor: ConstructorDeclaration, index: number): ExpressionStatement {
if (!ctor.body) {
return undefined;
}
const statements = ctor.body.statements;
if (!statements || index >= statements.length) {
return undefined;
}
const statement = statements[index];
if (statement.kind === SyntaxKind.ExpressionStatement) {
return isSuperCallExpression((<ExpressionStatement>statement).expression) ? <ExpressionStatement>statement : undefined;
}
}
@@ -5085,13 +5196,15 @@ const _super = (function (geti, seti) {
if (ctor) {
emitDefaultValueAssignments(ctor);
emitRestParameter(ctor);
if (baseTypeElement) {
superCall = findInitialSuperCall(ctor);
superCall = getSuperCallAtGivenIndex(ctor, startIndex);
if (superCall) {
writeLine();
emit(superCall);
}
}
emitParameterPropertyAssignments(ctor);
}
else {
@@ -6633,7 +6746,7 @@ const _super = (function (geti, seti) {
// when resolving exports local exported entries/indirect exported entries in the module
// should always win over entries with similar names that were added via star exports
// to support this we store names of local/indirect exported entries in a set.
// this set is used to filter names brought by star expors.
// this set is used to filter names brought by star exports.
if (!hasExportStarsToExportValues) {
// local names set is needed only in presence of star exports
return undefined;
@@ -7179,7 +7292,7 @@ const _super = (function (geti, seti) {
write(`], function(${exportFunctionForFile}, ${contextObjectForFile}) {`);
writeLine();
increaseIndent();
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true);
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict);
writeLine();
write(`var __moduleName = ${contextObjectForFile} && ${contextObjectForFile}.id;`);
writeLine();
@@ -7285,7 +7398,7 @@ const _super = (function (geti, seti) {
writeModuleName(node, emitRelativePathAsModuleName);
emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, emitRelativePathAsModuleName);
increaseIndent();
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true);
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/!compilerOptions.noImplicitUseStrict);
emitExportStarHelper();
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
@@ -7297,7 +7410,7 @@ const _super = (function (geti, seti) {
}
function emitCommonJSModule(node: SourceFile) {
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ true);
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict);
emitEmitHelpers(node);
collectExternalModuleInfo(node);
emitExportStarHelper();
@@ -7326,7 +7439,7 @@ const _super = (function (geti, seti) {
})(`);
emitAMDFactoryHeader(dependencyNames);
increaseIndent();
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true);
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict);
emitExportStarHelper();
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
@@ -7964,7 +8077,7 @@ const _super = (function (geti, seti) {
// declare var x;
// /// <reference-path ...>
// interface F {}
// The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted
// The first /// will NOT be removed while the second one will be removed even though both node will not be emitted
if (node.pos === 0) {
leadingComments = filter(getLeadingCommentsToEmit(node), isTripleSlashComment);
}
+69 -44
View File
@@ -577,7 +577,7 @@ namespace ts {
scanner.setText("");
scanner.setOnError(undefined);
// Clear any data. We don't want to accidently hold onto it for too long.
// Clear any data. We don't want to accidentally hold onto it for too long.
parseDiagnostics = undefined;
sourceFile = undefined;
identifiers = undefined;
@@ -1442,8 +1442,8 @@ namespace ts {
// We can only reuse a node if it was parsed under the same strict mode that we're
// currently in. i.e. if we originally parsed a node in non-strict mode, but then
// the user added 'using strict' at the top of the file, then we can't use that node
// again as the presense of strict mode may cause us to parse the tokens in the file
// differetly.
// again as the presence of strict mode may cause us to parse the tokens in the file
// differently.
//
// Note: we *can* reuse tokens when the strict mode changes. That's because tokens
// are unaffected by strict mode. It's just the parser will decide what to do with it
@@ -1456,7 +1456,7 @@ namespace ts {
}
// Ok, we have a node that looks like it could be reused. Now verify that it is valid
// in the currest list parsing context that we're currently at.
// in the current list parsing context that we're currently at.
if (!canReuseNode(node, parsingContext)) {
return undefined;
}
@@ -1719,7 +1719,7 @@ namespace ts {
};
// Parses a comma-delimited list of elements
function parseDelimitedList<T extends Node>(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimeter?: boolean): NodeArray<T> {
function parseDelimitedList<T extends Node>(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimiter?: boolean): NodeArray<T> {
const saveParsingContext = parsingContext;
parsingContext |= 1 << kind;
const result = <NodeArray<T>>[];
@@ -1748,7 +1748,7 @@ namespace ts {
// parse errors. For example, this can happen when people do things like use
// a semicolon to delimit object literal members. Note: we'll have already
// reported an error when we called parseExpected above.
if (considerSemicolonAsDelimeter && token === SyntaxKind.SemicolonToken && !scanner.hasPrecedingLineBreak()) {
if (considerSemicolonAsDelimiter && token === SyntaxKind.SemicolonToken && !scanner.hasPrecedingLineBreak()) {
nextToken();
}
continue;
@@ -2221,7 +2221,7 @@ namespace ts {
method.name = name;
method.questionToken = questionToken;
// Method signatues don't exist in expression contexts. So they have neither
// Method signatures don't exist in expression contexts. So they have neither
// [Yield] nor [Await]
fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method);
parseTypeMemberSemicolon();
@@ -2450,10 +2450,27 @@ namespace ts {
if (token === SyntaxKind.LessThanToken) {
return true;
}
return token === SyntaxKind.OpenParenToken && lookAhead(isUnambiguouslyStartOfFunctionType);
}
function skipParameterStart(): boolean {
if (isModifierKind(token)) {
// Skip modifiers
parseModifiers();
}
if (isIdentifier()) {
nextToken();
return true;
}
if (token === SyntaxKind.OpenBracketToken || token === SyntaxKind.OpenBraceToken) {
// Return true if we can parse an array or object binding pattern with no errors
const previousErrorCount = parseDiagnostics.length;
parseIdentifierOrPattern();
return previousErrorCount === parseDiagnostics.length;
}
return false;
}
function isUnambiguouslyStartOfFunctionType() {
nextToken();
if (token === SyntaxKind.CloseParenToken || token === SyntaxKind.DotDotDotToken) {
@@ -2461,22 +2478,21 @@ namespace ts {
// ( ...
return true;
}
if (isIdentifier() || isModifierKind(token)) {
nextToken();
if (skipParameterStart()) {
// We successfully skipped modifiers (if any) and an identifier or binding pattern,
// now see if we have something that indicates a parameter declaration
if (token === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken ||
token === SyntaxKind.QuestionToken || token === SyntaxKind.EqualsToken ||
isIdentifier() || isModifierKind(token)) {
// ( id :
// ( id ,
// ( id ?
// ( id =
// ( modifier id
token === SyntaxKind.QuestionToken || token === SyntaxKind.EqualsToken) {
// ( xxx :
// ( xxx ,
// ( xxx ?
// ( xxx =
return true;
}
if (token === SyntaxKind.CloseParenToken) {
nextToken();
if (token === SyntaxKind.EqualsGreaterThanToken) {
// ( id ) =>
// ( xxx ) =>
return true;
}
}
@@ -2703,7 +2719,7 @@ namespace ts {
function isYieldExpression(): boolean {
if (token === SyntaxKind.YieldKeyword) {
// If we have a 'yield' keyword, and htis is a context where yield expressions are
// If we have a 'yield' keyword, and this is a context where yield expressions are
// allowed, then definitely parse out a yield expression.
if (inYieldContext()) {
return true;
@@ -2722,7 +2738,7 @@ namespace ts {
//
// for now we just check if the next token is an identifier. More heuristics
// can be added here later as necessary. We just need to make sure that we
// don't accidently consume something legal.
// don't accidentally consume something legal.
return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine);
}
@@ -2751,7 +2767,7 @@ namespace ts {
}
else {
// if the next token is not on the same line as yield. or we don't have an '*' or
// the start of an expressin, then this is just a simple "yield" expression.
// the start of an expression, then this is just a simple "yield" expression.
return finishNode(node);
}
}
@@ -3044,7 +3060,7 @@ namespace ts {
// Check the precedence to see if we should "take" this operator
// - For left associative operator (all operator but **), consume the operator,
// recursively call the function below, and parse binaryExpression as a rightOperand
// of the caller if the new precendence of the operator is greater then or equal to the current precendence.
// of the caller if the new precedence of the operator is greater then or equal to the current precedence.
// For example:
// a - b - c;
// ^token; leftOperand = b. Return b to the caller as a rightOperand
@@ -3053,8 +3069,8 @@ namespace ts {
// a - b * c;
// ^token; leftOperand = b. Return b * c to the caller as a rightOperand
// - For right associative operator (**), consume the operator, recursively call the function
// and parse binaryExpression as a rightOperand of the caller if the new precendence of
// the operator is strictly grater than the current precendence
// and parse binaryExpression as a rightOperand of the caller if the new precedence of
// the operator is strictly grater than the current precedence
// For example:
// a ** b ** c;
// ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand
@@ -3295,7 +3311,7 @@ namespace ts {
*/
function isIncrementExpression(): boolean {
// This function is called inside parseUnaryExpression to decide
// whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly
// whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly
switch (token) {
case SyntaxKind.PlusToken:
case SyntaxKind.MinusToken:
@@ -3783,7 +3799,7 @@ namespace ts {
return undefined;
}
// If we have a '<', then only parse this as a arugment list if the type arguments
// If we have a '<', then only parse this as a argument list if the type arguments
// are complete and we have an open paren. if we don't, rewind and return nothing.
return typeArguments && canFollowTypeArgumentsInExpression()
? typeArguments
@@ -3960,7 +3976,7 @@ namespace ts {
shorthandDeclaration.equalsToken = equalsToken;
shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher);
}
return finishNode(shorthandDeclaration);
return addJSDocComment(finishNode(shorthandDeclaration));
}
else {
const propertyAssignment = <PropertyAssignment>createNode(SyntaxKind.PropertyAssignment, fullStart);
@@ -3969,7 +3985,7 @@ namespace ts {
propertyAssignment.questionToken = questionToken;
parseExpected(SyntaxKind.ColonToken);
propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher);
return finishNode(propertyAssignment);
return addJSDocComment(finishNode(propertyAssignment));
}
}
@@ -3980,7 +3996,7 @@ namespace ts {
node.multiLine = true;
}
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true);
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
parseExpected(SyntaxKind.CloseBraceToken);
return finishNode(node);
}
@@ -4776,8 +4792,8 @@ namespace ts {
// off. The grammar would look something like this:
//
// MemberVariableDeclaration[Yield]:
// AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initialiser_opt[In];
// AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield];
// AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initializer_opt[In];
// AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initializer_opt[In, ?Yield];
//
// The checker may still error in the static case to explicitly disallow the yield expression.
property.initializer = modifiers && modifiers.flags & NodeFlags.Static
@@ -5378,7 +5394,7 @@ namespace ts {
// ImportSpecifier:
// BindingIdentifier
// IdentifierName as BindingIdentifier
// ExportSpecififer:
// ExportSpecifier:
// IdentifierName
// IdentifierName as IdentifierName
let checkIdentifierIsKeyword = isKeyword(token) && !isIdentifier();
@@ -5727,6 +5743,9 @@ namespace ts {
function parseJSDocParameter(): ParameterDeclaration {
const parameter = <ParameterDeclaration>createNode(SyntaxKind.Parameter);
parameter.type = parseJSDocType();
if (parseOptional(SyntaxKind.EqualsToken)) {
parameter.questionToken = createNode(SyntaxKind.EqualsToken);
}
return finishNode(parameter);
}
@@ -5734,16 +5753,22 @@ namespace ts {
const result = <JSDocTypeReference>createNode(SyntaxKind.JSDocTypeReference);
result.name = parseSimplePropertyName();
while (parseOptional(SyntaxKind.DotToken)) {
if (token === SyntaxKind.LessThanToken) {
result.typeArguments = parseTypeArguments();
break;
}
else {
result.name = parseQualifiedName(result.name);
if (token === SyntaxKind.LessThanToken) {
result.typeArguments = parseTypeArguments();
}
else {
while (parseOptional(SyntaxKind.DotToken)) {
if (token === SyntaxKind.LessThanToken) {
result.typeArguments = parseTypeArguments();
break;
}
else {
result.name = parseQualifiedName(result.name);
}
}
}
return finishNode(result);
}
@@ -6213,7 +6238,7 @@ namespace ts {
}
// Make sure we're not trying to incrementally update a source file more than once. Once
// we do an update the original source file is considered unusbale from that point onwards.
// we do an update the original source file is considered unusable from that point onwards.
//
// This is because we do incremental parsing in-place. i.e. we take nodes from the old
// tree and give them new positions and parents. From that point on, trusting the old
@@ -6344,7 +6369,7 @@ namespace ts {
// We have an element that intersects the change range in some way. It may have its
// start, or its end (or both) in the changed range. We want to adjust any part
// that intersects such that the final tree is in a consistent state. i.e. all
// chlidren have spans within the span of their parent, and all siblings are ordered
// children have spans within the span of their parent, and all siblings are ordered
// properly.
// We may need to update both the 'pos' and the 'end' of the element.
@@ -6366,7 +6391,7 @@ namespace ts {
// -------------------ZZZ-----------------
//
// In this case, any element that started in the 'X' range will keep its position.
// However any element htat started after that will have their pos adjusted to be
// However any element that started after that will have their pos adjusted to be
// at the end of the new range. i.e. any node that started in the 'Y' range will
// be adjusted to have their start at the end of the 'Z' range.
//
@@ -6391,7 +6416,7 @@ namespace ts {
// -------------------ZZZ-----------------
//
// In this case, any element that ended in the 'X' range will keep its position.
// However any element htat ended after that will have their pos adjusted to be
// However any element that ended after that will have their pos adjusted to be
// at the end of the new range. i.e. any node that ended in the 'Y' range will
// be adjusted to have their end at the end of the 'Z' range.
if (element.end >= changeRangeOldEnd) {
@@ -6721,7 +6746,7 @@ namespace ts {
// Position was within this node. Keep searching deeper to find the node.
forEachChild(node, visitNode, visitArray);
// don't procede any futher in the search.
// don't proceed any further in the search.
return true;
}
+12 -12
View File
@@ -141,7 +141,7 @@ namespace ts {
* 'typings' entry or file 'index' with some supported extension
* - Classic loader will only try to interpret '/a/b/c' as file.
*/
type ResolutionKindSpecificLoader = (candidate: string, extensions: string[], failedLookupLocations: string[], onlyRecordFalures: boolean, state: ModuleResolutionState) => string;
type ResolutionKindSpecificLoader = (candidate: string, extensions: string[], failedLookupLocations: string[], onlyRecordFailures: boolean, state: ModuleResolutionState) => string;
/**
* Any module resolution kind can be augmented with optional settings: 'baseUrl', 'paths' and 'rootDirs' - they are used to
@@ -151,7 +151,7 @@ namespace ts {
* fallback to standard resolution routine.
*
* - baseUrl - this setting controls how non-relative module names are resolved. If this setting is specified then non-relative
* names will be resolved relative to baseUrl: i.e. if baseUrl is '/a/b' then canditate location to resolve module name 'c/d' will
* names will be resolved relative to baseUrl: i.e. if baseUrl is '/a/b' then candidate location to resolve module name 'c/d' will
* be '/a/b/c/d'
* - paths - this setting can only be used when baseUrl is specified. allows to tune how non-relative module names
* will be resolved based on the content of the module name.
@@ -169,7 +169,7 @@ namespace ts {
* If module name can be matches with multiple patterns then pattern with the longest prefix will be picked.
* After selecting pattern we'll use list of substitutions to get candidate locations of the module and the try to load module
* from the candidate location.
* Substitiution is a string that can contain zero or one '*'. To get candidate location from substitution we'll pick every
* Substitution is a string that can contain zero or one '*'. To get candidate location from substitution we'll pick every
* substitution in the list and replace '*' with <MatchedStar> string. If candidate location is not rooted it
* will be converted to absolute using baseUrl.
* For example:
@@ -197,10 +197,10 @@ namespace ts {
* 'rootDirs' provides the way to tell compiler that in order to get the whole project it should behave as if content of all
* root dirs were merged together.
* I.e. for the example above 'rootDirs' will have two entries: [ '/local/src', '/shared/components/contracts/src' ].
* Compiler wil first convert './protocols/file2' into absolute path relative to the location of containing file:
* Compiler will first convert './protocols/file2' into absolute path relative to the location of containing file:
* '/local/src/content/protocols/file2' and try to load it - failure.
* Then it will search 'rootDirs' looking for a longest matching prefix of this absolute path and if such prefix is found - absolute path will
* be converted to a path relative to found rootDir entry './content/protocols/file2' (*). As a last step compiler will check all remainining
* be converted to a path relative to found rootDir entry './content/protocols/file2' (*). As a last step compiler will check all remaining
* entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location.
*/
function tryLoadModuleUsingOptionalResolutionSettings(moduleName: string, containingDirectory: string, loader: ResolutionKindSpecificLoader,
@@ -232,7 +232,7 @@ namespace ts {
for (const rootDir of state.compilerOptions.rootDirs) {
// rootDirs are expected to be absolute
// in case of tsconfig.json this will happen automatically - compiler will expand relative names
// using locaton of tsconfig.json as base location
// using location of tsconfig.json as base location
let normalizedRoot = normalizePath(rootDir);
if (!endsWith(normalizedRoot, directorySeparator)) {
normalizedRoot += directorySeparator;
@@ -329,7 +329,7 @@ namespace ts {
}
}
else if (pattern === moduleName) {
// pattern was matched as is - no need to seatch further
// pattern was matched as is - no need to search further
matchedPattern = pattern;
matchedStar = undefined;
break;
@@ -1025,7 +1025,7 @@ namespace ts {
// We were canceled while performing the operation. Because our type checker
// might be a bad state, we need to throw it away.
//
// Note: we are overly agressive here. We do not actually *have* to throw away
// Note: we are overly aggressive here. We do not actually *have* to throw away
// the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep
// the lifetimes of these two TypeCheckers the same. Also, we generally only
// cancel when the user has made a change anyways. And, in that case, we (the
@@ -1477,7 +1477,7 @@ namespace ts {
const resolution = resolutions[i];
setResolvedModule(file, moduleNames[i], resolution);
// add file to program only if:
// - resolution was successfull
// - resolution was successful
// - noResolve is falsy
// - module name come from the list fo imports
const shouldAddFile = resolution &&
@@ -1652,7 +1652,7 @@ namespace ts {
const firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
if (options.isolatedModules) {
if (!options.module && languageVersion < ScriptTarget.ES6) {
if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES6) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
}
@@ -1662,10 +1662,10 @@ namespace ts {
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && options.module === ModuleKind.None) {
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file));
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file));
}
// Cannot specify module gen target of es6 when below es6
+2 -2
View File
@@ -511,7 +511,7 @@ namespace ts {
}
// All conflict markers consist of the same character repeated seven times. If it is
// a <<<<<<< or >>>>>>> marker then it is also followd by a space.
// a <<<<<<< or >>>>>>> marker then it is also followed by a space.
const mergeConflictMarkerLength = "<<<<<<<".length;
function isConflictMarkerTrivia(text: string, pos: number) {
@@ -551,7 +551,7 @@ namespace ts {
}
else {
Debug.assert(ch === CharacterCodes.equals);
// Consume everything from the start of the mid-conlict marker to the start of the next
// Consume everything from the start of the mid-conflict marker to the start of the next
// end-conflict marker.
while (pos < len) {
const ch = text.charCodeAt(pos);
+32 -9
View File
@@ -378,7 +378,8 @@ namespace ts {
const filePath = typeof relativeFileName !== "string"
? undefined
: toPath(relativeFileName, baseDirPath, createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) {
// Some applications save a working file via rename operations
if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks.contains(filePath)) {
for (const fileCallback of fileWatcherCallbacks.get(filePath)) {
fileCallback(filePath);
}
@@ -411,7 +412,7 @@ namespace ts {
const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
function readFile(fileName: string, encoding?: string): string {
if (!_fs.existsSync(fileName)) {
if (!fileExists(fileName)) {
return undefined;
}
const buffer = _fs.readFileSync(fileName);
@@ -462,6 +463,32 @@ namespace ts {
return useCaseSensitiveFileNames ? path : path.toLowerCase();
}
const enum FileSystemEntryKind {
File,
Directory
}
function fileSystemEntryExists(path: string, entryKind: FileSystemEntryKind): boolean {
try {
const stat = _fs.statSync(path);
switch (entryKind) {
case FileSystemEntryKind.File: return stat.isFile();
case FileSystemEntryKind.Directory: return stat.isDirectory();
}
}
catch (e) {
return false;
}
}
function fileExists(path: string): boolean {
return fileSystemEntryExists(path, FileSystemEntryKind.File);
}
function directoryExists(path: string): boolean {
return fileSystemEntryExists(path, FileSystemEntryKind.Directory);
}
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
const result: string[] = [];
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
@@ -500,7 +527,7 @@ namespace ts {
readFile,
writeFile,
watchFile: (filePath, callback) => {
// Node 4.0 stablized the `fs.watch` function on Windows which avoids polling
// Node 4.0 stabilized the `fs.watch` function on Windows which avoids polling
// and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649
// and https://github.com/Microsoft/TypeScript/issues/4643), therefore
// if the current node.js version is newer than 4, use `fs.watch` instead.
@@ -538,12 +565,8 @@ namespace ts {
resolvePath: function (path: string): string {
return _path.resolve(path);
},
fileExists(path: string): boolean {
return _fs.existsSync(path);
},
directoryExists(path: string) {
return _fs.existsSync(path) && _fs.statSync(path).isDirectory();
},
fileExists,
directoryExists,
createDirectory(directoryName: string) {
if (!this.directoryExists(directoryName)) {
_fs.mkdirSync(directoryName);
+6 -6
View File
@@ -115,7 +115,7 @@ namespace ts {
const gutterStyleSequence = "\u001b[100;30m";
const gutterSeparator = " ";
const resetEscapeSequence = "\u001b[0m";
const elipsis = "...";
const ellipsis = "...";
const categoryFormatMap: Map<string> = {
[DiagnosticCategory.Warning]: yellowForegroundEscapeSequence,
[DiagnosticCategory.Error]: redForegroundEscapeSequence,
@@ -139,7 +139,7 @@ namespace ts {
const hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
let gutterWidth = (lastLine + 1 + "").length;
if (hasMoreThanFiveLines) {
gutterWidth = Math.max(elipsis.length, gutterWidth);
gutterWidth = Math.max(ellipsis.length, gutterWidth);
}
output += sys.newLine;
@@ -147,7 +147,7 @@ namespace ts {
// If the error spans over 5 lines, we'll only show the first 2 and last 2 lines,
// so we'll skip ahead to the second-to-last line.
if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
output += formatAndReset(padLeft(elipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + sys.newLine;
output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + sys.newLine;
i = lastLine - 1;
}
@@ -341,7 +341,7 @@ namespace ts {
const directory = ts.getDirectoryPath(configFileName);
directoryWatcher = sys.watchDirectory(
// When the configFileName is just "tsconfig.json", the watched directory should be
// the current direcotry; if there is a given "project" parameter, then the configFileName
// the current directory; if there is a given "project" parameter, then the configFileName
// is an absolute file name.
directory == "" ? "." : directory,
watchedDirectoryChanged, /*recursive*/ true);
@@ -376,7 +376,7 @@ namespace ts {
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
return;
}
const configParseResult = parseJsonConfigFileContent(configObject, sys, getNormalizedAbsolutePath(getDirectoryPath(configFileName), sys.getCurrentDirectory()), commandLine.options);
const configParseResult = parseJsonConfigFileContent(configObject, sys, getNormalizedAbsolutePath(getDirectoryPath(configFileName), sys.getCurrentDirectory()), commandLine.options, configFileName);
if (configParseResult.errors.length > 0) {
reportDiagnostics(configParseResult.errors, /* compilerHost */ undefined);
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
@@ -486,7 +486,7 @@ namespace ts {
}
function watchedDirectoryChanged(fileName: string) {
if (fileName && !ts.isSupportedSourceFileName(fileName, commandLine.options)) {
if (fileName && !ts.isSupportedSourceFileName(fileName, compilerOptions)) {
return;
}
+11 -13
View File
@@ -422,10 +422,6 @@ namespace ts {
IntrinsicNamedElement = 1 << 0,
/** An element inferred from the string index signature of the JSX.IntrinsicElements interface */
IntrinsicIndexedElement = 1 << 1,
/** An element backed by a class, class-like, or function value */
ValueElement = 1 << 2,
/** Element resolution failed */
UnknownElement = 1 << 4,
IntrinsicElement = IntrinsicNamedElement | IntrinsicIndexedElement,
}
@@ -1559,7 +1555,7 @@ namespace ts {
/* @internal */ classifiableNames?: Map<string>;
// Stores a mapping 'external module reference text' -> 'resolved file name' | undefined
// It is used to resolve module names in the checker.
// Content of this fiels should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead
// Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead
/* @internal */ resolvedModules: Map<ResolvedModule>;
/* @internal */ imports: LiteralExpression[];
/* @internal */ moduleAugmentations: LiteralExpression[];
@@ -1753,7 +1749,7 @@ namespace ts {
buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void;
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
@@ -1846,7 +1842,7 @@ namespace ts {
}
/* @internal */
export interface SymbolAccessiblityResult extends SymbolVisibilityResult {
export interface SymbolAccessibilityResult extends SymbolVisibilityResult {
errorModuleName?: string; // If the symbol is not visible from module, module's name
}
@@ -1888,7 +1884,7 @@ namespace ts {
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessibilityResult;
isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult;
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
@@ -2013,7 +2009,7 @@ namespace ts {
containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property
resolvedExports?: SymbolTable; // Resolved exports of module
exportsChecked?: boolean; // True if exports of external module have been checked
isDeclaratonWithCollidingName?: boolean; // True if symbol is block scoped redeclaration
isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration
bindingElement?: BindingElement; // Binding element associated with property symbol
exportsSomeValue?: boolean; // true if module exports some value (not just types)
}
@@ -2044,6 +2040,7 @@ namespace ts {
HasSeenSuperCall = 0x00080000, // Set during the binding when encounter 'super'
ClassWithBodyScopedClassBinding = 0x00100000, // Decorated class that contains a binding to itself inside of the class body.
BodyScopedClassBinding = 0x00200000, // Binding to a decorated class inside of the class's body.
NeedsLoopOutParameter = 0x00400000, // Block scoped binding whose value should be explicitly copied outside of the converted loop
}
/* @internal */
@@ -2061,7 +2058,7 @@ namespace ts {
assignmentChecks?: Map<boolean>; // Cache of assignment checks
hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context
importOnRightSide?: Symbol; // for import declarations - import that appear on the right side
jsxFlags?: JsxFlags; // flags for knowning what kind of element/attributes we're dealing with
jsxFlags?: JsxFlags; // flags for knowing what kind of element/attributes we're dealing with
resolvedJsxType?: Type; // resolved element attributes type of a JSX openinglike element
}
@@ -2166,7 +2163,7 @@ namespace ts {
// Type references (TypeFlags.Reference). When a class or interface has type parameters or
// a "this" type, references to the class or interface are made using type references. The
// typeArguments property specififes the types to substitute for the type parameters of the
// typeArguments property specifies the types to substitute for the type parameters of the
// class or interface and optionally includes an extra element that specifies the type to
// substitute for "this" in the resulting instantiation. When no extra argument is present,
// the type reference itself is substituted for "this". The typeArguments property is undefined
@@ -2422,6 +2419,7 @@ namespace ts {
traceModuleResolution?: boolean;
allowSyntheticDefaultImports?: boolean;
allowJs?: boolean;
noImplicitUseStrict?: boolean;
/* @internal */ stripInternal?: boolean;
// Skip checking lib.d.ts to help speed up tests.
@@ -2692,7 +2690,7 @@ namespace ts {
/*
* CompilerHost must either implement resolveModuleNames (in case if it wants to be completely in charge of
* module name resolution) or provide implementation for methods from ModuleResolutionHost (in this case compiler
* will appply built-in module resolution logic and use members of ModuleResolutionHost to ask host specific questions).
* will apply built-in module resolution logic and use members of ModuleResolutionHost to ask host specific questions).
* If resolveModuleNames is implemented then implementation for members from ModuleResolutionHost can be just
* 'throw new Error("NotImplemented")'
*/
@@ -2718,7 +2716,7 @@ namespace ts {
getGlobalDiagnostics(): Diagnostic[];
// If fileName is provided, gets all the diagnostics associated with that file name.
// Otherwise, returns all the diagnostics (global and file associated) in this colletion.
// Otherwise, returns all the diagnostics (global and file associated) in this collection.
getDiagnostics(fileName?: string): Diagnostic[];
// Gets a count of how many times this collection has been modified. This value changes
+39 -15
View File
@@ -137,7 +137,7 @@ namespace ts {
node.flags |= NodeFlags.ThisNodeOrAnySubNodesHasError;
}
// Also mark that we've propogated the child information to this node. This way we can
// Also mark that we've propagated the child information to this node. This way we can
// always consult the bit directly on this node without needing to check its children
// again.
node.flags |= NodeFlags.HasAggregatedChildData;
@@ -464,6 +464,10 @@ namespace ts {
return !!(getCombinedNodeFlags(node) & NodeFlags.Let);
}
export function isSuperCallExpression(n: Node): boolean {
return n.kind === SyntaxKind.CallExpression && (<CallExpression>n).expression.kind === SyntaxKind.SuperKeyword;
}
export function isPrologueDirective(node: Node): boolean {
return node.kind === SyntaxKind.ExpressionStatement && (<ExpressionStatement>node).expression.kind === SyntaxKind.StringLiteral;
}
@@ -1212,13 +1216,19 @@ namespace ts {
}
// Also recognize when the node is the RHS of an assignment expression
const parent = node.parent;
const isSourceOfAssignmentExpressionStatement =
node.parent && node.parent.parent &&
node.parent.kind === SyntaxKind.BinaryExpression &&
(node.parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken &&
node.parent.parent.kind === SyntaxKind.ExpressionStatement;
parent && parent.parent &&
parent.kind === SyntaxKind.BinaryExpression &&
(parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken &&
parent.parent.kind === SyntaxKind.ExpressionStatement;
if (isSourceOfAssignmentExpressionStatement) {
return node.parent.parent.jsDocComment;
return parent.parent.jsDocComment;
}
const isPropertyAssignmentExpression = parent && parent.kind === SyntaxKind.PropertyAssignment;
if (isPropertyAssignmentExpression) {
return parent.jsDocComment;
}
}
@@ -2001,9 +2011,9 @@ namespace ts {
}
export function getEmitModuleKind(compilerOptions: CompilerOptions) {
return compilerOptions.module ?
return typeof compilerOptions.module === "number" ?
compilerOptions.module :
getEmitScriptTarget(compilerOptions) === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None;
getEmitScriptTarget(compilerOptions) === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.CommonJS;
}
export interface EmitFileNames {
@@ -2030,8 +2040,22 @@ namespace ts {
}
function onSingleFileEmit(host: EmitHost, sourceFile: SourceFile) {
const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host,
sourceFile.languageVariant === LanguageVariant.JSX && options.jsx === JsxEmit.Preserve ? ".jsx" : ".js");
// JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also.
// So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve.
// For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve
let extension = ".js";
if (options.jsx === JsxEmit.Preserve) {
if (isSourceFileJavaScript(sourceFile)) {
if (fileExtensionIs(sourceFile.fileName, ".jsx")) {
extension = ".jsx";
}
}
else if (sourceFile.languageVariant === LanguageVariant.JSX) {
// TypeScript source file preserving JSX syntax
extension = ".jsx";
}
}
const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension);
const emitFileNames: EmitFileNames = {
jsFilePath,
sourceMapFilePath: getSourceMapFilePath(jsFilePath, options),
@@ -2562,7 +2586,7 @@ namespace ts {
byte4 = 64;
}
// Write to the ouput
// Write to the output
result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4);
i += 3;
@@ -2757,9 +2781,9 @@ namespace ts {
// . | \
// ----------------------------------------------------------------------*--------------------------------
//
// (Note the dots represent the newly inferrred start.
// (Note the dots represent the newly inferred start.
// Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the
// absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see
// absolute positions at the asterisks, and the relative change between the dollar signs. Basically, we see
// which if the two $'s precedes the other, and we move that one forward until they line up. in this case that
// means:
//
@@ -2782,8 +2806,8 @@ namespace ts {
// ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started
// that's the same as if we started at char 80 instead of 60.
//
// As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter
// than pusing the first edit forward to match the second, we'll push the second edit forward to match the
// As it so happens, the same logic applies if the second edit precedes the first edit. In that case rather
// than pushing the first edit forward to match the second, we'll push the second edit forward to match the
// first.
//
// In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange
+3 -3
View File
@@ -746,7 +746,7 @@ namespace Harness {
namespace Harness {
export const libFolder = "built/local/";
const tcServicesFileName = ts.combinePaths(libFolder, "typescriptServices.js");
const tcServicesFileName = ts.combinePaths(libFolder, Utils.getExecutionEnvironment() === Utils.ExecutionEnvironment.Browser ? "typescriptServicesInBrowserTest.js" : "typescriptServices.js");
export const tcServicesFile = IO.readFile(tcServicesFileName);
export interface SourceMapEmitterCallback {
@@ -895,7 +895,8 @@ namespace Harness {
{ name: "includeBuiltFile", type: "string" },
{ name: "fileName", type: "string" },
{ name: "libFiles", type: "string" },
{ name: "noErrorTruncation", type: "boolean" }
{ name: "noErrorTruncation", type: "boolean" },
{ name: "suppressOutputPathCheck", type: "boolean" }
];
let optionsIndex: ts.Map<ts.CommandLineOption>;
@@ -965,7 +966,6 @@ namespace Harness {
const options: ts.CompilerOptions & HarnessOptions = compilerOptions ? ts.clone(compilerOptions) : { noResolve: false };
options.target = options.target || ts.ScriptTarget.ES3;
options.module = options.module || ts.ModuleKind.None;
options.newLine = options.newLine || ts.NewLineKind.CarriageReturnLineFeed;
options.noErrorTruncation = true;
options.skipDefaultLibCheck = true;
+12 -1
View File
@@ -223,7 +223,18 @@ namespace Playback {
recordLog.directoriesRead.push(logEntry);
return result;
},
(path, extension, exclude) => findResultByPath(wrapper, replayLog.directoriesRead.filter(d => d.extension === extension && ts.arrayIsEqualTo(d.exclude, exclude)), path));
(path, extension, exclude) => findResultByPath(wrapper,
replayLog.directoriesRead.filter(
d => {
if (d.extension === extension) {
if (d.exclude) {
return ts.arrayIsEqualTo(d.exclude, exclude);
}
return true;
}
return false;
}
), path));
wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)(
(path, contents) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }),
+1 -6
View File
@@ -1113,12 +1113,7 @@ interface Array<T> {
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat<U extends T[]>(...items: U[]): T[];
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: T[]): T[];
concat(...items: (T | T[])[]): T[];
/**
* Adds all the elements of an array separated by the specified separator string.
* @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
+28 -20
View File
@@ -502,7 +502,7 @@ namespace ts {
spacesToRemoveAfterAsterisk = 0;
}
// Analyse text on this line
// Analyze text on this line
while (pos < end && !isLineBreak(sourceFile.text.charCodeAt(pos))) {
const ch = sourceFile.text.charAt(pos);
if (ch === "@") {
@@ -641,7 +641,7 @@ namespace ts {
paramHelpStringMargin = undefined;
}
// If this is the start of another tag, continue with the loop in seach of param tag with symbol name
// If this is the start of another tag, continue with the loop in search of param tag with symbol name
if (sourceFile.text.charCodeAt(pos) === CharacterCodes.at) {
continue;
}
@@ -1713,7 +1713,6 @@ namespace ts {
// Always default to "ScriptTarget.ES5" for the language service
return {
target: ScriptTarget.ES5,
module: ModuleKind.None,
jsx: JsxEmit.Preserve
};
}
@@ -2822,7 +2821,7 @@ namespace ts {
}
// Check if the language version has changed since we last created a program; if they are the same,
// it is safe to reuse the souceFiles; if not, then the shape of the AST can change, and the oldSourceFile
// it is safe to reuse the sourceFiles; if not, then the shape of the AST can change, and the oldSourceFile
// can not be reused. we have to dump all syntax trees and create new ones.
if (!changesInCompilationSettingsAffectSyntax) {
// Check if the old program had this file already
@@ -2916,7 +2915,7 @@ namespace ts {
}
/**
* getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors
* getSemanticDiagnostics return array of Diagnostics. If '-d' is not enabled, only report semantic errors
* If '-d' enabled, report both semantic and emitter errors
*/
function getSemanticDiagnostics(fileName: string): Diagnostic[] {
@@ -3725,7 +3724,7 @@ namespace ts {
* do not occur at the current position and have not otherwise been typed.
*/
function filterNamedImportOrExportCompletionItems(exportsOfModule: Symbol[], namedImportsOrExports: ImportOrExportSpecifier[]): Symbol[] {
const exisingImportsOrExports: Map<boolean> = {};
const existingImportsOrExports: Map<boolean> = {};
for (const element of namedImportsOrExports) {
// If this is the current item we are editing right now, do not filter it out
@@ -3734,14 +3733,14 @@ namespace ts {
}
const name = element.propertyName || element.name;
exisingImportsOrExports[name.text] = true;
existingImportsOrExports[name.text] = true;
}
if (isEmpty(exisingImportsOrExports)) {
if (isEmpty(existingImportsOrExports)) {
return exportsOfModule;
}
return filter(exportsOfModule, e => !lookUp(exisingImportsOrExports, e.name));
return filter(exportsOfModule, e => !lookUp(existingImportsOrExports, e.name));
}
/**
@@ -3823,7 +3822,7 @@ namespace ts {
return undefined;
}
const { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot, isJsDocTagName } = completionData;
const { symbols, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName } = completionData;
if (isJsDocTagName) {
// If the current position is a jsDoc tag name, only tag names should be provided for completion
@@ -3834,7 +3833,7 @@ namespace ts {
const entries: CompletionEntry[] = [];
if (isRightOfDot && isSourceFileJavaScript(sourceFile)) {
if (isSourceFileJavaScript(sourceFile)) {
const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries);
addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames));
}
@@ -4639,7 +4638,16 @@ namespace ts {
// to jump to the implementation directly.
if (symbol.flags & SymbolFlags.Alias) {
const declaration = symbol.declarations[0];
if (node.kind === SyntaxKind.Identifier && node.parent === declaration) {
// Go to the original declaration for cases:
//
// (1) when the aliased symbol was declared in the location(parent).
// (2) when the aliased symbol is originating from a named import.
//
if (node.kind === SyntaxKind.Identifier &&
(node.parent === declaration ||
(declaration.kind === SyntaxKind.ImportSpecifier && declaration.parent && declaration.parent.kind === SyntaxKind.NamedImports))) {
symbol = typeChecker.getAliasedSymbol(symbol);
}
}
@@ -5565,7 +5573,7 @@ namespace ts {
}
// If the symbol is an import we would like to find it if we are looking for what it imports.
// So consider it visibile outside its declaration scope.
// So consider it visible outside its declaration scope.
if (symbol.flags & SymbolFlags.Alias) {
return undefined;
}
@@ -5965,12 +5973,12 @@ namespace ts {
// The search set contains at least the current symbol
let result = [symbol];
// If the symbol is an alias, add what it alaises to the list
// If the symbol is an alias, add what it aliases to the list
if (isImportSpecifierSymbol(symbol)) {
result.push(typeChecker.getAliasedSymbol(symbol));
}
// For export specifiers, the exported name can be refering to a local symbol, e.g.:
// For export specifiers, the exported name can be referring to a local symbol, e.g.:
// import {a} from "mod";
// export {a as somethingElse}
// We want the *local* declaration of 'a' as declared in the import,
@@ -6006,7 +6014,7 @@ namespace ts {
// If the symbol.valueDeclaration is a property parameter declaration,
// we should include both parameter declaration symbol and property declaration symbol
// Parameter Declaration symbol is only visible within function scope, so the symbol is stored in contructor.locals.
// Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals.
// Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members
if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.Parameter &&
isParameterPropertyDeclaration(<ParameterDeclaration>symbol.valueDeclaration)) {
@@ -6032,9 +6040,9 @@ namespace ts {
/**
* Find symbol of the given property-name and add the symbol to the given result array
* @param symbol a symbol to start searching for the given propertyName
* @param propertyName a name of property to serach for
* @param propertyName a name of property to search for
* @param result an array of symbol of found property symbols
* @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisitng of the same symbol.
* @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol.
* The value of previousIterationSymbol is undefined when the function is first called.
*/
function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[],
@@ -7377,12 +7385,12 @@ namespace ts {
// comment portion.
const singleLineCommentStart = /(?:\/\/+\s*)/.source;
const multiLineCommentStart = /(?:\/\*+\s*)/.source;
const anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source;
const anyNumberOfSpacesAndAsterisksAtStartOfLine = /(?:^(?:\s|\*)*)/.source;
// Match any of the above three TODO comment start regexps.
// Note that the outermost group *is* a capture group. We want to capture the preamble
// so that we can determine the starting position of the TODO comment match.
const preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")";
const preamble = "(" + anyNumberOfSpacesAndAsterisksAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")";
// Takes the descriptors and forms a regexp that matches them as if they were literals.
// For example, if the descriptors are "TODO(jason)" and "HACK", then this will be:
@@ -1,12 +1,9 @@
tests/cases/compiler/ExportAssignment7.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/compiler/ExportAssignment7.ts(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
tests/cases/compiler/ExportAssignment7.ts(4,10): error TS2304: Cannot find name 'B'.
==== tests/cases/compiler/ExportAssignment7.ts (3 errors) ====
==== tests/cases/compiler/ExportAssignment7.ts (2 errors) ====
export class C {
~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
}
export = B;
@@ -1,13 +1,10 @@
tests/cases/compiler/ExportAssignment8.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/compiler/ExportAssignment8.ts(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
tests/cases/compiler/ExportAssignment8.ts(1,10): error TS2304: Cannot find name 'B'.
==== tests/cases/compiler/ExportAssignment8.ts (3 errors) ====
==== tests/cases/compiler/ExportAssignment8.ts (2 errors) ====
export = B;
~~~~~~~~~~~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
~~~~~~~~~~~
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.
~
!!! error TS2304: Cannot find name 'B'.
@@ -1,8 +1,8 @@
tests/cases/conformance/parser/ecmascript5/Protected/Protected1.ts(1,1): error TS1044: 'protected' modifier cannot appear on a module element.
tests/cases/conformance/parser/ecmascript5/Protected/Protected1.ts(1,1): error TS1044: 'protected' modifier cannot appear on a module or namespace element.
==== tests/cases/conformance/parser/ecmascript5/Protected/Protected1.ts (1 errors) ====
protected class C {
~~~~~~~~~
!!! error TS1044: 'protected' modifier cannot appear on a module element.
!!! error TS1044: 'protected' modifier cannot appear on a module or namespace element.
}
@@ -1,8 +1,8 @@
tests/cases/conformance/parser/ecmascript5/Protected/Protected2.ts(1,1): error TS1044: 'protected' modifier cannot appear on a module element.
tests/cases/conformance/parser/ecmascript5/Protected/Protected2.ts(1,1): error TS1044: 'protected' modifier cannot appear on a module or namespace element.
==== tests/cases/conformance/parser/ecmascript5/Protected/Protected2.ts (1 errors) ====
protected module M {
~~~~~~~~~
!!! error TS1044: 'protected' modifier cannot appear on a module element.
!!! error TS1044: 'protected' modifier cannot appear on a module or namespace element.
}
@@ -1,13 +1,10 @@
tests/cases/conformance/internalModules/DeclarationMerging/part1.ts(1,15): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(3,24): error TS2304: Cannot find name 'Point'.
tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(7,36): error TS2304: Cannot find name 'Point'.
tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(7,54): error TS2304: Cannot find name 'Point'.
==== tests/cases/conformance/internalModules/DeclarationMerging/part1.ts (1 errors) ====
==== tests/cases/conformance/internalModules/DeclarationMerging/part1.ts (0 errors) ====
export module A {
~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
export interface Point {
x: number;
y: number;
@@ -1,28 +0,0 @@
tests/cases/conformance/ambient/consumer.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
==== tests/cases/conformance/ambient/consumer.ts (1 errors) ====
/// <reference path="decls.ts" />
import imp1 = require('equ');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
// Ambient external module members are always exported with or without export keyword when module lacks export assignment
import imp3 = require('equ2');
var n = imp3.x;
var n: number;
==== tests/cases/conformance/ambient/decls.ts (0 errors) ====
// Ambient external module with export assignment
declare module 'equ' {
var x;
export = x;
}
declare module 'equ2' {
var x: number;
}
// Ambient external import declaration referencing ambient external module using top level module name
@@ -0,0 +1,36 @@
=== tests/cases/conformance/ambient/consumer.ts ===
/// <reference path="decls.ts" />
import imp1 = require('equ');
>imp1 : Symbol(imp1, Decl(consumer.ts, 0, 0))
// Ambient external module members are always exported with or without export keyword when module lacks export assignment
import imp3 = require('equ2');
>imp3 : Symbol(imp3, Decl(consumer.ts, 1, 29))
var n = imp3.x;
>n : Symbol(n, Decl(consumer.ts, 6, 3), Decl(consumer.ts, 7, 3))
>imp3.x : Symbol(imp3.x, Decl(decls.ts, 8, 7))
>imp3 : Symbol(imp3, Decl(consumer.ts, 1, 29))
>x : Symbol(imp3.x, Decl(decls.ts, 8, 7))
var n: number;
>n : Symbol(n, Decl(consumer.ts, 6, 3), Decl(consumer.ts, 7, 3))
=== tests/cases/conformance/ambient/decls.ts ===
// Ambient external module with export assignment
declare module 'equ' {
var x;
>x : Symbol(x, Decl(decls.ts, 3, 7))
export = x;
>x : Symbol(x, Decl(decls.ts, 3, 7))
}
declare module 'equ2' {
var x: number;
>x : Symbol(x, Decl(decls.ts, 8, 7))
}
// Ambient external import declaration referencing ambient external module using top level module name
@@ -0,0 +1,36 @@
=== tests/cases/conformance/ambient/consumer.ts ===
/// <reference path="decls.ts" />
import imp1 = require('equ');
>imp1 : any
// Ambient external module members are always exported with or without export keyword when module lacks export assignment
import imp3 = require('equ2');
>imp3 : typeof imp3
var n = imp3.x;
>n : number
>imp3.x : number
>imp3 : typeof imp3
>x : number
var n: number;
>n : number
=== tests/cases/conformance/ambient/decls.ts ===
// Ambient external module with export assignment
declare module 'equ' {
var x;
>x : any
export = x;
>x : any
}
declare module 'equ2' {
var x: number;
>x : number
}
// Ambient external import declaration referencing ambient external module using top level module name
@@ -3,21 +3,21 @@ var a: string[] = [];
>a : Symbol(a, Decl(arrayConcat2.ts, 0, 3))
a.concat("hello", 'world');
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(arrayConcat2.ts, 0, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
a.concat('Hello');
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(arrayConcat2.ts, 0, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
var b = new Array<string>();
>b : Symbol(b, Decl(arrayConcat2.ts, 5, 3))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
b.concat('hello');
>b.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>b.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>b : Symbol(b, Decl(arrayConcat2.ts, 5, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
+6 -6
View File
@@ -5,17 +5,17 @@ var a: string[] = [];
a.concat("hello", 'world');
>a.concat("hello", 'world') : string[]
>a.concat : { <U extends string[]>(...items: U[]): string[]; (...items: string[]): string[]; }
>a.concat : (...items: (string | string[])[]) => string[]
>a : string[]
>concat : { <U extends string[]>(...items: U[]): string[]; (...items: string[]): string[]; }
>concat : (...items: (string | string[])[]) => string[]
>"hello" : string
>'world' : string
a.concat('Hello');
>a.concat('Hello') : string[]
>a.concat : { <U extends string[]>(...items: U[]): string[]; (...items: string[]): string[]; }
>a.concat : (...items: (string | string[])[]) => string[]
>a : string[]
>concat : { <U extends string[]>(...items: U[]): string[]; (...items: string[]): string[]; }
>concat : (...items: (string | string[])[]) => string[]
>'Hello' : string
var b = new Array<string>();
@@ -25,8 +25,8 @@ var b = new Array<string>();
b.concat('hello');
>b.concat('hello') : string[]
>b.concat : { <U extends string[]>(...items: U[]): string[]; (...items: string[]): string[]; }
>b.concat : (...items: (string | string[])[]) => string[]
>b : string[]
>concat : { <U extends string[]>(...items: U[]): string[]; (...items: string[]): string[]; }
>concat : (...items: (string | string[])[]) => string[]
>'hello' : string
@@ -2,8 +2,8 @@
var x = [].concat([{ a: 1 }], [{ a: 2 }])
>x : Symbol(x, Decl(arrayConcatMap.ts, 0, 3))
>[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>[].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>[].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(arrayConcatMap.ts, 0, 20))
>a : Symbol(a, Decl(arrayConcatMap.ts, 0, 32))
@@ -4,9 +4,9 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }])
>[].concat([{ a: 1 }], [{ a: 2 }]) .map(b => b.a) : any[]
>[].concat([{ a: 1 }], [{ a: 2 }]) .map : <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[]
>[].concat([{ a: 1 }], [{ a: 2 }]) : any[]
>[].concat : { <U extends any[]>(...items: U[]): any[]; (...items: any[]): any[]; }
>[].concat : (...items: any[]) => any[]
>[] : undefined[]
>concat : { <U extends any[]>(...items: U[]): any[]; (...items: any[]): any[]; }
>concat : (...items: any[]) => any[]
>[{ a: 1 }] : { a: number; }[]
>{ a: 1 } : { a: number; }
>a : number
@@ -0,0 +1,22 @@
//// [blockScopedBindingsReassignedInLoop1.ts]
declare function use(n: number): void;
(function () {
'use strict'
for (let i = 0; i < 9; ++i) {
(() => use(++i))();
}
})();
//// [blockScopedBindingsReassignedInLoop1.js]
(function () {
'use strict';
var _loop_1 = function(i) {
(function () { return use(++i); })();
out_i_1 = i;
};
var out_i_1;
for (var i = 0; i < 9; ++i) {
_loop_1(i);
i = out_i_1;
}
})();
@@ -0,0 +1,17 @@
=== tests/cases/compiler/blockScopedBindingsReassignedInLoop1.ts ===
declare function use(n: number): void;
>use : Symbol(use, Decl(blockScopedBindingsReassignedInLoop1.ts, 0, 0))
>n : Symbol(n, Decl(blockScopedBindingsReassignedInLoop1.ts, 0, 21))
(function () {
'use strict'
for (let i = 0; i < 9; ++i) {
>i : Symbol(i, Decl(blockScopedBindingsReassignedInLoop1.ts, 3, 10))
>i : Symbol(i, Decl(blockScopedBindingsReassignedInLoop1.ts, 3, 10))
>i : Symbol(i, Decl(blockScopedBindingsReassignedInLoop1.ts, 3, 10))
(() => use(++i))();
>use : Symbol(use, Decl(blockScopedBindingsReassignedInLoop1.ts, 0, 0))
>i : Symbol(i, Decl(blockScopedBindingsReassignedInLoop1.ts, 3, 10))
}
})();
@@ -0,0 +1,32 @@
=== tests/cases/compiler/blockScopedBindingsReassignedInLoop1.ts ===
declare function use(n: number): void;
>use : (n: number) => void
>n : number
(function () {
>(function () { 'use strict' for (let i = 0; i < 9; ++i) { (() => use(++i))(); }})() : void
>(function () { 'use strict' for (let i = 0; i < 9; ++i) { (() => use(++i))(); }}) : () => void
>function () { 'use strict' for (let i = 0; i < 9; ++i) { (() => use(++i))(); }} : () => void
'use strict'
>'use strict' : string
for (let i = 0; i < 9; ++i) {
>i : number
>0 : number
>i < 9 : boolean
>i : number
>9 : number
>++i : number
>i : number
(() => use(++i))();
>(() => use(++i))() : void
>(() => use(++i)) : () => void
>() => use(++i) : () => void
>use(++i) : void
>use : (n: number) => void
>++i : number
>i : number
}
})();
@@ -0,0 +1,120 @@
//// [blockScopedBindingsReassignedInLoop2.ts]
for (let x = 1, y = 2; x < y; ++x, --y) {
let a = () => x++ + y++;
if (x == 1) {
break;
}
else {
y = 5;
}
}
for (let x = 1, y = 2; x < y; ++x, --y) {
let a = () => x++ + y++;
if (x == 1) {
continue;
}
else {
y = 5;
}
}
loop:
for (let x = 1, y = 2; x < y; ++x, --y) {
let a = () => x++ + y++;
if (x == 1) {
break loop;
}
else {
y = 5;
}
}
loop:
for (let x = 1, y = 2; x < y; ++x, --y) {
let a = () => x++ + y++;
if (x == 1) {
continue loop;
}
else {
y = 5;
}
}
//// [blockScopedBindingsReassignedInLoop2.js]
var _loop_1 = function(x, y) {
var a = function () { return x++ + y++; };
if (x == 1) {
return out_x_1 = x, out_y_1 = y, "break";
}
else {
y = 5;
}
out_x_1 = x;
out_y_1 = y;
};
var out_x_1, out_y_1;
for (var x = 1, y = 2; x < y; ++x, --y) {
var state_1 = _loop_1(x, y);
x = out_x_1;
y = out_y_1;
if (state_1 === "break") break;
}
var _loop_2 = function(x, y) {
var a = function () { return x++ + y++; };
if (x == 1) {
return out_x_2 = x, out_y_2 = y, "continue";
}
else {
y = 5;
}
out_x_2 = x;
out_y_2 = y;
};
var out_x_2, out_y_2;
for (var x = 1, y = 2; x < y; ++x, --y) {
var state_2 = _loop_2(x, y);
x = out_x_2;
y = out_y_2;
if (state_2 === "continue") continue;
}
var _loop_3 = function(x, y) {
var a = function () { return x++ + y++; };
if (x == 1) {
return out_x_3 = x, out_y_3 = y, "break-loop";
}
else {
y = 5;
}
out_x_3 = x;
out_y_3 = y;
};
var out_x_3, out_y_3;
loop: for (var x = 1, y = 2; x < y; ++x, --y) {
var state_3 = _loop_3(x, y);
x = out_x_3;
y = out_y_3;
switch(state_3) {
case "break-loop": break loop;
}
}
var _loop_4 = function(x, y) {
var a = function () { return x++ + y++; };
if (x == 1) {
return out_x_4 = x, out_y_4 = y, "continue-loop";
}
else {
y = 5;
}
out_x_4 = x;
out_y_4 = y;
};
var out_x_4, out_y_4;
loop: for (var x = 1, y = 2; x < y; ++x, --y) {
var state_4 = _loop_4(x, y);
x = out_x_4;
y = out_y_4;
switch(state_4) {
case "continue-loop": continue loop;
}
}
@@ -0,0 +1,98 @@
=== tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts ===
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15))
let a = () => x++ + y++;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop2.ts, 1, 7))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15))
if (x == 1) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8))
break;
}
else {
y = 5;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15))
}
}
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15))
let a = () => x++ + y++;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop2.ts, 11, 7))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15))
if (x == 1) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8))
continue;
}
else {
y = 5;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15))
}
}
loop:
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15))
let a = () => x++ + y++;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop2.ts, 22, 7))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15))
if (x == 1) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8))
break loop;
}
else {
y = 5;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15))
}
}
loop:
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15))
let a = () => x++ + y++;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop2.ts, 33, 7))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15))
if (x == 1) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8))
continue loop;
}
else {
y = 5;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15))
}
}
@@ -0,0 +1,160 @@
=== tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts ===
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : number
>1 : number
>y : number
>2 : number
>x < y : boolean
>x : number
>y : number
>++x, --y : number
>++x : number
>x : number
>--y : number
>y : number
let a = () => x++ + y++;
>a : () => number
>() => x++ + y++ : () => number
>x++ + y++ : number
>x++ : number
>x : number
>y++ : number
>y : number
if (x == 1) {
>x == 1 : boolean
>x : number
>1 : number
break;
}
else {
y = 5;
>y = 5 : number
>y : number
>5 : number
}
}
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : number
>1 : number
>y : number
>2 : number
>x < y : boolean
>x : number
>y : number
>++x, --y : number
>++x : number
>x : number
>--y : number
>y : number
let a = () => x++ + y++;
>a : () => number
>() => x++ + y++ : () => number
>x++ + y++ : number
>x++ : number
>x : number
>y++ : number
>y : number
if (x == 1) {
>x == 1 : boolean
>x : number
>1 : number
continue;
}
else {
y = 5;
>y = 5 : number
>y : number
>5 : number
}
}
loop:
>loop : any
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : number
>1 : number
>y : number
>2 : number
>x < y : boolean
>x : number
>y : number
>++x, --y : number
>++x : number
>x : number
>--y : number
>y : number
let a = () => x++ + y++;
>a : () => number
>() => x++ + y++ : () => number
>x++ + y++ : number
>x++ : number
>x : number
>y++ : number
>y : number
if (x == 1) {
>x == 1 : boolean
>x : number
>1 : number
break loop;
>loop : any
}
else {
y = 5;
>y = 5 : number
>y : number
>5 : number
}
}
loop:
>loop : any
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : number
>1 : number
>y : number
>2 : number
>x < y : boolean
>x : number
>y : number
>++x, --y : number
>++x : number
>x : number
>--y : number
>y : number
let a = () => x++ + y++;
>a : () => number
>() => x++ + y++ : () => number
>x++ + y++ : number
>x++ : number
>x : number
>y++ : number
>y : number
if (x == 1) {
>x == 1 : boolean
>x : number
>1 : number
continue loop;
>loop : any
}
else {
y = 5;
>y = 5 : number
>y : number
>5 : number
}
}
@@ -0,0 +1,247 @@
//// [blockScopedBindingsReassignedInLoop3.ts]
for (let x = 1, y = 2; x < y; ++x, --y) {
let a = () => x++ + y++;
if (x == 1) {
break;
}
else {
for (let a = 1; a < 5; --a) {
let f = () => a;
if (a) {
a = x;
break;
}
else {
y++;
}
}
y = 5;
}
}
for (let x = 1, y = 2; x < y; ++x, --y) {
let a = () => x++ + y++;
if (x == 1) {
continue;
}
else {
for (let a = 1; a < 5; --a) {
let f = () => a;
if (a) {
a = x;
continue;
}
else {
y++;
}
}
y = 5;
}
}
loop2:
for (let x = 1, y = 2; x < y; ++x, --y) {
let a = () => x++ + y++;
if (x == 1) {
break loop2;
}
else {
loop1:
for (let a = 1; a < 5; --a) {
let f = () => a;
if (a) {
a = x;
break loop1;
}
else {
y++;
break loop2
}
}
y = 5;
}
}
loop2:
for (let x = 1, y = 2; x < y; ++x, --y) {
let a = () => x++ + y++;
if (x == 1) {
continue loop2;
}
else {
loop1:
for (let a = 1; a < 5; --a) {
let f = () => a;
if (a) {
a = x;
continue loop1;
}
else {
y++;
continue loop2
}
}
y = 5;
}
}
//// [blockScopedBindingsReassignedInLoop3.js]
var _loop_1 = function(x, y) {
var a = function () { return x++ + y++; };
if (x == 1) {
return out_x_1 = x, out_y_1 = y, "break";
}
else {
var _loop_2 = function(a_1) {
var f = function () { return a_1; };
if (a_1) {
a_1 = x;
return out_a_1_1 = a_1, "break";
}
else {
y++;
}
out_a_1_1 = a_1;
};
var out_a_1_1;
for (var a_1 = 1; a_1 < 5; --a_1) {
var state_1 = _loop_2(a_1);
a_1 = out_a_1_1;
if (state_1 === "break") break;
}
y = 5;
}
out_x_1 = x;
out_y_1 = y;
};
var out_x_1, out_y_1;
for (var x = 1, y = 2; x < y; ++x, --y) {
var state_2 = _loop_1(x, y);
x = out_x_1;
y = out_y_1;
if (state_2 === "break") break;
}
var _loop_3 = function(x, y) {
var a = function () { return x++ + y++; };
if (x == 1) {
return out_x_2 = x, out_y_2 = y, "continue";
}
else {
var _loop_4 = function(a_2) {
var f = function () { return a_2; };
if (a_2) {
a_2 = x;
return out_a_2_1 = a_2, "continue";
}
else {
y++;
}
out_a_2_1 = a_2;
};
var out_a_2_1;
for (var a_2 = 1; a_2 < 5; --a_2) {
var state_3 = _loop_4(a_2);
a_2 = out_a_2_1;
if (state_3 === "continue") continue;
}
y = 5;
}
out_x_2 = x;
out_y_2 = y;
};
var out_x_2, out_y_2;
for (var x = 1, y = 2; x < y; ++x, --y) {
var state_4 = _loop_3(x, y);
x = out_x_2;
y = out_y_2;
if (state_4 === "continue") continue;
}
var _loop_5 = function(x, y) {
var a = function () { return x++ + y++; };
if (x == 1) {
return out_x_3 = x, out_y_3 = y, "break-loop2";
}
else {
var _loop_6 = function(a_3) {
var f = function () { return a_3; };
if (a_3) {
a_3 = x;
return out_a_3_1 = a_3, "break-loop1";
}
else {
y++;
return out_a_3_1 = a_3, "break-loop2";
}
out_a_3_1 = a_3;
};
var out_a_3_1;
loop1: for (var a_3 = 1; a_3 < 5; --a_3) {
var state_5 = _loop_6(a_3);
a_3 = out_a_3_1;
switch(state_5) {
case "break-loop1": break loop1;
case "break-loop2": return state_5;
}
}
y = 5;
}
out_x_3 = x;
out_y_3 = y;
};
var out_x_3, out_y_3;
loop2: for (var x = 1, y = 2; x < y; ++x, --y) {
var state_6 = _loop_5(x, y);
x = out_x_3;
y = out_y_3;
switch(state_6) {
case "break-loop2": break loop2;
}
}
var _loop_7 = function(x, y) {
var a = function () { return x++ + y++; };
if (x == 1) {
return out_x_4 = x, out_y_4 = y, "continue-loop2";
}
else {
var _loop_8 = function(a_4) {
var f = function () { return a_4; };
if (a_4) {
a_4 = x;
return out_a_4_1 = a_4, "continue-loop1";
}
else {
y++;
return out_a_4_1 = a_4, "continue-loop2";
}
out_a_4_1 = a_4;
};
var out_a_4_1;
loop1: for (var a_4 = 1; a_4 < 5; --a_4) {
var state_7 = _loop_8(a_4);
a_4 = out_a_4_1;
switch(state_7) {
case "continue-loop1": continue loop1;
case "continue-loop2": return state_7;
}
}
y = 5;
}
out_x_4 = x;
out_y_4 = y;
};
var out_x_4, out_y_4;
loop2: for (var x = 1, y = 2; x < y; ++x, --y) {
var state_8 = _loop_7(x, y);
x = out_x_4;
y = out_y_4;
switch(state_8) {
case "continue-loop2": continue loop2;
}
}
@@ -0,0 +1,203 @@
=== tests/cases/compiler/blockScopedBindingsReassignedInLoop3.ts ===
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15))
let a = () => x++ + y++;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 2, 7))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15))
if (x == 1) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8))
break;
}
else {
for (let a = 1; a < 5; --a) {
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16))
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16))
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16))
let f = () => a;
>f : Symbol(f, Decl(blockScopedBindingsReassignedInLoop3.ts, 8, 15))
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16))
if (a) {
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16))
a = x;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8))
break;
}
else {
y++;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15))
}
}
y = 5;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15))
}
}
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15))
let a = () => x++ + y++;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 24, 7))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15))
if (x == 1) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8))
continue;
}
else {
for (let a = 1; a < 5; --a) {
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16))
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16))
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16))
let f = () => a;
>f : Symbol(f, Decl(blockScopedBindingsReassignedInLoop3.ts, 30, 15))
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16))
if (a) {
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16))
a = x;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8))
continue;
}
else {
y++;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15))
}
}
y = 5;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15))
}
}
loop2:
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15))
let a = () => x++ + y++;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 46, 7))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15))
if (x == 1) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8))
break loop2;
}
else {
loop1:
for (let a = 1; a < 5; --a) {
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16))
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16))
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16))
let f = () => a;
>f : Symbol(f, Decl(blockScopedBindingsReassignedInLoop3.ts, 53, 15))
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16))
if (a) {
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16))
a = x;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8))
break loop1;
}
else {
y++;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15))
break loop2
}
}
y = 5;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15))
}
}
loop2:
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15))
let a = () => x++ + y++;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 70, 7))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15))
if (x == 1) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8))
continue loop2;
}
else {
loop1:
for (let a = 1; a < 5; --a) {
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16))
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16))
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16))
let f = () => a;
>f : Symbol(f, Decl(blockScopedBindingsReassignedInLoop3.ts, 77, 15))
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16))
if (a) {
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16))
a = x;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8))
continue loop1;
}
else {
y++;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15))
continue loop2
}
}
y = 5;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15))
}
}
@@ -0,0 +1,301 @@
=== tests/cases/compiler/blockScopedBindingsReassignedInLoop3.ts ===
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : number
>1 : number
>y : number
>2 : number
>x < y : boolean
>x : number
>y : number
>++x, --y : number
>++x : number
>x : number
>--y : number
>y : number
let a = () => x++ + y++;
>a : () => number
>() => x++ + y++ : () => number
>x++ + y++ : number
>x++ : number
>x : number
>y++ : number
>y : number
if (x == 1) {
>x == 1 : boolean
>x : number
>1 : number
break;
}
else {
for (let a = 1; a < 5; --a) {
>a : number
>1 : number
>a < 5 : boolean
>a : number
>5 : number
>--a : number
>a : number
let f = () => a;
>f : () => number
>() => a : () => number
>a : number
if (a) {
>a : number
a = x;
>a = x : number
>a : number
>x : number
break;
}
else {
y++;
>y++ : number
>y : number
}
}
y = 5;
>y = 5 : number
>y : number
>5 : number
}
}
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : number
>1 : number
>y : number
>2 : number
>x < y : boolean
>x : number
>y : number
>++x, --y : number
>++x : number
>x : number
>--y : number
>y : number
let a = () => x++ + y++;
>a : () => number
>() => x++ + y++ : () => number
>x++ + y++ : number
>x++ : number
>x : number
>y++ : number
>y : number
if (x == 1) {
>x == 1 : boolean
>x : number
>1 : number
continue;
}
else {
for (let a = 1; a < 5; --a) {
>a : number
>1 : number
>a < 5 : boolean
>a : number
>5 : number
>--a : number
>a : number
let f = () => a;
>f : () => number
>() => a : () => number
>a : number
if (a) {
>a : number
a = x;
>a = x : number
>a : number
>x : number
continue;
}
else {
y++;
>y++ : number
>y : number
}
}
y = 5;
>y = 5 : number
>y : number
>5 : number
}
}
loop2:
>loop2 : any
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : number
>1 : number
>y : number
>2 : number
>x < y : boolean
>x : number
>y : number
>++x, --y : number
>++x : number
>x : number
>--y : number
>y : number
let a = () => x++ + y++;
>a : () => number
>() => x++ + y++ : () => number
>x++ + y++ : number
>x++ : number
>x : number
>y++ : number
>y : number
if (x == 1) {
>x == 1 : boolean
>x : number
>1 : number
break loop2;
>loop2 : any
}
else {
loop1:
>loop1 : any
for (let a = 1; a < 5; --a) {
>a : number
>1 : number
>a < 5 : boolean
>a : number
>5 : number
>--a : number
>a : number
let f = () => a;
>f : () => number
>() => a : () => number
>a : number
if (a) {
>a : number
a = x;
>a = x : number
>a : number
>x : number
break loop1;
>loop1 : any
}
else {
y++;
>y++ : number
>y : number
break loop2
>loop2 : any
}
}
y = 5;
>y = 5 : number
>y : number
>5 : number
}
}
loop2:
>loop2 : any
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : number
>1 : number
>y : number
>2 : number
>x < y : boolean
>x : number
>y : number
>++x, --y : number
>++x : number
>x : number
>--y : number
>y : number
let a = () => x++ + y++;
>a : () => number
>() => x++ + y++ : () => number
>x++ + y++ : number
>x++ : number
>x : number
>y++ : number
>y : number
if (x == 1) {
>x == 1 : boolean
>x : number
>1 : number
continue loop2;
>loop2 : any
}
else {
loop1:
>loop1 : any
for (let a = 1; a < 5; --a) {
>a : number
>1 : number
>a < 5 : boolean
>a : number
>5 : number
>--a : number
>a : number
let f = () => a;
>f : () => number
>() => a : () => number
>a : number
if (a) {
>a : number
a = x;
>a = x : number
>a : number
>x : number
continue loop1;
>loop1 : any
}
else {
y++;
>y++ : number
>y : number
continue loop2
>loop2 : any
}
}
y = 5;
>y = 5 : number
>y : number
>5 : number
}
}
@@ -0,0 +1,34 @@
//// [blockScopedBindingsReassignedInLoop4.ts]
function f1() {
for (let x = 1, y = 2; x < y; ++x, --y) {
let a = () => x++ + y++;
if (x == 1) {
return 1;
}
else {
y = 5;
}
}
}
//// [blockScopedBindingsReassignedInLoop4.js]
function f1() {
var _loop_1 = function(x, y) {
var a = function () { return x++ + y++; };
if (x == 1) {
return { value: 1 };
}
else {
y = 5;
}
out_x_1 = x;
out_y_1 = y;
};
var out_x_1, out_y_1;
for (var x = 1, y = 2; x < y; ++x, --y) {
var state_1 = _loop_1(x, y);
x = out_x_1;
y = out_y_1;
if (typeof state_1 === "object") return state_1.value;
}
}
@@ -0,0 +1,28 @@
=== tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts ===
function f1() {
>f1 : Symbol(f1, Decl(blockScopedBindingsReassignedInLoop4.ts, 0, 0))
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19))
let a = () => x++ + y++;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop4.ts, 2, 11))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19))
if (x == 1) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12))
return 1;
}
else {
y = 5;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19))
}
}
}
@@ -0,0 +1,43 @@
=== tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts ===
function f1() {
>f1 : () => number
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : number
>1 : number
>y : number
>2 : number
>x < y : boolean
>x : number
>y : number
>++x, --y : number
>++x : number
>x : number
>--y : number
>y : number
let a = () => x++ + y++;
>a : () => number
>() => x++ + y++ : () => number
>x++ + y++ : number
>x++ : number
>x : number
>y++ : number
>y : number
if (x == 1) {
>x == 1 : boolean
>x : number
>1 : number
return 1;
>1 : number
}
else {
y = 5;
>y = 5 : number
>y : number
>5 : number
}
}
}
@@ -0,0 +1,27 @@
//// [blockScopedBindingsReassignedInLoop5.ts]
for (let x = 1, y = 2; x < y; ++x, --y) {
let a = () => x++ + y++;
if (x == 1)
break;
else
y = 5;
}
//// [blockScopedBindingsReassignedInLoop5.js]
var _loop_1 = function(x, y) {
var a = function () { return x++ + y++; };
if (x == 1)
return out_x_1 = x, out_y_1 = y, "break";
else
y = 5;
out_x_1 = x;
out_y_1 = y;
};
var out_x_1, out_y_1;
for (var x = 1, y = 2; x < y; ++x, --y) {
var state_1 = _loop_1(x, y);
x = out_x_1;
y = out_y_1;
if (state_1 === "break") break;
}
@@ -0,0 +1,23 @@
=== tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts ===
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15))
let a = () => x++ + y++;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop5.ts, 1, 7))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15))
if (x == 1)
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8))
break;
else
y = 5;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15))
}
@@ -0,0 +1,37 @@
=== tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts ===
for (let x = 1, y = 2; x < y; ++x, --y) {
>x : number
>1 : number
>y : number
>2 : number
>x < y : boolean
>x : number
>y : number
>++x, --y : number
>++x : number
>x : number
>--y : number
>y : number
let a = () => x++ + y++;
>a : () => number
>() => x++ + y++ : () => number
>x++ + y++ : number
>x++ : number
>x : number
>y++ : number
>y : number
if (x == 1)
>x == 1 : boolean
>x : number
>1 : number
break;
else
y = 5;
>y = 5 : number
>y : number
>5 : number
}
@@ -0,0 +1,74 @@
//// [blockScopedBindingsReassignedInLoop6.ts]
function f1() {
for (let [x, y] = [1, 2]; x < y; ++x, --y) {
let a = () => x++ + y++;
if (x == 1)
break;
else if (y == 2)
y = 5;
else
return;
}
}
function f2() {
for (let [{a: x, b: {c: y}}] = [{a: 1, b: {c: 2}}]; x < y; ++x, --y) {
let a = () => x++ + y++;
if (x == 1)
break;
else if (y == 2)
y = 5;
else
return;
}
}
//// [blockScopedBindingsReassignedInLoop6.js]
function f1() {
var _loop_1 = function(x, y) {
var a = function () { return x++ + y++; };
if (x == 1)
return out_x_1 = x, out_y_1 = y, "break";
else if (y == 2)
y = 5;
else
return { value: void 0 };
out_x_1 = x;
out_y_1 = y;
};
var out_x_1, out_y_1;
for (var _a = [1, 2], x = _a[0], y = _a[1]; x < y; ++x, --y) {
var state_1 = _loop_1(x, y);
x = out_x_1;
y = out_y_1;
if (typeof state_1 === "object") return state_1.value;
if (state_1 === "break") break;
}
}
function f2() {
var _loop_2 = function(x, y) {
var a = function () { return x++ + y++; };
if (x == 1)
return out_x_2 = x, out_y_2 = y, "break";
else if (y == 2)
y = 5;
else
return { value: void 0 };
out_x_2 = x;
out_y_2 = y;
};
var out_x_2, out_y_2;
for (var _a = [{ a: 1, b: { c: 2 } }][0], x = _a.a, y = _a.b.c; x < y; ++x, --y) {
var state_2 = _loop_2(x, y);
x = out_x_2;
y = out_y_2;
if (typeof state_2 === "object") return state_2.value;
if (state_2 === "break") break;
}
}
@@ -0,0 +1,74 @@
=== tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts ===
function f1() {
>f1 : Symbol(f1, Decl(blockScopedBindingsReassignedInLoop6.ts, 0, 0))
for (let [x, y] = [1, 2]; x < y; ++x, --y) {
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16))
let a = () => x++ + y++;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop6.ts, 2, 11))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16))
if (x == 1)
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14))
break;
else if (y == 2)
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16))
y = 5;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16))
else
return;
}
}
function f2() {
>f2 : Symbol(f2, Decl(blockScopedBindingsReassignedInLoop6.ts, 10, 1))
for (let [{a: x, b: {c: y}}] = [{a: 1, b: {c: 2}}]; x < y; ++x, --y) {
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 37))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15))
>b : Symbol(b, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 42))
>c : Symbol(c, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 47))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25))
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 37))
>b : Symbol(b, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 42))
>c : Symbol(c, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 47))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25))
let a = () => x++ + y++;
>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop6.ts, 14, 11))
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15))
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25))
if (x == 1)
>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15))
break;
else if (y == 2)
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25))
y = 5;
>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25))
else
return;
}
}
@@ -0,0 +1,110 @@
=== tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts ===
function f1() {
>f1 : () => void
for (let [x, y] = [1, 2]; x < y; ++x, --y) {
>x : number
>y : number
>[1, 2] : [number, number]
>1 : number
>2 : number
>x < y : boolean
>x : number
>y : number
>++x, --y : number
>++x : number
>x : number
>--y : number
>y : number
let a = () => x++ + y++;
>a : () => number
>() => x++ + y++ : () => number
>x++ + y++ : number
>x++ : number
>x : number
>y++ : number
>y : number
if (x == 1)
>x == 1 : boolean
>x : number
>1 : number
break;
else if (y == 2)
>y == 2 : boolean
>y : number
>2 : number
y = 5;
>y = 5 : number
>y : number
>5 : number
else
return;
}
}
function f2() {
>f2 : () => void
for (let [{a: x, b: {c: y}}] = [{a: 1, b: {c: 2}}]; x < y; ++x, --y) {
>a : any
>x : number
>b : any
>c : any
>y : number
>[{a: 1, b: {c: 2}}] : [{ a: number; b: { c: number; }; }]
>{a: 1, b: {c: 2}} : { a: number; b: { c: number; }; }
>a : number
>1 : number
>b : { c: number; }
>{c: 2} : { c: number; }
>c : number
>2 : number
>x < y : boolean
>x : number
>y : number
>++x, --y : number
>++x : number
>x : number
>--y : number
>y : number
let a = () => x++ + y++;
>a : () => number
>() => x++ + y++ : () => number
>x++ + y++ : number
>x++ : number
>x : number
>y++ : number
>y : number
if (x == 1)
>x == 1 : boolean
>x : number
>1 : number
break;
else if (y == 2)
>y == 2 : boolean
>y : number
>2 : number
y = 5;
>y = 5 : number
>y : number
>5 : number
else
return;
}
}
@@ -1,4 +1,3 @@
tests/cases/conformance/externalModules/foo1.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/conformance/externalModules/foo1.ts(9,12): error TS2339: Property 'x' does not exist on type 'C1'.
tests/cases/conformance/externalModules/foo2.ts(8,12): error TS2339: Property 'y' does not exist on type 'C1'.
tests/cases/conformance/externalModules/foo2.ts(13,8): error TS2339: Property 'x' does not exist on type 'C1'.
@@ -26,10 +25,8 @@ tests/cases/conformance/externalModules/foo2.ts(13,8): error TS2339: Property 'x
}
}
==== tests/cases/conformance/externalModules/foo1.ts (2 errors) ====
==== tests/cases/conformance/externalModules/foo1.ts (1 errors) ====
import foo2 = require('./foo2');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
export module M1 {
export class C1 {
m1: foo2.M1.C1;
@@ -1,13 +1,10 @@
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,25): error TS1005: ';' expected.
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(3,1): error TS1128: Declaration or statement expected.
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(4,17): error TS1005: '=' expected.
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts (4 errors) ====
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts (3 errors) ====
export default abstract class A {}
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
~~~~~
!!! error TS1005: ';' expected.
export abstract class B {}
@@ -1,17 +1,14 @@
tests/cases/compiler/classMemberInitializerWithLamdaScoping3_1.ts(4,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/compiler/classMemberInitializerWithLamdaScoping3_1.ts(8,21): error TS2301: Initializer of instance member variable 'messageHandler' cannot reference identifier 'field1' declared in the constructor.
==== tests/cases/compiler/classMemberInitializerWithLamdaScoping3_0.ts (0 errors) ====
var field1: string;
==== tests/cases/compiler/classMemberInitializerWithLamdaScoping3_1.ts (2 errors) ====
==== tests/cases/compiler/classMemberInitializerWithLamdaScoping3_1.ts (1 errors) ====
declare var console: {
log(msg?: any): void;
};
export class Test1 {
~~~~~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
constructor(private field1: string) {
}
messageHandler = () => {
@@ -1,11 +1,8 @@
tests/cases/compiler/classMemberInitializerWithLamdaScoping3_0.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/compiler/classMemberInitializerWithLamdaScoping3_1.ts(8,21): error TS2304: Cannot find name 'field1'.
==== tests/cases/compiler/classMemberInitializerWithLamdaScoping3_0.ts (1 errors) ====
==== tests/cases/compiler/classMemberInitializerWithLamdaScoping3_0.ts (0 errors) ====
export var field1: string;
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
==== tests/cases/compiler/classMemberInitializerWithLamdaScoping3_1.ts (1 errors) ====
declare var console: {
@@ -14,15 +14,15 @@ var fa: number[];
fa = fa.concat([0]);
>fa : Symbol(fa, Decl(concatError.ts, 8, 3))
>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>fa : Symbol(fa, Decl(concatError.ts, 8, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
fa = fa.concat(0);
>fa : Symbol(fa, Decl(concatError.ts, 8, 3))
>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>fa : Symbol(fa, Decl(concatError.ts, 8, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
+4 -4
View File
@@ -16,9 +16,9 @@ fa = fa.concat([0]);
>fa = fa.concat([0]) : number[]
>fa : number[]
>fa.concat([0]) : number[]
>fa.concat : { <U extends number[]>(...items: U[]): number[]; (...items: number[]): number[]; }
>fa.concat : (...items: (number | number[])[]) => number[]
>fa : number[]
>concat : { <U extends number[]>(...items: U[]): number[]; (...items: number[]): number[]; }
>concat : (...items: (number | number[])[]) => number[]
>[0] : number[]
>0 : number
@@ -26,9 +26,9 @@ fa = fa.concat(0);
>fa = fa.concat(0) : number[]
>fa : number[]
>fa.concat(0) : number[]
>fa.concat : { <U extends number[]>(...items: U[]): number[]; (...items: number[]): number[]; }
>fa.concat : (...items: (number | number[])[]) => number[]
>fa : number[]
>concat : { <U extends number[]>(...items: U[]): number[]; (...items: number[]): number[]; }
>concat : (...items: (number | number[])[]) => number[]
>0 : number
@@ -0,0 +1,61 @@
//// [destructuringInFunctionType.ts]
interface a { a }
interface b { b }
interface c { c }
type T1 = ([a, b, c]);
type F1 = ([a, b, c]) => void;
type T2 = ({ a });
type F2 = ({ a }) => void;
type T3 = ([{ a: b }, { b: a }]);
type F3 = ([{ a: b }, { b: a }]) => void;
type T4 = ([{ a: [b, c] }]);
type F4 = ([{ a: [b, c] }]) => void;
type C1 = new ([{ a: [b, c] }]) => void;
var v1 = ([a, b, c]) => "hello";
var v2: ([a, b, c]) => string;
//// [destructuringInFunctionType.js]
var v1 = function (_a) {
var a = _a[0], b = _a[1], c = _a[2];
return "hello";
};
var v2;
//// [destructuringInFunctionType.d.ts]
interface a {
a: any;
}
interface b {
b: any;
}
interface c {
c: any;
}
declare type T1 = ([a, b, c]);
declare type F1 = ([a, b, c]) => void;
declare type T2 = ({
a;
});
declare type F2 = ({a}) => void;
declare type T3 = ([{
a: b;
}, {
b: a;
}]);
declare type F3 = ([{a: b}, {b: a}]) => void;
declare type T4 = ([{
a: [b, c];
}]);
declare type F4 = ([{a: [b, c]}]) => void;
declare type C1 = new ([{a: [b, c]}]) => void;
declare var v1: ([a, b, c]: [any, any, any]) => string;
declare var v2: ([a, b, c]) => string;
@@ -0,0 +1,78 @@
=== tests/cases/conformance/es6/destructuring/destructuringInFunctionType.ts ===
interface a { a }
>a : Symbol(a, Decl(destructuringInFunctionType.ts, 0, 0))
>a : Symbol(a, Decl(destructuringInFunctionType.ts, 1, 13))
interface b { b }
>b : Symbol(b, Decl(destructuringInFunctionType.ts, 1, 17))
>b : Symbol(b, Decl(destructuringInFunctionType.ts, 2, 13))
interface c { c }
>c : Symbol(c, Decl(destructuringInFunctionType.ts, 2, 17))
>c : Symbol(c, Decl(destructuringInFunctionType.ts, 3, 13))
type T1 = ([a, b, c]);
>T1 : Symbol(T1, Decl(destructuringInFunctionType.ts, 3, 17))
>a : Symbol(a, Decl(destructuringInFunctionType.ts, 0, 0))
>b : Symbol(b, Decl(destructuringInFunctionType.ts, 1, 17))
>c : Symbol(c, Decl(destructuringInFunctionType.ts, 2, 17))
type F1 = ([a, b, c]) => void;
>F1 : Symbol(F1, Decl(destructuringInFunctionType.ts, 5, 22))
>a : Symbol(a, Decl(destructuringInFunctionType.ts, 6, 12))
>b : Symbol(b, Decl(destructuringInFunctionType.ts, 6, 14))
>c : Symbol(c, Decl(destructuringInFunctionType.ts, 6, 17))
type T2 = ({ a });
>T2 : Symbol(T2, Decl(destructuringInFunctionType.ts, 6, 30))
>a : Symbol(a, Decl(destructuringInFunctionType.ts, 8, 12))
type F2 = ({ a }) => void;
>F2 : Symbol(F2, Decl(destructuringInFunctionType.ts, 8, 18))
>a : Symbol(a, Decl(destructuringInFunctionType.ts, 9, 12))
type T3 = ([{ a: b }, { b: a }]);
>T3 : Symbol(T3, Decl(destructuringInFunctionType.ts, 9, 26))
>a : Symbol(a, Decl(destructuringInFunctionType.ts, 11, 13))
>b : Symbol(b, Decl(destructuringInFunctionType.ts, 1, 17))
>b : Symbol(b, Decl(destructuringInFunctionType.ts, 11, 23))
>a : Symbol(a, Decl(destructuringInFunctionType.ts, 0, 0))
type F3 = ([{ a: b }, { b: a }]) => void;
>F3 : Symbol(F3, Decl(destructuringInFunctionType.ts, 11, 33))
>a : Symbol(a)
>b : Symbol(b, Decl(destructuringInFunctionType.ts, 12, 13))
>b : Symbol(b)
>a : Symbol(a, Decl(destructuringInFunctionType.ts, 12, 23))
type T4 = ([{ a: [b, c] }]);
>T4 : Symbol(T4, Decl(destructuringInFunctionType.ts, 12, 41))
>a : Symbol(a, Decl(destructuringInFunctionType.ts, 14, 13))
>b : Symbol(b, Decl(destructuringInFunctionType.ts, 1, 17))
>c : Symbol(c, Decl(destructuringInFunctionType.ts, 2, 17))
type F4 = ([{ a: [b, c] }]) => void;
>F4 : Symbol(F4, Decl(destructuringInFunctionType.ts, 14, 28))
>a : Symbol(a)
>b : Symbol(b, Decl(destructuringInFunctionType.ts, 15, 18))
>c : Symbol(c, Decl(destructuringInFunctionType.ts, 15, 20))
type C1 = new ([{ a: [b, c] }]) => void;
>C1 : Symbol(C1, Decl(destructuringInFunctionType.ts, 15, 36))
>a : Symbol(a)
>b : Symbol(b, Decl(destructuringInFunctionType.ts, 17, 22))
>c : Symbol(c, Decl(destructuringInFunctionType.ts, 17, 24))
var v1 = ([a, b, c]) => "hello";
>v1 : Symbol(v1, Decl(destructuringInFunctionType.ts, 19, 3))
>a : Symbol(a, Decl(destructuringInFunctionType.ts, 19, 11))
>b : Symbol(b, Decl(destructuringInFunctionType.ts, 19, 13))
>c : Symbol(c, Decl(destructuringInFunctionType.ts, 19, 16))
var v2: ([a, b, c]) => string;
>v2 : Symbol(v2, Decl(destructuringInFunctionType.ts, 20, 3))
>a : Symbol(a, Decl(destructuringInFunctionType.ts, 20, 10))
>b : Symbol(b, Decl(destructuringInFunctionType.ts, 20, 12))
>c : Symbol(c, Decl(destructuringInFunctionType.ts, 20, 15))
@@ -0,0 +1,80 @@
=== tests/cases/conformance/es6/destructuring/destructuringInFunctionType.ts ===
interface a { a }
>a : a
>a : any
interface b { b }
>b : b
>b : any
interface c { c }
>c : c
>c : any
type T1 = ([a, b, c]);
>T1 : [a, b, c]
>a : a
>b : b
>c : c
type F1 = ([a, b, c]) => void;
>F1 : ([a, b, c]: [any, any, any]) => void
>a : any
>b : any
>c : any
type T2 = ({ a });
>T2 : { a: any; }
>a : any
type F2 = ({ a }) => void;
>F2 : ({ a }: { a: any; }) => void
>a : any
type T3 = ([{ a: b }, { b: a }]);
>T3 : [{ a: b; }, { b: a; }]
>a : b
>b : b
>b : a
>a : a
type F3 = ([{ a: b }, { b: a }]) => void;
>F3 : ([{ a: b }, { b: a }]: [{ a: any; }, { b: any; }]) => void
>a : any
>b : any
>b : any
>a : any
type T4 = ([{ a: [b, c] }]);
>T4 : [{ a: [b, c]; }]
>a : [b, c]
>b : b
>c : c
type F4 = ([{ a: [b, c] }]) => void;
>F4 : ([{ a: [b, c] }]: [{ a: [any, any]; }]) => void
>a : any
>b : any
>c : any
type C1 = new ([{ a: [b, c] }]) => void;
>C1 : new ([{ a: [b, c] }]: [{ a: [any, any]; }]) => void
>a : any
>b : any
>c : any
var v1 = ([a, b, c]) => "hello";
>v1 : ([a, b, c]: [any, any, any]) => string
>([a, b, c]) => "hello" : ([a, b, c]: [any, any, any]) => string
>a : any
>b : any
>c : any
>"hello" : string
var v2: ([a, b, c]) => string;
>v2 : ([a, b, c]: [any, any, any]) => string
>a : any
>b : any
>c : any
@@ -1,4 +1,3 @@
tests/cases/conformance/externalModules/foo1.ts(3,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/conformance/externalModules/foo1.ts(3,1): error TS2300: Duplicate identifier 'export='.
tests/cases/conformance/externalModules/foo1.ts(4,1): error TS2300: Duplicate identifier 'export='.
tests/cases/conformance/externalModules/foo2.ts(3,1): error TS2300: Duplicate identifier 'export='.
@@ -12,13 +11,11 @@ tests/cases/conformance/externalModules/foo5.ts(5,1): error TS2300: Duplicate id
tests/cases/conformance/externalModules/foo5.ts(6,1): error TS2300: Duplicate identifier 'export='.
==== tests/cases/conformance/externalModules/foo1.ts (3 errors) ====
==== tests/cases/conformance/externalModules/foo1.ts (2 errors) ====
var x = 10;
var y = 20;
export = x;
~~~~~~~~~~~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
~~~~~~~~~~~
!!! error TS2300: Duplicate identifier 'export='.
export = y;
~~~~~~~~~~~
@@ -1,13 +1,12 @@
tests/cases/compiler/duplicateLocalVariable1.ts(2,4): error TS1005: ';' expected.
tests/cases/compiler/duplicateLocalVariable1.ts(2,11): error TS1146: Declaration expected.
tests/cases/compiler/duplicateLocalVariable1.ts(2,13): error TS2304: Cannot find name 'commonjs'.
tests/cases/compiler/duplicateLocalVariable1.ts(12,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/compiler/duplicateLocalVariable1.ts(187,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'.
tests/cases/compiler/duplicateLocalVariable1.ts(187,29): error TS2365: Operator '<' cannot be applied to types 'string' and 'number'.
tests/cases/compiler/duplicateLocalVariable1.ts(187,37): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
==== tests/cases/compiler/duplicateLocalVariable1.ts (7 errors) ====
==== tests/cases/compiler/duplicateLocalVariable1.ts (6 errors) ====
/ /@module: commonjs
~
@@ -26,8 +25,6 @@ tests/cases/compiler/duplicateLocalVariable1.ts(187,37): error TS2356: An arithm
var TestFileDir = ".\\TempTestFiles";
export class TestCase {
~~~~~~~~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
constructor (public name: string, public test: ()=>boolean, public errorMessageRegEx?: string) {
}
}
@@ -0,0 +1,37 @@
//// [emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts]
class A {
blub = 6;
}
class B extends A {
constructor(public x: number) {
"use strict";
'someStringForEgngInject';
super()
}
}
//// [emitSuperCallBeforeEmitParameterPropertyDeclaration1.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var A = (function () {
function A() {
this.blub = 6;
}
return A;
}());
var B = (function (_super) {
__extends(B, _super);
function B(x) {
"use strict";
'someStringForEgngInject';
_super.call(this);
this.x = x;
}
return B;
}(A));
@@ -0,0 +1,23 @@
=== tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts ===
class A {
>A : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 0, 0))
blub = 6;
>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 0, 9))
}
class B extends A {
>B : Symbol(B, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 2, 1))
>A : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 0, 0))
constructor(public x: number) {
>x : Symbol(x, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 6, 16))
"use strict";
'someStringForEgngInject';
super()
>super : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 0, 0))
}
}
@@ -0,0 +1,29 @@
=== tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts ===
class A {
>A : A
blub = 6;
>blub : number
>6 : number
}
class B extends A {
>B : B
>A : A
constructor(public x: number) {
>x : number
"use strict";
>"use strict" : string
'someStringForEgngInject';
>'someStringForEgngInject' : string
super()
>super() : void
>super : typeof A
}
}
@@ -0,0 +1,29 @@
//// [emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts]
class A {
blub = 6;
}
class B extends A {
constructor(public x: number) {
"use strict";
'someStringForEgngInject';
super()
}
}
//// [emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js]
class A {
constructor() {
this.blub = 6;
}
}
class B extends A {
constructor(x) {
"use strict";
'someStringForEgngInject';
super();
this.x = x;
}
}
@@ -0,0 +1,23 @@
=== tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts ===
class A {
>A : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 0, 0))
blub = 6;
>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 0, 9))
}
class B extends A {
>B : Symbol(B, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 2, 1))
>A : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 0, 0))
constructor(public x: number) {
>x : Symbol(x, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 6, 16))
"use strict";
'someStringForEgngInject';
super()
>super : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 0, 0))
}
}
@@ -0,0 +1,29 @@
=== tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts ===
class A {
>A : A
blub = 6;
>blub : number
>6 : number
}
class B extends A {
>B : B
>A : A
constructor(public x: number) {
>x : number
"use strict";
>"use strict" : string
'someStringForEgngInject';
>'someStringForEgngInject' : string
super()
>super() : void
>super : typeof A
}
}
@@ -0,0 +1,39 @@
//// [emitSuperCallBeforeEmitPropertyDeclaration1.ts]
class A {
blub = 6;
}
class B extends A {
blub = 12;
constructor() {
"use strict";
'someStringForEgngInject';
super()
}
}
//// [emitSuperCallBeforeEmitPropertyDeclaration1.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var A = (function () {
function A() {
this.blub = 6;
}
return A;
}());
var B = (function (_super) {
__extends(B, _super);
function B() {
"use strict";
'someStringForEgngInject';
_super.call(this);
this.blub = 12;
}
return B;
}(A));
@@ -0,0 +1,23 @@
=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.ts ===
class A {
>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 0, 0))
blub = 6;
>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 0, 9))
}
class B extends A {
>B : Symbol(B, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 2, 1))
>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 0, 0))
blub = 12;
>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 5, 19))
constructor() {
"use strict";
'someStringForEgngInject';
super()
>super : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 0, 0))
}
}
@@ -0,0 +1,30 @@
=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.ts ===
class A {
>A : A
blub = 6;
>blub : number
>6 : number
}
class B extends A {
>B : B
>A : A
blub = 12;
>blub : number
>12 : number
constructor() {
"use strict";
>"use strict" : string
'someStringForEgngInject';
>'someStringForEgngInject' : string
super()
>super() : void
>super : typeof A
}
}
@@ -0,0 +1,29 @@
//// [emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts]
class A {
blub = 6;
}
class B extends A {
blub = 12;
constructor() {
'someStringForEgngInject';
super()
}
}
//// [emitSuperCallBeforeEmitPropertyDeclaration1ES6.js]
class A {
constructor() {
this.blub = 6;
}
}
class B extends A {
constructor() {
'someStringForEgngInject';
super();
this.blub = 12;
}
}
@@ -0,0 +1,22 @@
=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts ===
class A {
>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 0, 0))
blub = 6;
>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 0, 9))
}
class B extends A {
>B : Symbol(B, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 2, 1))
>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 0, 0))
blub = 12;
>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 5, 19))
constructor() {
'someStringForEgngInject';
super()
>super : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 0, 0))
}
}
@@ -0,0 +1,27 @@
=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts ===
class A {
>A : A
blub = 6;
>blub : number
>6 : number
}
class B extends A {
>B : B
>A : A
blub = 12;
>blub : number
>12 : number
constructor() {
'someStringForEgngInject';
>'someStringForEgngInject' : string
super()
>super() : void
>super : typeof A
}
}
@@ -0,0 +1,38 @@
//// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts]
class A {
blub = 6;
}
class B extends A {
blah = 2;
constructor(public x: number) {
"use strict";
'someStringForEgngInject';
super()
}
}
//// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var A = (function () {
function A() {
this.blub = 6;
}
return A;
}());
var B = (function (_super) {
__extends(B, _super);
function B(x) {
"use strict";
'someStringForEgngInject';
_super.call(this);
this.x = x;
this.blah = 2;
}
return B;
}(A));
@@ -0,0 +1,25 @@
=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts ===
class A {
>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 0, 0))
blub = 6;
>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 0, 9))
}
class B extends A {
>B : Symbol(B, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 2, 1))
>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 0, 0))
blah = 2;
>blah : Symbol(blah, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 5, 19))
constructor(public x: number) {
>x : Symbol(x, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 7, 16))
"use strict";
'someStringForEgngInject';
super()
>super : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 0, 0))
}
}
@@ -0,0 +1,32 @@
=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts ===
class A {
>A : A
blub = 6;
>blub : number
>6 : number
}
class B extends A {
>B : B
>A : A
blah = 2;
>blah : number
>2 : number
constructor(public x: number) {
>x : number
"use strict";
>"use strict" : string
'someStringForEgngInject';
>'someStringForEgngInject' : string
super()
>super() : void
>super : typeof A
}
}
@@ -0,0 +1,30 @@
//// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts]
class A {
blub = 6;
}
class B extends A {
blah = 2;
constructor(public x: number) {
"use strict";
'someStringForEgngInject';
super()
}
}
//// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js]
class A {
constructor() {
this.blub = 6;
}
}
class B extends A {
constructor(x) {
"use strict";
'someStringForEgngInject';
super();
this.x = x;
this.blah = 2;
}
}
@@ -0,0 +1,25 @@
=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts ===
class A {
>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 0, 0))
blub = 6;
>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 0, 9))
}
class B extends A {
>B : Symbol(B, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 2, 1))
>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 0, 0))
blah = 2;
>blah : Symbol(blah, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 5, 19))
constructor(public x: number) {
>x : Symbol(x, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 7, 16))
"use strict";
'someStringForEgngInject';
super()
>super : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 0, 0))
}
}
@@ -0,0 +1,32 @@
=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts ===
class A {
>A : A
blub = 6;
>blub : number
>6 : number
}
class B extends A {
>B : B
>A : A
blah = 2;
>blah : number
>2 : number
constructor(public x: number) {
>x : number
"use strict";
>"use strict" : string
'someStringForEgngInject';
>'someStringForEgngInject' : string
super()
>super() : void
>super : typeof A
}
}
@@ -1,17 +0,0 @@
tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
==== tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts (1 errors) ====
export class A
~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
{
constructor ()
{
}
public B()
{
return 42;
}
}
@@ -0,0 +1,14 @@
=== tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts ===
export class A
>A : Symbol(A, Decl(es5ModuleWithoutModuleGenTarget.ts, 0, 0))
{
constructor ()
{
}
public B()
>B : Symbol(B, Decl(es5ModuleWithoutModuleGenTarget.ts, 4, 5))
{
return 42;
}
}
@@ -0,0 +1,15 @@
=== tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts ===
export class A
>A : A
{
constructor ()
{
}
public B()
>B : () => number
{
return 42;
>42 : number
}
}
@@ -17,3 +17,4 @@ import "es6ImportWithoutFromClause_0";
//// [es6ImportWithoutFromClause_0.d.ts]
export declare var a: number;
//// [es6ImportWithoutFromClause_1.d.ts]
import "es6ImportWithoutFromClause_0";
@@ -36,3 +36,5 @@ export declare var a: number;
//// [es6ImportWithoutFromClauseAmd_1.d.ts]
export declare var b: number;
//// [es6ImportWithoutFromClauseAmd_2.d.ts]
import "es6ImportWithoutFromClauseAmd_0";
import "es6ImportWithoutFromClauseAmd_2";
@@ -18,3 +18,4 @@ require("es6ImportWithoutFromClauseInEs5_0");
//// [es6ImportWithoutFromClauseInEs5_0.d.ts]
export declare var a: number;
//// [es6ImportWithoutFromClauseInEs5_1.d.ts]
import "es6ImportWithoutFromClauseInEs5_0";
@@ -17,3 +17,4 @@ import "es6ImportWithoutFromClauseNonInstantiatedModule_0";
export interface i {
}
//// [es6ImportWithoutFromClauseNonInstantiatedModule_1.d.ts]
import "es6ImportWithoutFromClauseNonInstantiatedModule_0";
@@ -1,14 +0,0 @@
tests/cases/conformance/externalModules/foo1.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
==== tests/cases/conformance/externalModules/foo2.ts (0 errors) ====
import foo1 = require('./foo1');
export = foo1.x; // Ok
==== tests/cases/conformance/externalModules/foo1.ts (1 errors) ====
export function x(){
~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
return true;
}
@@ -0,0 +1,16 @@
=== tests/cases/conformance/externalModules/foo2.ts ===
import foo1 = require('./foo1');
>foo1 : Symbol(foo1, Decl(foo2.ts, 0, 0))
export = foo1.x; // Ok
>foo1.x : Symbol(foo1.x, Decl(foo1.ts, 0, 0))
>foo1 : Symbol(foo1, Decl(foo2.ts, 0, 0))
>x : Symbol(foo1.x, Decl(foo1.ts, 0, 0))
=== tests/cases/conformance/externalModules/foo1.ts ===
export function x(){
>x : Symbol(x, Decl(foo1.ts, 0, 0))
return true;
}
@@ -0,0 +1,17 @@
=== tests/cases/conformance/externalModules/foo2.ts ===
import foo1 = require('./foo1');
>foo1 : typeof foo1
export = foo1.x; // Ok
>foo1.x : () => boolean
>foo1 : typeof foo1
>x : () => boolean
=== tests/cases/conformance/externalModules/foo1.ts ===
export function x(){
>x : () => boolean
return true;
>true : boolean
}
@@ -1,18 +0,0 @@
tests/cases/conformance/externalModules/foo1.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
==== tests/cases/conformance/externalModules/foo3.ts (0 errors) ====
import foo2 = require('./foo2');
var x = foo2(); // should be boolean
==== tests/cases/conformance/externalModules/foo1.ts (1 errors) ====
export function x(){
~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
return true;
}
==== tests/cases/conformance/externalModules/foo2.ts (0 errors) ====
import foo1 = require('./foo1');
var x = foo1.x;
export = x;
@@ -0,0 +1,28 @@
=== tests/cases/conformance/externalModules/foo3.ts ===
import foo2 = require('./foo2');
>foo2 : Symbol(foo2, Decl(foo3.ts, 0, 0))
var x = foo2(); // should be boolean
>x : Symbol(x, Decl(foo3.ts, 1, 3))
>foo2 : Symbol(foo2, Decl(foo3.ts, 0, 0))
=== tests/cases/conformance/externalModules/foo1.ts ===
export function x(){
>x : Symbol(x, Decl(foo1.ts, 0, 0))
return true;
}
=== tests/cases/conformance/externalModules/foo2.ts ===
import foo1 = require('./foo1');
>foo1 : Symbol(foo1, Decl(foo2.ts, 0, 0))
var x = foo1.x;
>x : Symbol(x, Decl(foo2.ts, 1, 3))
>foo1.x : Symbol(foo1.x, Decl(foo1.ts, 0, 0))
>foo1 : Symbol(foo1, Decl(foo2.ts, 0, 0))
>x : Symbol(foo1.x, Decl(foo1.ts, 0, 0))
export = x;
>x : Symbol(x, Decl(foo2.ts, 1, 3))
@@ -0,0 +1,30 @@
=== tests/cases/conformance/externalModules/foo3.ts ===
import foo2 = require('./foo2');
>foo2 : () => boolean
var x = foo2(); // should be boolean
>x : boolean
>foo2() : boolean
>foo2 : () => boolean
=== tests/cases/conformance/externalModules/foo1.ts ===
export function x(){
>x : () => boolean
return true;
>true : boolean
}
=== tests/cases/conformance/externalModules/foo2.ts ===
import foo1 = require('./foo1');
>foo1 : typeof foo1
var x = foo1.x;
>x : () => boolean
>foo1.x : () => boolean
>foo1 : typeof foo1
>x : () => boolean
export = x;
>x : () => boolean
@@ -1,12 +1,9 @@
tests/cases/conformance/externalModules/foo1.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/conformance/externalModules/foo6.ts(1,14): error TS1109: Expression expected.
==== tests/cases/conformance/externalModules/foo1.ts (1 errors) ====
==== tests/cases/conformance/externalModules/foo1.ts (0 errors) ====
var x = 10;
export = typeof x; // Ok
~~~~~~~~~~~~~~~~~~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
==== tests/cases/conformance/externalModules/foo2.ts (0 errors) ====
export = "sausages"; // Ok
@@ -1,57 +0,0 @@
tests/cases/conformance/externalModules/expString.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
==== tests/cases/conformance/externalModules/consumer.ts (0 errors) ====
import iString = require('./expString');
var v1: string = iString;
import iNumber = require('./expNumber');
var v2: number = iNumber;
import iBoolean = require('./expBoolean');
var v3: boolean = iBoolean;
import iArray = require('./expArray');
var v4: Array<number> = iArray;
import iObject = require('./expObject');
var v5: Object = iObject;
import iAny = require('./expAny');
var v6 = iAny;
import iGeneric = require('./expGeneric');
var v7: {<x>(p1: x): x} = iGeneric;
==== tests/cases/conformance/externalModules/expString.ts (1 errors) ====
var x = "test";
export = x;
~~~~~~~~~~~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
==== tests/cases/conformance/externalModules/expNumber.ts (0 errors) ====
var x = 42;
export = x;
==== tests/cases/conformance/externalModules/expBoolean.ts (0 errors) ====
var x = true;
export = x;
==== tests/cases/conformance/externalModules/expArray.ts (0 errors) ====
var x = [1,2];
export = x;
==== tests/cases/conformance/externalModules/expObject.ts (0 errors) ====
var x = { answer: 42, when: 1776};
export = x;
==== tests/cases/conformance/externalModules/expAny.ts (0 errors) ====
var x;
export = x;
==== tests/cases/conformance/externalModules/expGeneric.ts (0 errors) ====
function x<T>(a: T){
return a;
}
export = x;
@@ -0,0 +1,113 @@
=== tests/cases/conformance/externalModules/consumer.ts ===
import iString = require('./expString');
>iString : Symbol(iString, Decl(consumer.ts, 0, 0))
var v1: string = iString;
>v1 : Symbol(v1, Decl(consumer.ts, 1, 3))
>iString : Symbol(iString, Decl(consumer.ts, 0, 0))
import iNumber = require('./expNumber');
>iNumber : Symbol(iNumber, Decl(consumer.ts, 1, 25))
var v2: number = iNumber;
>v2 : Symbol(v2, Decl(consumer.ts, 4, 3))
>iNumber : Symbol(iNumber, Decl(consumer.ts, 1, 25))
import iBoolean = require('./expBoolean');
>iBoolean : Symbol(iBoolean, Decl(consumer.ts, 4, 25))
var v3: boolean = iBoolean;
>v3 : Symbol(v3, Decl(consumer.ts, 7, 3))
>iBoolean : Symbol(iBoolean, Decl(consumer.ts, 4, 25))
import iArray = require('./expArray');
>iArray : Symbol(iArray, Decl(consumer.ts, 7, 27))
var v4: Array<number> = iArray;
>v4 : Symbol(v4, Decl(consumer.ts, 10, 3))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>iArray : Symbol(iArray, Decl(consumer.ts, 7, 27))
import iObject = require('./expObject');
>iObject : Symbol(iObject, Decl(consumer.ts, 10, 31))
var v5: Object = iObject;
>v5 : Symbol(v5, Decl(consumer.ts, 13, 3))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>iObject : Symbol(iObject, Decl(consumer.ts, 10, 31))
import iAny = require('./expAny');
>iAny : Symbol(iAny, Decl(consumer.ts, 13, 25))
var v6 = iAny;
>v6 : Symbol(v6, Decl(consumer.ts, 16, 3))
>iAny : Symbol(iAny, Decl(consumer.ts, 13, 25))
import iGeneric = require('./expGeneric');
>iGeneric : Symbol(iGeneric, Decl(consumer.ts, 16, 14))
var v7: {<x>(p1: x): x} = iGeneric;
>v7 : Symbol(v7, Decl(consumer.ts, 19, 3))
>x : Symbol(x, Decl(consumer.ts, 19, 10))
>p1 : Symbol(p1, Decl(consumer.ts, 19, 13))
>x : Symbol(x, Decl(consumer.ts, 19, 10))
>x : Symbol(x, Decl(consumer.ts, 19, 10))
>iGeneric : Symbol(iGeneric, Decl(consumer.ts, 16, 14))
=== tests/cases/conformance/externalModules/expString.ts ===
var x = "test";
>x : Symbol(x, Decl(expString.ts, 0, 3))
export = x;
>x : Symbol(x, Decl(expString.ts, 0, 3))
=== tests/cases/conformance/externalModules/expNumber.ts ===
var x = 42;
>x : Symbol(x, Decl(expNumber.ts, 0, 3))
export = x;
>x : Symbol(x, Decl(expNumber.ts, 0, 3))
=== tests/cases/conformance/externalModules/expBoolean.ts ===
var x = true;
>x : Symbol(x, Decl(expBoolean.ts, 0, 3))
export = x;
>x : Symbol(x, Decl(expBoolean.ts, 0, 3))
=== tests/cases/conformance/externalModules/expArray.ts ===
var x = [1,2];
>x : Symbol(x, Decl(expArray.ts, 0, 3))
export = x;
>x : Symbol(x, Decl(expArray.ts, 0, 3))
=== tests/cases/conformance/externalModules/expObject.ts ===
var x = { answer: 42, when: 1776};
>x : Symbol(x, Decl(expObject.ts, 0, 3))
>answer : Symbol(answer, Decl(expObject.ts, 0, 9))
>when : Symbol(when, Decl(expObject.ts, 0, 21))
export = x;
>x : Symbol(x, Decl(expObject.ts, 0, 3))
=== tests/cases/conformance/externalModules/expAny.ts ===
var x;
>x : Symbol(x, Decl(expAny.ts, 0, 3))
export = x;
>x : Symbol(x, Decl(expAny.ts, 0, 3))
=== tests/cases/conformance/externalModules/expGeneric.ts ===
function x<T>(a: T){
>x : Symbol(x, Decl(expGeneric.ts, 0, 0))
>T : Symbol(T, Decl(expGeneric.ts, 0, 11))
>a : Symbol(a, Decl(expGeneric.ts, 0, 14))
>T : Symbol(T, Decl(expGeneric.ts, 0, 11))
return a;
>a : Symbol(a, Decl(expGeneric.ts, 0, 14))
}
export = x;
>x : Symbol(x, Decl(expGeneric.ts, 0, 0))

Some files were not shown because too many files have changed in this diff Show More