Merge branch 'funcDeclsInBlocks' into sourceFileUpdate
Conflicts: src/compiler/parser.ts src/compiler/utilities.ts
This commit is contained in:
commit
8917e96663
32 changed files with 289 additions and 261 deletions
|
@ -206,7 +206,8 @@ module ts {
|
||||||
if (symbolKind & SymbolFlags.Namespace) {
|
if (symbolKind & SymbolFlags.Namespace) {
|
||||||
exportKind |= SymbolFlags.ExportNamespace;
|
exportKind |= SymbolFlags.ExportNamespace;
|
||||||
}
|
}
|
||||||
if (node.flags & NodeFlags.Export || (node.kind !== SyntaxKind.ImportDeclaration && isAmbientContext(container))) {
|
|
||||||
|
if (getNodeFlags(node) & NodeFlags.Export || (node.kind !== SyntaxKind.ImportDeclaration && isAmbientContext(container))) {
|
||||||
if (exportKind) {
|
if (exportKind) {
|
||||||
var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
|
var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
|
||||||
local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
|
local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
|
||||||
|
@ -389,7 +390,7 @@ module ts {
|
||||||
if (isBindingPattern((<Declaration>node).name)) {
|
if (isBindingPattern((<Declaration>node).name)) {
|
||||||
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
|
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
|
||||||
}
|
}
|
||||||
else if (node.flags & NodeFlags.BlockScoped) {
|
else if (getNodeFlags(node) & NodeFlags.BlockScoped) {
|
||||||
bindBlockScopedVariableDeclaration(<Declaration>node);
|
bindBlockScopedVariableDeclaration(<Declaration>node);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -16,7 +16,6 @@ module ts {
|
||||||
/// If fullTypeCheck === false, the typechecker can take shortcuts and skip checks that only produce errors.
|
/// If fullTypeCheck === false, the typechecker can take shortcuts and skip checks that only produce errors.
|
||||||
/// NOTE: checks that somehow affect decisions being made during typechecking should be executed in both cases.
|
/// NOTE: checks that somehow affect decisions being made during typechecking should be executed in both cases.
|
||||||
export function createTypeChecker(program: Program, fullTypeCheck: boolean): TypeChecker {
|
export function createTypeChecker(program: Program, fullTypeCheck: boolean): TypeChecker {
|
||||||
|
|
||||||
var Symbol = objectAllocator.getSymbolConstructor();
|
var Symbol = objectAllocator.getSymbolConstructor();
|
||||||
var Type = objectAllocator.getTypeConstructor();
|
var Type = objectAllocator.getTypeConstructor();
|
||||||
var Signature = objectAllocator.getSignatureConstructor();
|
var Signature = objectAllocator.getSignatureConstructor();
|
||||||
|
@ -407,7 +406,7 @@ module ts {
|
||||||
}
|
}
|
||||||
if (result.flags & SymbolFlags.BlockScopedVariable) {
|
if (result.flags & SymbolFlags.BlockScopedVariable) {
|
||||||
// Block-scoped variables cannot be used before their definition
|
// Block-scoped variables cannot be used before their definition
|
||||||
var declaration = forEach(result.declarations, d => d.flags & NodeFlags.BlockScoped ? d : undefined);
|
var declaration = forEach(result.declarations, d => getNodeFlags(d) & NodeFlags.BlockScoped ? d : undefined);
|
||||||
Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
|
Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
|
||||||
if (!isDefinedBefore(declaration, errorLocation)) {
|
if (!isDefinedBefore(declaration, errorLocation)) {
|
||||||
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name));
|
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name));
|
||||||
|
@ -764,7 +763,7 @@ module ts {
|
||||||
// if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table)
|
// 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 symbolfrom symbolTable or alias resolution matches the symbol,
|
||||||
// check the symbol can be qualified, it is only then this symbol is accessible
|
// check the symbol can be qualified, it is only then this symbol is accessible
|
||||||
return !forEach(symbolFromSymbolTable.declarations, declaration => hasExternalModuleSymbol(declaration)) &&
|
return !forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) &&
|
||||||
canQualifySymbol(symbolFromSymbolTable, meaning);
|
canQualifySymbol(symbolFromSymbolTable, meaning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -868,7 +867,7 @@ module ts {
|
||||||
|
|
||||||
// This could be a symbol that is not exported in the external module
|
// This could be a symbol that is not exported in the external module
|
||||||
// or it could be a symbol from different external module that is not aliased and hence cannot be named
|
// or it could be a symbol from different external module that is not aliased and hence cannot be named
|
||||||
var symbolExternalModule = forEach(initialSymbol.declarations, declaration => getExternalModuleContainer(declaration));
|
var symbolExternalModule = forEach(initialSymbol.declarations, getExternalModuleContainer);
|
||||||
if (symbolExternalModule) {
|
if (symbolExternalModule) {
|
||||||
var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
|
var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
|
||||||
if (symbolExternalModule !== enclosingExternalModule) {
|
if (symbolExternalModule !== enclosingExternalModule) {
|
||||||
|
@ -1088,7 +1087,7 @@ module ts {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If we didn't find accessible symbol chain for this symbol, break if this is external module
|
// If we didn't find accessible symbol chain for this symbol, break if this is external module
|
||||||
if (!parentSymbol && ts.forEach(symbol.declarations, declaration => hasExternalModuleSymbol(declaration))) {
|
if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1557,7 +1556,7 @@ module ts {
|
||||||
case SyntaxKind.ImportDeclaration:
|
case SyntaxKind.ImportDeclaration:
|
||||||
var parent = getDeclarationContainer(node);
|
var parent = getDeclarationContainer(node);
|
||||||
// If the node is not exported or it is not ambient module element (except import declaration)
|
// If the node is not exported or it is not ambient module element (except import declaration)
|
||||||
if (!(node.flags & NodeFlags.Export) &&
|
if (!(getNodeFlags(node) & NodeFlags.Export) &&
|
||||||
!(node.kind !== SyntaxKind.ImportDeclaration && parent.kind !== SyntaxKind.SourceFile && isInAmbientContext(parent))) {
|
!(node.kind !== SyntaxKind.ImportDeclaration && parent.kind !== SyntaxKind.SourceFile && isInAmbientContext(parent))) {
|
||||||
return isGlobalSourceFile(parent) || isUsedInExportAssignment(node);
|
return isGlobalSourceFile(parent) || isUsedInExportAssignment(node);
|
||||||
}
|
}
|
||||||
|
@ -1620,7 +1619,7 @@ module ts {
|
||||||
|
|
||||||
function getDeclarationContainer(node: Node): Node {
|
function getDeclarationContainer(node: Node): Node {
|
||||||
node = getRootDeclaration(node);
|
node = getRootDeclaration(node);
|
||||||
return node.kind === SyntaxKind.VariableDeclaration ? node.parent.parent : node.parent;
|
return node.kind === SyntaxKind.VariableDeclaration ? node.parent.parent.parent : node.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTypeOfPrototypeProperty(prototype: Symbol): Type {
|
function getTypeOfPrototypeProperty(prototype: Symbol): Type {
|
||||||
|
@ -1687,7 +1686,7 @@ module ts {
|
||||||
// Return the inferred type for a variable, parameter, or property declaration
|
// Return the inferred type for a variable, parameter, or property declaration
|
||||||
function getTypeForVariableLikeDeclaration(declaration: VariableLikeDeclaration): Type {
|
function getTypeForVariableLikeDeclaration(declaration: VariableLikeDeclaration): Type {
|
||||||
// A variable declared in a for..in statement is always of type any
|
// A variable declared in a for..in statement is always of type any
|
||||||
if (declaration.parent.kind === SyntaxKind.ForInStatement) {
|
if (declaration.parent.parent.kind === SyntaxKind.ForInStatement) {
|
||||||
return anyType;
|
return anyType;
|
||||||
}
|
}
|
||||||
if (isBindingPattern(declaration.parent)) {
|
if (isBindingPattern(declaration.parent)) {
|
||||||
|
@ -4102,7 +4101,7 @@ module ts {
|
||||||
return anyType;
|
return anyType;
|
||||||
}
|
}
|
||||||
if (type.flags & TypeFlags.Union) {
|
if (type.flags & TypeFlags.Union) {
|
||||||
return getUnionType(map((<UnionType>type).types, t => getWidenedType(t)));
|
return getUnionType(map((<UnionType>type).types, getWidenedType));
|
||||||
}
|
}
|
||||||
if (isTypeOfObjectLiteral(type)) {
|
if (isTypeOfObjectLiteral(type)) {
|
||||||
return getWidenedTypeOfObjectLiteral(type);
|
return getWidenedTypeOfObjectLiteral(type);
|
||||||
|
@ -5108,7 +5107,7 @@ module ts {
|
||||||
|
|
||||||
// Return true if the given contextual type is a tuple-like type
|
// Return true if the given contextual type is a tuple-like type
|
||||||
function contextualTypeIsTupleLikeType(type: Type): boolean {
|
function contextualTypeIsTupleLikeType(type: Type): boolean {
|
||||||
return !!(type.flags & TypeFlags.Union ? forEach((<UnionType>type).types, t => isTupleLikeType(t)) : isTupleLikeType(type));
|
return !!(type.flags & TypeFlags.Union ? forEach((<UnionType>type).types, isTupleLikeType) : isTupleLikeType(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if the given contextual type provides an index signature of the given kind
|
// Return true if the given contextual type provides an index signature of the given kind
|
||||||
|
@ -5420,7 +5419,7 @@ module ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDeclarationFlagsFromSymbol(s: Symbol) {
|
function getDeclarationFlagsFromSymbol(s: Symbol) {
|
||||||
return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & SymbolFlags.Prototype ? NodeFlags.Public | NodeFlags.Static : 0;
|
return s.valueDeclaration ? getNodeFlags(s.valueDeclaration) : s.flags & SymbolFlags.Prototype ? NodeFlags.Public | NodeFlags.Static : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol) {
|
function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol) {
|
||||||
|
@ -7306,7 +7305,7 @@ module ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags) {
|
function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags) {
|
||||||
var flags = n.flags;
|
var flags = getNodeFlags(n);
|
||||||
if (n.parent.kind !== SyntaxKind.InterfaceDeclaration && isInAmbientContext(n)) {
|
if (n.parent.kind !== SyntaxKind.InterfaceDeclaration && isInAmbientContext(n)) {
|
||||||
if (!(flags & NodeFlags.Ambient)) {
|
if (!(flags & NodeFlags.Ambient)) {
|
||||||
// It is nested in an ambient context, which means it is automatically exported
|
// It is nested in an ambient context, which means it is automatically exported
|
||||||
|
@ -7782,7 +7781,7 @@ module ts {
|
||||||
// const x = 0;
|
// const x = 0;
|
||||||
// var x = 0;
|
// var x = 0;
|
||||||
// }
|
// }
|
||||||
if (node.initializer && (node.flags & NodeFlags.BlockScoped) === 0) {
|
if (node.initializer && (getNodeFlags(node) & NodeFlags.BlockScoped) === 0) {
|
||||||
var symbol = getSymbolOfNode(node);
|
var symbol = getSymbolOfNode(node);
|
||||||
if (symbol.flags & SymbolFlags.FunctionScopedVariable) {
|
if (symbol.flags & SymbolFlags.FunctionScopedVariable) {
|
||||||
var localDeclarationSymbol = resolveName(node, (<Identifier>node.name).text, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined);
|
var localDeclarationSymbol = resolveName(node, (<Identifier>node.name).text, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined);
|
||||||
|
@ -7834,6 +7833,10 @@ module ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkVariableDeclaration(node: VariableDeclaration) {
|
||||||
|
return checkVariableLikeDeclaration(node);
|
||||||
|
}
|
||||||
|
|
||||||
// Check variable, parameter, or property declaration
|
// Check variable, parameter, or property declaration
|
||||||
function checkVariableLikeDeclaration(node: VariableLikeDeclaration) {
|
function checkVariableLikeDeclaration(node: VariableLikeDeclaration) {
|
||||||
checkSourceElement(node.type);
|
checkSourceElement(node.type);
|
||||||
|
@ -7892,7 +7895,7 @@ module ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkVariableStatement(node: VariableStatement) {
|
function checkVariableStatement(node: VariableStatement) {
|
||||||
forEach(node.declarations, checkSourceElement);
|
forEach(node.declarationList.declarations, checkSourceElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkExpressionStatement(node: ExpressionStatement) {
|
function checkExpressionStatement(node: ExpressionStatement) {
|
||||||
|
@ -7916,8 +7919,15 @@ module ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkForStatement(node: ForStatement) {
|
function checkForStatement(node: ForStatement) {
|
||||||
if (node.declarations) forEach(<VariableLikeDeclaration[]>node.declarations, checkVariableLikeDeclaration);
|
if (node.initializer) {
|
||||||
if (node.initializer) checkExpression(node.initializer);
|
if (node.initializer.kind === SyntaxKind.VariableDeclarationList) {
|
||||||
|
forEach((<VariableDeclarationList>node.initializer).declarations, checkVariableDeclaration)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
checkExpression(<Expression>node.initializer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (node.condition) checkExpression(node.condition);
|
if (node.condition) checkExpression(node.condition);
|
||||||
if (node.iterator) checkExpression(node.iterator);
|
if (node.iterator) checkExpression(node.iterator);
|
||||||
checkSourceElement(node.statement);
|
checkSourceElement(node.statement);
|
||||||
|
@ -7930,28 +7940,29 @@ module ts {
|
||||||
// for (var VarDecl in Expr) Statement
|
// for (var VarDecl in Expr) Statement
|
||||||
// VarDecl must be a variable declaration without a type annotation that declares a variable of type Any,
|
// VarDecl must be a variable declaration without a type annotation that declares a variable of type Any,
|
||||||
// and Expr must be an expression of type Any, an object type, or a type parameter type.
|
// and Expr must be an expression of type Any, an object type, or a type parameter type.
|
||||||
if (node.declarations) {
|
if (node.initializer.kind === SyntaxKind.VariableDeclarationList) {
|
||||||
if (node.declarations.length >= 1) {
|
var variableDeclarationList = <VariableDeclarationList>node.initializer;
|
||||||
var decl = node.declarations[0];
|
if (variableDeclarationList.declarations.length >= 1) {
|
||||||
|
var decl = variableDeclarationList.declarations[0];
|
||||||
checkVariableLikeDeclaration(decl);
|
checkVariableLikeDeclaration(decl);
|
||||||
if (decl.type) {
|
if (decl.type) {
|
||||||
error(decl, Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation);
|
error(decl, Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
// In a 'for-in' statement of the form
|
// In a 'for-in' statement of the form
|
||||||
// for (Var in Expr) Statement
|
// for (Var in Expr) Statement
|
||||||
// Var must be an expression classified as a reference of type Any or the String primitive type,
|
// Var must be an expression classified as a reference of type Any or the String primitive type,
|
||||||
// and Expr must be an expression of type Any, an object type, or a type parameter type.
|
// and Expr must be an expression of type Any, an object type, or a type parameter type.
|
||||||
if (node.variable) {
|
var varExpr = <Expression>node.initializer;
|
||||||
var exprType = checkExpression(node.variable);
|
var exprType = checkExpression(varExpr);
|
||||||
if (exprType !== anyType && exprType !== stringType) {
|
if (exprType !== anyType && exprType !== stringType) {
|
||||||
error(node.variable, Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any);
|
error(varExpr, Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// run check only former check succeeded to avoid cascading errors
|
// run check only former check succeeded to avoid cascading errors
|
||||||
checkReferenceExpression(node.variable, Diagnostics.Invalid_left_hand_side_in_for_in_statement, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant);
|
checkReferenceExpression(varExpr, Diagnostics.Invalid_left_hand_side_in_for_in_statement, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8879,6 +8890,7 @@ module ts {
|
||||||
case SyntaxKind.TryStatement:
|
case SyntaxKind.TryStatement:
|
||||||
case SyntaxKind.CatchClause:
|
case SyntaxKind.CatchClause:
|
||||||
case SyntaxKind.VariableDeclaration:
|
case SyntaxKind.VariableDeclaration:
|
||||||
|
case SyntaxKind.VariableDeclarationList:
|
||||||
case SyntaxKind.ClassDeclaration:
|
case SyntaxKind.ClassDeclaration:
|
||||||
case SyntaxKind.EnumDeclaration:
|
case SyntaxKind.EnumDeclaration:
|
||||||
case SyntaxKind.EnumMember:
|
case SyntaxKind.EnumMember:
|
||||||
|
|
|
@ -1014,20 +1014,20 @@ module ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitVariableStatement(node: VariableStatement) {
|
function emitVariableStatement(node: VariableStatement) {
|
||||||
var hasDeclarationWithEmit = forEach(node.declarations, varDeclaration => resolver.isDeclarationVisible(varDeclaration));
|
var hasDeclarationWithEmit = forEach(node.declarationList.declarations, varDeclaration => resolver.isDeclarationVisible(varDeclaration));
|
||||||
if (hasDeclarationWithEmit) {
|
if (hasDeclarationWithEmit) {
|
||||||
emitJsDocComments(node);
|
emitJsDocComments(node);
|
||||||
emitModuleElementDeclarationFlags(node);
|
emitModuleElementDeclarationFlags(node);
|
||||||
if (isLet(node)) {
|
if (isLet(node.declarationList)) {
|
||||||
write("let ");
|
write("let ");
|
||||||
}
|
}
|
||||||
else if (isConst(node)) {
|
else if (isConst(node.declarationList)) {
|
||||||
write("const ");
|
write("const ");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
write("var ");
|
write("var ");
|
||||||
}
|
}
|
||||||
emitCommaList(node.declarations, emitVariableDeclaration);
|
emitCommaList(node.declarationList.declarations, emitVariableDeclaration);
|
||||||
write(";");
|
write(";");
|
||||||
writeLine();
|
writeLine();
|
||||||
}
|
}
|
||||||
|
@ -2610,20 +2610,22 @@ module ts {
|
||||||
var endPos = emitToken(SyntaxKind.ForKeyword, node.pos);
|
var endPos = emitToken(SyntaxKind.ForKeyword, node.pos);
|
||||||
write(" ");
|
write(" ");
|
||||||
endPos = emitToken(SyntaxKind.OpenParenToken, endPos);
|
endPos = emitToken(SyntaxKind.OpenParenToken, endPos);
|
||||||
if (node.declarations) {
|
if (node.initializer && node.initializer.kind === SyntaxKind.VariableDeclarationList) {
|
||||||
if (node.declarations[0] && isLet(node.declarations[0])) {
|
var variableDeclarationList = <VariableDeclarationList>node.initializer;
|
||||||
|
var declarations = variableDeclarationList.declarations;
|
||||||
|
if (declarations[0] && isLet(declarations[0])) {
|
||||||
emitToken(SyntaxKind.LetKeyword, endPos);
|
emitToken(SyntaxKind.LetKeyword, endPos);
|
||||||
}
|
}
|
||||||
else if (node.declarations[0] && isConst(node.declarations[0])) {
|
else if (declarations[0] && isConst(declarations[0])) {
|
||||||
emitToken(SyntaxKind.ConstKeyword, endPos);
|
emitToken(SyntaxKind.ConstKeyword, endPos);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emitToken(SyntaxKind.VarKeyword, endPos);
|
emitToken(SyntaxKind.VarKeyword, endPos);
|
||||||
}
|
}
|
||||||
write(" ");
|
write(" ");
|
||||||
emitCommaList(node.declarations);
|
emitCommaList(variableDeclarationList.declarations);
|
||||||
}
|
}
|
||||||
if (node.initializer) {
|
else if (node.initializer) {
|
||||||
emit(node.initializer);
|
emit(node.initializer);
|
||||||
}
|
}
|
||||||
write(";");
|
write(";");
|
||||||
|
@ -2638,9 +2640,10 @@ module ts {
|
||||||
var endPos = emitToken(SyntaxKind.ForKeyword, node.pos);
|
var endPos = emitToken(SyntaxKind.ForKeyword, node.pos);
|
||||||
write(" ");
|
write(" ");
|
||||||
endPos = emitToken(SyntaxKind.OpenParenToken, endPos);
|
endPos = emitToken(SyntaxKind.OpenParenToken, endPos);
|
||||||
if (node.declarations) {
|
if (node.initializer.kind === SyntaxKind.VariableDeclarationList) {
|
||||||
if (node.declarations.length >= 1) {
|
var variableDeclarationList = <VariableDeclarationList>node.initializer;
|
||||||
var decl = node.declarations[0];
|
if (variableDeclarationList.declarations.length >= 1) {
|
||||||
|
var decl = variableDeclarationList.declarations[0];
|
||||||
if (isLet(decl)) {
|
if (isLet(decl)) {
|
||||||
emitToken(SyntaxKind.LetKeyword, endPos);
|
emitToken(SyntaxKind.LetKeyword, endPos);
|
||||||
}
|
}
|
||||||
|
@ -2652,7 +2655,7 @@ module ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emit(node.variable);
|
emit(node.initializer);
|
||||||
}
|
}
|
||||||
write(" in ");
|
write(" in ");
|
||||||
emit(node.expression);
|
emit(node.expression);
|
||||||
|
@ -2769,7 +2772,7 @@ module ts {
|
||||||
|
|
||||||
function emitModuleMemberName(node: Declaration) {
|
function emitModuleMemberName(node: Declaration) {
|
||||||
emitStart(node.name);
|
emitStart(node.name);
|
||||||
if (node.flags & NodeFlags.Export) {
|
if (getNodeFlags(node) & NodeFlags.Export) {
|
||||||
var container = getContainingModule(node);
|
var container = getContainingModule(node);
|
||||||
write(container ? resolver.getLocalNameOfContainer(container) : "exports");
|
write(container ? resolver.getLocalNameOfContainer(container) : "exports");
|
||||||
write(".");
|
write(".");
|
||||||
|
@ -2782,7 +2785,7 @@ module ts {
|
||||||
var emitCount = 0;
|
var emitCount = 0;
|
||||||
// An exported declaration is actually emitted as an assignment (to a property on the module object), so
|
// An exported declaration is actually emitted as an assignment (to a property on the module object), so
|
||||||
// temporary variables in an exported declaration need to have real declarations elsewhere
|
// temporary variables in an exported declaration need to have real declarations elsewhere
|
||||||
var isDeclaration = (root.kind === SyntaxKind.VariableDeclaration && !(root.flags & NodeFlags.Export)) || root.kind === SyntaxKind.Parameter;
|
var isDeclaration = (root.kind === SyntaxKind.VariableDeclaration && !(getNodeFlags(root) & NodeFlags.Export)) || root.kind === SyntaxKind.Parameter;
|
||||||
if (root.kind === SyntaxKind.BinaryExpression) {
|
if (root.kind === SyntaxKind.BinaryExpression) {
|
||||||
emitAssignmentExpression(<BinaryExpression>root);
|
emitAssignmentExpression(<BinaryExpression>root);
|
||||||
}
|
}
|
||||||
|
@ -2991,17 +2994,17 @@ module ts {
|
||||||
function emitVariableStatement(node: VariableStatement) {
|
function emitVariableStatement(node: VariableStatement) {
|
||||||
emitLeadingComments(node);
|
emitLeadingComments(node);
|
||||||
if (!(node.flags & NodeFlags.Export)) {
|
if (!(node.flags & NodeFlags.Export)) {
|
||||||
if (isLet(node)) {
|
if (isLet(node.declarationList)) {
|
||||||
write("let ");
|
write("let ");
|
||||||
}
|
}
|
||||||
else if (isConst(node)) {
|
else if (isConst(node.declarationList)) {
|
||||||
write("const ");
|
write("const ");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
write("var ");
|
write("var ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emitCommaList(node.declarations);
|
emitCommaList(node.declarationList.declarations);
|
||||||
write(";");
|
write(";");
|
||||||
emitTrailingComments(node);
|
emitTrailingComments(node);
|
||||||
}
|
}
|
||||||
|
@ -3818,6 +3821,7 @@ module ts {
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.flags & NodeFlags.Ambient) {
|
if (node.flags & NodeFlags.Ambient) {
|
||||||
return emitPinnedOrTripleSlashComments(node);
|
return emitPinnedOrTripleSlashComments(node);
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,9 @@ module ts {
|
||||||
child((<SourceFile>node).endOfFileToken);
|
child((<SourceFile>node).endOfFileToken);
|
||||||
case SyntaxKind.VariableStatement:
|
case SyntaxKind.VariableStatement:
|
||||||
return children(node.modifiers) ||
|
return children(node.modifiers) ||
|
||||||
children((<VariableStatement>node).declarations);
|
child((<VariableStatement>node).declarationList);
|
||||||
|
case SyntaxKind.VariableDeclarationList:
|
||||||
|
return children((<VariableDeclarationList>node).declarations);
|
||||||
case SyntaxKind.ExpressionStatement:
|
case SyntaxKind.ExpressionStatement:
|
||||||
return child((<ExpressionStatement>node).expression);
|
return child((<ExpressionStatement>node).expression);
|
||||||
case SyntaxKind.IfStatement:
|
case SyntaxKind.IfStatement:
|
||||||
|
@ -172,14 +174,12 @@ module ts {
|
||||||
return child((<WhileStatement>node).expression) ||
|
return child((<WhileStatement>node).expression) ||
|
||||||
child((<WhileStatement>node).statement);
|
child((<WhileStatement>node).statement);
|
||||||
case SyntaxKind.ForStatement:
|
case SyntaxKind.ForStatement:
|
||||||
return children((<ForStatement>node).declarations) ||
|
return child((<ForStatement>node).initializer) ||
|
||||||
child((<ForStatement>node).initializer) ||
|
|
||||||
child((<ForStatement>node).condition) ||
|
child((<ForStatement>node).condition) ||
|
||||||
child((<ForStatement>node).iterator) ||
|
child((<ForStatement>node).iterator) ||
|
||||||
child((<ForStatement>node).statement);
|
child((<ForStatement>node).statement);
|
||||||
case SyntaxKind.ForInStatement:
|
case SyntaxKind.ForInStatement:
|
||||||
return children((<ForInStatement>node).declarations) ||
|
return child((<ForInStatement>node).initializer) ||
|
||||||
child((<ForInStatement>node).variable) ||
|
|
||||||
child((<ForInStatement>node).expression) ||
|
child((<ForInStatement>node).expression) ||
|
||||||
child((<ForInStatement>node).statement);
|
child((<ForInStatement>node).statement);
|
||||||
case SyntaxKind.ContinueStatement:
|
case SyntaxKind.ContinueStatement:
|
||||||
|
@ -3769,42 +3769,27 @@ module ts {
|
||||||
var pos = getNodePos();
|
var pos = getNodePos();
|
||||||
parseExpected(SyntaxKind.ForKeyword);
|
parseExpected(SyntaxKind.ForKeyword);
|
||||||
parseExpected(SyntaxKind.OpenParenToken);
|
parseExpected(SyntaxKind.OpenParenToken);
|
||||||
|
|
||||||
|
var initializer: VariableDeclarationList | Expression = undefined;
|
||||||
if (token !== SyntaxKind.SemicolonToken) {
|
if (token !== SyntaxKind.SemicolonToken) {
|
||||||
if (parseOptional(SyntaxKind.VarKeyword)) {
|
if (token === SyntaxKind.VarKeyword || token === SyntaxKind.LetKeyword || token === SyntaxKind.ConstKeyword) {
|
||||||
var declarations = disallowInAnd(parseVariableDeclarationList);
|
initializer = parseVariableDeclarationList(/*disallowIn:*/ true);
|
||||||
}
|
|
||||||
else if (parseOptional(SyntaxKind.LetKeyword)) {
|
|
||||||
var declarations = setFlag(disallowInAnd(parseVariableDeclarationList), NodeFlags.Let);
|
|
||||||
}
|
|
||||||
else if (parseOptional(SyntaxKind.ConstKeyword)) {
|
|
||||||
var declarations = setFlag(disallowInAnd(parseVariableDeclarationList), NodeFlags.Const);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var varOrInit = disallowInAnd(parseExpression);
|
initializer = disallowInAnd(parseExpression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var forOrForInStatement: IterationStatement;
|
var forOrForInStatement: IterationStatement;
|
||||||
if (parseOptional(SyntaxKind.InKeyword)) {
|
if (parseOptional(SyntaxKind.InKeyword)) {
|
||||||
var forInStatement = <ForInStatement>createNode(SyntaxKind.ForInStatement, pos);
|
var forInStatement = <ForInStatement>createNode(SyntaxKind.ForInStatement, pos);
|
||||||
if (declarations) {
|
forInStatement.initializer = initializer;
|
||||||
forInStatement.declarations = declarations;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
forInStatement.variable = varOrInit;
|
|
||||||
}
|
|
||||||
forInStatement.expression = allowInAnd(parseExpression);
|
forInStatement.expression = allowInAnd(parseExpression);
|
||||||
parseExpected(SyntaxKind.CloseParenToken);
|
parseExpected(SyntaxKind.CloseParenToken);
|
||||||
forOrForInStatement = forInStatement;
|
forOrForInStatement = forInStatement;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var forStatement = <ForStatement>createNode(SyntaxKind.ForStatement, pos);
|
var forStatement = <ForStatement>createNode(SyntaxKind.ForStatement, pos);
|
||||||
if (declarations) {
|
forStatement.initializer = initializer;
|
||||||
forStatement.declarations = declarations;
|
|
||||||
}
|
|
||||||
if (varOrInit) {
|
|
||||||
forStatement.initializer = varOrInit;
|
|
||||||
}
|
|
||||||
|
|
||||||
parseExpected(SyntaxKind.SemicolonToken);
|
parseExpected(SyntaxKind.SemicolonToken);
|
||||||
if (token !== SyntaxKind.SemicolonToken && token !== SyntaxKind.CloseParenToken) {
|
if (token !== SyntaxKind.SemicolonToken && token !== SyntaxKind.CloseParenToken) {
|
||||||
forStatement.condition = allowInAnd(parseExpression);
|
forStatement.condition = allowInAnd(parseExpression);
|
||||||
|
@ -4213,39 +4198,37 @@ module ts {
|
||||||
return finishNode(node);
|
return finishNode(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setFlag(nodes: NodeArray<VariableDeclaration>, flag: NodeFlags): NodeArray<VariableDeclaration> {
|
function parseVariableDeclarationList(disallowIn: boolean): VariableDeclarationList {
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
var node = <VariableDeclarationList>createNode(SyntaxKind.VariableDeclarationList);
|
||||||
var node = nodes[i];
|
|
||||||
node.flags |= flag;
|
switch (token) {
|
||||||
if (node.name && isBindingPattern(node.name)) {
|
case SyntaxKind.VarKeyword:
|
||||||
setFlag((<BindingPattern>node.name).elements, flag);
|
break;
|
||||||
}
|
case SyntaxKind.LetKeyword:
|
||||||
}
|
node.flags |= NodeFlags.Let;
|
||||||
return nodes;
|
break;
|
||||||
|
case SyntaxKind.ConstKeyword:
|
||||||
|
node.flags |= NodeFlags.Const;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Debug.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseVariableDeclarationList(): NodeArray<VariableDeclaration> {
|
nextToken();
|
||||||
return parseDelimitedList(ParsingContext.VariableDeclarations, parseVariableDeclaration);
|
var savedDisallowIn = inDisallowInContext();
|
||||||
|
setDisallowInContext(disallowIn);
|
||||||
|
|
||||||
|
node.declarations = parseDelimitedList(ParsingContext.VariableDeclarations, parseVariableDeclaration);
|
||||||
|
|
||||||
|
setDisallowInContext(savedDisallowIn);
|
||||||
|
|
||||||
|
return finishNode(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseVariableStatement(fullStart: number, modifiers: ModifiersArray): VariableStatement {
|
function parseVariableStatement(fullStart: number, modifiers: ModifiersArray): VariableStatement {
|
||||||
var node = <VariableStatement>createNode(SyntaxKind.VariableStatement, fullStart);
|
var node = <VariableStatement>createNode(SyntaxKind.VariableStatement, fullStart);
|
||||||
setModifiers(node, modifiers);
|
setModifiers(node, modifiers);
|
||||||
|
node.declarationList = parseVariableDeclarationList(/*disallowIn:*/ false);
|
||||||
if (token === SyntaxKind.LetKeyword) {
|
|
||||||
node.flags |= NodeFlags.Let;
|
|
||||||
}
|
|
||||||
else if (token === SyntaxKind.ConstKeyword) {
|
|
||||||
node.flags |= NodeFlags.Const;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Debug.assert(token === SyntaxKind.VarKeyword);
|
|
||||||
}
|
|
||||||
|
|
||||||
nextToken();
|
|
||||||
node.declarations = allowInAnd(parseVariableDeclarationList);
|
|
||||||
setFlag(node.declarations, node.flags);
|
|
||||||
|
|
||||||
parseSemicolon();
|
parseSemicolon();
|
||||||
return finishNode(node);
|
return finishNode(node);
|
||||||
}
|
}
|
||||||
|
@ -4954,8 +4937,6 @@ module ts {
|
||||||
case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(<ElementAccessExpression>node);
|
case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(<ElementAccessExpression>node);
|
||||||
case SyntaxKind.ExportAssignment: return checkExportAssignment(<ExportAssignment>node);
|
case SyntaxKind.ExportAssignment: return checkExportAssignment(<ExportAssignment>node);
|
||||||
case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(<ExternalModuleReference>node);
|
case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(<ExternalModuleReference>node);
|
||||||
case SyntaxKind.ForInStatement: return checkForInStatement(<ForInStatement>node);
|
|
||||||
case SyntaxKind.ForStatement: return checkForStatement(<ForStatement>node);
|
|
||||||
case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(<FunctionLikeDeclaration>node);
|
case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(<FunctionLikeDeclaration>node);
|
||||||
case SyntaxKind.FunctionExpression: return checkFunctionExpression(<FunctionExpression>node);
|
case SyntaxKind.FunctionExpression: return checkFunctionExpression(<FunctionExpression>node);
|
||||||
case SyntaxKind.GetAccessor: return checkGetAccessor(<MethodDeclaration>node);
|
case SyntaxKind.GetAccessor: return checkGetAccessor(<MethodDeclaration>node);
|
||||||
|
@ -4987,6 +4968,7 @@ module ts {
|
||||||
case SyntaxKind.TypeParameter: return checkTypeParameter(<TypeParameterDeclaration>node);
|
case SyntaxKind.TypeParameter: return checkTypeParameter(<TypeParameterDeclaration>node);
|
||||||
case SyntaxKind.TypeReference: return checkTypeReference(<TypeReferenceNode>node);
|
case SyntaxKind.TypeReference: return checkTypeReference(<TypeReferenceNode>node);
|
||||||
case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(<VariableDeclaration>node);
|
case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(<VariableDeclaration>node);
|
||||||
|
case SyntaxKind.VariableDeclarationList: return checkVariableDeclarationList(<VariableDeclarationList>node);
|
||||||
case SyntaxKind.VariableStatement: return checkVariableStatement(<VariableStatement>node);
|
case SyntaxKind.VariableStatement: return checkVariableStatement(<VariableStatement>node);
|
||||||
case SyntaxKind.WithStatement: return checkWithStatement(<WithStatement>node);
|
case SyntaxKind.WithStatement: return checkWithStatement(<WithStatement>node);
|
||||||
case SyntaxKind.YieldExpression: return checkYieldExpression(<YieldExpression>node);
|
case SyntaxKind.YieldExpression: return checkYieldExpression(<YieldExpression>node);
|
||||||
|
@ -5349,15 +5331,6 @@ module ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkForInStatement(node: ForInStatement) {
|
|
||||||
return checkVariableDeclarations(node.declarations) ||
|
|
||||||
checkForMoreThanOneDeclaration(node.declarations);
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkForStatement(node: ForStatement) {
|
|
||||||
return checkVariableDeclarations(node.declarations);
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkForMoreThanOneDeclaration(declarations: NodeArray<VariableDeclaration>) {
|
function checkForMoreThanOneDeclaration(declarations: NodeArray<VariableDeclaration>) {
|
||||||
if (declarations && declarations.length > 1) {
|
if (declarations && declarations.length > 1) {
|
||||||
return grammarErrorOnFirstToken(declarations[1], Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement);
|
return grammarErrorOnFirstToken(declarations[1], Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement);
|
||||||
|
@ -6094,31 +6067,32 @@ module ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkVariableDeclarations(declarations: NodeArray<VariableDeclaration>): boolean {
|
function checkVariableDeclarationList(declarationList: VariableDeclarationList): boolean {
|
||||||
if (declarations) {
|
var declarations = declarationList.declarations;
|
||||||
if (checkForDisallowedTrailingComma(declarations)) {
|
if (checkForDisallowedTrailingComma(declarationList.declarations)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!declarations.length) {
|
if (!declarationList.declarations.length) {
|
||||||
return grammarErrorAtPos(declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty);
|
return grammarErrorAtPos(declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
var decl = declarations[0];
|
if (declarationList.parent.kind === SyntaxKind.ForInStatement) {
|
||||||
|
checkForMoreThanOneDeclaration(declarationList.declarations);
|
||||||
|
}
|
||||||
|
|
||||||
if (languageVersion < ScriptTarget.ES6) {
|
if (languageVersion < ScriptTarget.ES6) {
|
||||||
if (isLet(decl)) {
|
if (isLet(declarationList)) {
|
||||||
return grammarErrorOnFirstToken(decl, Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
return grammarErrorOnFirstToken(declarationList, Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
||||||
}
|
|
||||||
else if (isConst(decl)) {
|
|
||||||
return grammarErrorOnFirstToken(decl, Diagnostics.const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
|
||||||
}
|
}
|
||||||
|
else if (isConst(declarationList)) {
|
||||||
|
return grammarErrorOnFirstToken(declarationList, Diagnostics.const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkVariableStatement(node: VariableStatement) {
|
function checkVariableStatement(node: VariableStatement) {
|
||||||
return checkForDisallowedModifiersInBlockOrObjectLiteral(node) ||
|
return checkForDisallowedModifiersInBlockOrObjectLiteral(node) ||
|
||||||
checkVariableDeclarations(node.declarations) ||
|
|
||||||
checkForDisallowedLetOrConstStatement(node);
|
checkForDisallowedLetOrConstStatement(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6132,10 +6106,10 @@ module ts {
|
||||||
|
|
||||||
function checkForDisallowedLetOrConstStatement(node: VariableStatement) {
|
function checkForDisallowedLetOrConstStatement(node: VariableStatement) {
|
||||||
if (!allowLetAndConstDeclarations(node.parent)) {
|
if (!allowLetAndConstDeclarations(node.parent)) {
|
||||||
if (isLet(node)) {
|
if (isLet(node.declarationList)) {
|
||||||
return grammarErrorOnNode(node, Diagnostics.let_declarations_can_only_be_declared_inside_a_block);
|
return grammarErrorOnNode(node, Diagnostics.let_declarations_can_only_be_declared_inside_a_block);
|
||||||
}
|
}
|
||||||
else if (isConst(node)) {
|
else if (isConst(node.declarationList)) {
|
||||||
return grammarErrorOnNode(node, Diagnostics.const_declarations_can_only_be_declared_inside_a_block);
|
return grammarErrorOnNode(node, Diagnostics.const_declarations_can_only_be_declared_inside_a_block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,6 +219,7 @@ module ts {
|
||||||
TryStatement,
|
TryStatement,
|
||||||
DebuggerStatement,
|
DebuggerStatement,
|
||||||
VariableDeclaration,
|
VariableDeclaration,
|
||||||
|
VariableDeclarationList,
|
||||||
FunctionDeclaration,
|
FunctionDeclaration,
|
||||||
ClassDeclaration,
|
ClassDeclaration,
|
||||||
InterfaceDeclaration,
|
InterfaceDeclaration,
|
||||||
|
@ -398,6 +399,10 @@ module ts {
|
||||||
initializer?: Expression; // Optional initializer
|
initializer?: Expression; // Optional initializer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface VariableDeclarationList extends Node {
|
||||||
|
declarations: NodeArray<VariableDeclaration>;
|
||||||
|
}
|
||||||
|
|
||||||
// SyntaxKind.Parameter
|
// SyntaxKind.Parameter
|
||||||
export interface ParameterDeclaration extends Declaration {
|
export interface ParameterDeclaration extends Declaration {
|
||||||
dotDotDotToken?: Node; // Present on rest parameter
|
dotDotDotToken?: Node; // Present on rest parameter
|
||||||
|
@ -702,7 +707,7 @@ module ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VariableStatement extends Statement {
|
export interface VariableStatement extends Statement {
|
||||||
declarations: NodeArray<VariableDeclaration>;
|
declarationList: VariableDeclarationList;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExpressionStatement extends Statement {
|
export interface ExpressionStatement extends Statement {
|
||||||
|
@ -728,15 +733,13 @@ module ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ForStatement extends IterationStatement {
|
export interface ForStatement extends IterationStatement {
|
||||||
declarations?: NodeArray<VariableDeclaration>;
|
initializer?: VariableDeclarationList | Expression;
|
||||||
initializer?: Expression;
|
|
||||||
condition?: Expression;
|
condition?: Expression;
|
||||||
iterator?: Expression;
|
iterator?: Expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ForInStatement extends IterationStatement {
|
export interface ForInStatement extends IterationStatement {
|
||||||
declarations?: NodeArray<VariableDeclaration>;
|
initializer: VariableDeclarationList | Expression;
|
||||||
variable?: Expression;
|
|
||||||
expression: Expression;
|
expression: Expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -220,12 +220,40 @@ module ts {
|
||||||
return node.kind === SyntaxKind.EnumDeclaration && isConst(node);
|
return node.kind === SyntaxKind.EnumDeclaration && isConst(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function walkUpBindingElementsAndPatterns(node: Node): Node {
|
||||||
|
while (node && (node.kind === SyntaxKind.BindingElement || isBindingPattern(node))) {
|
||||||
|
node = node.parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getNodeFlags(node: Node): NodeFlags {
|
||||||
|
node = walkUpBindingElementsAndPatterns(node);
|
||||||
|
|
||||||
|
var flags = node.flags;
|
||||||
|
if (node.kind === SyntaxKind.VariableDeclaration) {
|
||||||
|
node = node.parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node && node.kind === SyntaxKind.VariableDeclarationList) {
|
||||||
|
flags |= node.flags;
|
||||||
|
node = node.parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node && node.kind === SyntaxKind.VariableStatement) {
|
||||||
|
flags |= node.flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
export function isConst(node: Node): boolean {
|
export function isConst(node: Node): boolean {
|
||||||
return !!(node.flags & NodeFlags.Const);
|
return !!(getNodeFlags(node) & NodeFlags.Const);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isLet(node: Node): boolean {
|
export function isLet(node: Node): boolean {
|
||||||
return !!(node.flags & NodeFlags.Let);
|
return !!(getNodeFlags(node) & NodeFlags.Let);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isPrologueDirective(node: Node): boolean {
|
export function isPrologueDirective(node: Node): boolean {
|
||||||
|
@ -456,12 +484,14 @@ module ts {
|
||||||
case SyntaxKind.SwitchStatement:
|
case SyntaxKind.SwitchStatement:
|
||||||
return (<ExpressionStatement>parent).expression === node;
|
return (<ExpressionStatement>parent).expression === node;
|
||||||
case SyntaxKind.ForStatement:
|
case SyntaxKind.ForStatement:
|
||||||
return (<ForStatement>parent).initializer === node ||
|
var forStatement = <ForStatement>parent;
|
||||||
(<ForStatement>parent).condition === node ||
|
return (forStatement.initializer === node && forStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) ||
|
||||||
(<ForStatement>parent).iterator === node;
|
forStatement.condition === node ||
|
||||||
|
forStatement.iterator === node;
|
||||||
case SyntaxKind.ForInStatement:
|
case SyntaxKind.ForInStatement:
|
||||||
return (<ForInStatement>parent).variable === node ||
|
var forInStatement = <ForInStatement>parent;
|
||||||
(<ForInStatement>parent).expression === node;
|
return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) ||
|
||||||
|
forInStatement.expression === node;
|
||||||
case SyntaxKind.TypeAssertionExpression:
|
case SyntaxKind.TypeAssertionExpression:
|
||||||
return node === (<TypeAssertion>parent).expression;
|
return node === (<TypeAssertion>parent).expression;
|
||||||
case SyntaxKind.TemplateSpan:
|
case SyntaxKind.TemplateSpan:
|
||||||
|
@ -533,7 +563,10 @@ module ts {
|
||||||
|
|
||||||
export function isInAmbientContext(node: Node): boolean {
|
export function isInAmbientContext(node: Node): boolean {
|
||||||
while (node) {
|
while (node) {
|
||||||
if (node.flags & (NodeFlags.Ambient | NodeFlags.DeclarationFile)) return true;
|
if (node.flags & (NodeFlags.Ambient | NodeFlags.DeclarationFile)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
node = node.parent;
|
node = node.parent;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1210,7 +1210,7 @@ module Harness {
|
||||||
|
|
||||||
// Report global errors
|
// Report global errors
|
||||||
var globalErrors = diagnostics.filter(err => !err.filename);
|
var globalErrors = diagnostics.filter(err => !err.filename);
|
||||||
globalErrors.forEach(err => outputErrorText(err));
|
globalErrors.forEach(outputErrorText);
|
||||||
|
|
||||||
// 'merge' the lines of each input file with any errors associated with it
|
// 'merge' the lines of each input file with any errors associated with it
|
||||||
inputFiles.filter(f => f.content !== undefined).forEach(inputFile => {
|
inputFiles.filter(f => f.content !== undefined).forEach(inputFile => {
|
||||||
|
|
|
@ -83,7 +83,7 @@ module ts.BreakpointResolver {
|
||||||
switch (node.kind) {
|
switch (node.kind) {
|
||||||
case SyntaxKind.VariableStatement:
|
case SyntaxKind.VariableStatement:
|
||||||
// Span on first variable declaration
|
// Span on first variable declaration
|
||||||
return spanInVariableDeclaration((<VariableStatement>node).declarations[0]);
|
return spanInVariableDeclaration((<VariableStatement>node).declarationList.declarations[0]);
|
||||||
|
|
||||||
case SyntaxKind.VariableDeclaration:
|
case SyntaxKind.VariableDeclaration:
|
||||||
case SyntaxKind.PropertyDeclaration:
|
case SyntaxKind.PropertyDeclaration:
|
||||||
|
@ -261,16 +261,16 @@ module ts.BreakpointResolver {
|
||||||
|
|
||||||
function spanInVariableDeclaration(variableDeclaration: VariableDeclaration): TextSpan {
|
function spanInVariableDeclaration(variableDeclaration: VariableDeclaration): TextSpan {
|
||||||
// If declaration of for in statement, just set the span in parent
|
// If declaration of for in statement, just set the span in parent
|
||||||
if (variableDeclaration.parent.kind === SyntaxKind.ForInStatement) {
|
if (variableDeclaration.parent.parent.kind === SyntaxKind.ForInStatement) {
|
||||||
return spanInNode(variableDeclaration.parent);
|
return spanInNode(variableDeclaration.parent.parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
var isParentVariableStatement = variableDeclaration.parent.kind === SyntaxKind.VariableStatement;
|
var isParentVariableStatement = variableDeclaration.parent.parent.kind === SyntaxKind.VariableStatement;
|
||||||
var isDeclarationOfForStatement = variableDeclaration.parent.kind === SyntaxKind.ForStatement && contains((<ForStatement>variableDeclaration.parent).declarations, variableDeclaration);
|
var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === SyntaxKind.ForStatement && contains((<VariableDeclarationList>(<ForStatement>variableDeclaration.parent.parent).initializer).declarations, variableDeclaration);
|
||||||
var declarations = isParentVariableStatement
|
var declarations = isParentVariableStatement
|
||||||
? (<VariableStatement>variableDeclaration.parent).declarations
|
? (<VariableStatement>variableDeclaration.parent.parent).declarationList.declarations
|
||||||
: isDeclarationOfForStatement
|
: isDeclarationOfForStatement
|
||||||
? (<ForStatement>variableDeclaration.parent).declarations
|
? (<VariableDeclarationList>(<ForStatement>variableDeclaration.parent.parent).initializer).declarations
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
// Breakpoint is possible in variableDeclaration only if there is initialization
|
// Breakpoint is possible in variableDeclaration only if there is initialization
|
||||||
|
@ -374,12 +374,18 @@ module ts.BreakpointResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
function spanInForStatement(forStatement: ForStatement): TextSpan {
|
function spanInForStatement(forStatement: ForStatement): TextSpan {
|
||||||
if (forStatement.declarations) {
|
|
||||||
return spanInNode(forStatement.declarations[0]);
|
|
||||||
}
|
|
||||||
if (forStatement.initializer) {
|
if (forStatement.initializer) {
|
||||||
|
if (forStatement.initializer.kind === SyntaxKind.VariableDeclarationList) {
|
||||||
|
var variableDeclarationList = <VariableDeclarationList>forStatement.initializer;
|
||||||
|
if (variableDeclarationList.declarations.length > 0) {
|
||||||
|
return spanInNode(variableDeclarationList.declarations[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
return spanInNode(forStatement.initializer);
|
return spanInNode(forStatement.initializer);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (forStatement.condition) {
|
if (forStatement.condition) {
|
||||||
return textSpan(forStatement.condition);
|
return textSpan(forStatement.condition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ module ts.NavigationBar {
|
||||||
function visit(node: Node) {
|
function visit(node: Node) {
|
||||||
switch (node.kind) {
|
switch (node.kind) {
|
||||||
case SyntaxKind.VariableStatement:
|
case SyntaxKind.VariableStatement:
|
||||||
forEach((<VariableStatement>node).declarations, visit);
|
forEach((<VariableStatement>node).declarationList.declarations, visit);
|
||||||
break;
|
break;
|
||||||
case SyntaxKind.ObjectBindingPattern:
|
case SyntaxKind.ObjectBindingPattern:
|
||||||
case SyntaxKind.ArrayBindingPattern:
|
case SyntaxKind.ArrayBindingPattern:
|
||||||
|
|
|
@ -364,7 +364,7 @@ module ts {
|
||||||
|
|
||||||
// Get the cleaned js doc comment text from the declaration
|
// Get the cleaned js doc comment text from the declaration
|
||||||
ts.forEach(getJsDocCommentTextRange(
|
ts.forEach(getJsDocCommentTextRange(
|
||||||
declaration.kind === SyntaxKind.VariableDeclaration ? declaration.parent : declaration, sourceFileOfDeclaration), jsDocCommentTextRange => {
|
declaration.kind === SyntaxKind.VariableDeclaration ? declaration.parent.parent : declaration, sourceFileOfDeclaration), jsDocCommentTextRange => {
|
||||||
var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration);
|
var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration);
|
||||||
if (cleanedJsDocComment) {
|
if (cleanedJsDocComment) {
|
||||||
jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment);
|
jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment);
|
||||||
|
@ -807,6 +807,7 @@ module ts {
|
||||||
// fall through
|
// fall through
|
||||||
case SyntaxKind.Constructor:
|
case SyntaxKind.Constructor:
|
||||||
case SyntaxKind.VariableStatement:
|
case SyntaxKind.VariableStatement:
|
||||||
|
case SyntaxKind.VariableDeclarationList:
|
||||||
case SyntaxKind.ObjectBindingPattern:
|
case SyntaxKind.ObjectBindingPattern:
|
||||||
case SyntaxKind.ArrayBindingPattern:
|
case SyntaxKind.ArrayBindingPattern:
|
||||||
case SyntaxKind.ModuleBlock:
|
case SyntaxKind.ModuleBlock:
|
||||||
|
@ -2438,6 +2439,7 @@ module ts {
|
||||||
switch (previousToken.kind) {
|
switch (previousToken.kind) {
|
||||||
case SyntaxKind.CommaToken:
|
case SyntaxKind.CommaToken:
|
||||||
return containingNodeKind === SyntaxKind.VariableDeclaration ||
|
return containingNodeKind === SyntaxKind.VariableDeclaration ||
|
||||||
|
containingNodeKind === SyntaxKind.VariableDeclarationList ||
|
||||||
containingNodeKind === SyntaxKind.VariableStatement ||
|
containingNodeKind === SyntaxKind.VariableStatement ||
|
||||||
containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, |
|
containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, |
|
||||||
isFunction(containingNodeKind);
|
isFunction(containingNodeKind);
|
||||||
|
@ -2631,7 +2633,7 @@ module ts {
|
||||||
else if (symbol.valueDeclaration && isConst(symbol.valueDeclaration)) {
|
else if (symbol.valueDeclaration && isConst(symbol.valueDeclaration)) {
|
||||||
return ScriptElementKind.constElement;
|
return ScriptElementKind.constElement;
|
||||||
}
|
}
|
||||||
else if (forEach(symbol.declarations, declaration => isLet(declaration))) {
|
else if (forEach(symbol.declarations, isLet)) {
|
||||||
return ScriptElementKind.letElement;
|
return ScriptElementKind.letElement;
|
||||||
}
|
}
|
||||||
return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement;
|
return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement;
|
||||||
|
@ -2689,9 +2691,10 @@ module ts {
|
||||||
case SyntaxKind.InterfaceDeclaration: return ScriptElementKind.interfaceElement;
|
case SyntaxKind.InterfaceDeclaration: return ScriptElementKind.interfaceElement;
|
||||||
case SyntaxKind.TypeAliasDeclaration: return ScriptElementKind.typeElement;
|
case SyntaxKind.TypeAliasDeclaration: return ScriptElementKind.typeElement;
|
||||||
case SyntaxKind.EnumDeclaration: return ScriptElementKind.enumElement;
|
case SyntaxKind.EnumDeclaration: return ScriptElementKind.enumElement;
|
||||||
case SyntaxKind.VariableDeclaration: return isConst(node)
|
case SyntaxKind.VariableDeclaration:
|
||||||
|
return isConst(node)
|
||||||
? ScriptElementKind.constElement
|
? ScriptElementKind.constElement
|
||||||
: node.flags & NodeFlags.Let
|
: isLet(node)
|
||||||
? ScriptElementKind.letElement
|
? ScriptElementKind.letElement
|
||||||
: ScriptElementKind.variableElement;
|
: ScriptElementKind.variableElement;
|
||||||
case SyntaxKind.FunctionDeclaration: return ScriptElementKind.functionElement;
|
case SyntaxKind.FunctionDeclaration: return ScriptElementKind.functionElement;
|
||||||
|
@ -2874,7 +2877,7 @@ module ts {
|
||||||
}
|
}
|
||||||
if (symbolFlags & SymbolFlags.Enum) {
|
if (symbolFlags & SymbolFlags.Enum) {
|
||||||
addNewLineIfDisplayPartsExist();
|
addNewLineIfDisplayPartsExist();
|
||||||
if (forEach(symbol.declarations, declaration => isConstEnumDeclaration(declaration))) {
|
if (forEach(symbol.declarations, isConstEnumDeclaration)) {
|
||||||
displayParts.push(keywordPart(SyntaxKind.ConstKeyword));
|
displayParts.push(keywordPart(SyntaxKind.ConstKeyword));
|
||||||
displayParts.push(spacePart());
|
displayParts.push(spacePart());
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,7 @@ module ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNodeModifiers(node: Node): string {
|
export function getNodeModifiers(node: Node): string {
|
||||||
var flags = node.flags;
|
var flags = getNodeFlags(node);
|
||||||
var result: string[] = [];
|
var result: string[] = [];
|
||||||
|
|
||||||
if (flags & NodeFlags.Private) result.push(ScriptElementKindModifier.privateMemberModifier);
|
if (flags & NodeFlags.Private) result.push(ScriptElementKindModifier.privateMemberModifier);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts(1,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts(1,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts (1 errors) ====
|
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts (1 errors) ====
|
||||||
let a: number = 1
|
let a: number = 1
|
||||||
~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
|
@ -1,7 +1,7 @@
|
||||||
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts(1,7): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts(1,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts (1 errors) ====
|
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts (1 errors) ====
|
||||||
const a
|
const a
|
||||||
~
|
~~~~~
|
||||||
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
|
@ -1,7 +1,7 @@
|
||||||
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts(1,7): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts(1,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts (1 errors) ====
|
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts (1 errors) ====
|
||||||
const a = 1
|
const a = 1
|
||||||
~
|
~~~~~
|
||||||
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
|
@ -1,7 +1,7 @@
|
||||||
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts(1,7): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts(1,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts (1 errors) ====
|
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts (1 errors) ====
|
||||||
const a: number
|
const a: number
|
||||||
~
|
~~~~~
|
||||||
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
|
@ -1,7 +1,7 @@
|
||||||
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts(1,7): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts(1,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts (1 errors) ====
|
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts (1 errors) ====
|
||||||
const a: number = 1
|
const a: number = 1
|
||||||
~
|
~~~~~
|
||||||
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
|
@ -1,7 +1,7 @@
|
||||||
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts(1,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts(1,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts (1 errors) ====
|
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts (1 errors) ====
|
||||||
let a
|
let a
|
||||||
~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
|
@ -1,7 +1,7 @@
|
||||||
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts(1,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts(1,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts (1 errors) ====
|
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts (1 errors) ====
|
||||||
let a = 1
|
let a = 1
|
||||||
~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
|
@ -1,7 +1,7 @@
|
||||||
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts(1,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts(1,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts (1 errors) ====
|
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts (1 errors) ====
|
||||||
let a: number
|
let a: number
|
||||||
~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
|
@ -76,21 +76,21 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
7 > export const cc1 = false;
|
7 > export const cc1 = false;
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (181 to 210) SpanInfo: {"start":185,"length":24}
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (181 to 210) SpanInfo: {"start":192,"length":17}
|
||||||
>export const cc1 = false
|
>const cc1 = false
|
||||||
>:=> (line 7, col 4) to (line 7, col 28)
|
>:=> (line 7, col 11) to (line 7, col 28)
|
||||||
--------------------------------
|
--------------------------------
|
||||||
8 > export const cc2: number = 23;
|
8 > export const cc2: number = 23;
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (211 to 245) SpanInfo: {"start":215,"length":29}
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (211 to 245) SpanInfo: {"start":222,"length":22}
|
||||||
>export const cc2: number = 23
|
>const cc2: number = 23
|
||||||
>:=> (line 8, col 4) to (line 8, col 33)
|
>:=> (line 8, col 11) to (line 8, col 33)
|
||||||
--------------------------------
|
--------------------------------
|
||||||
9 > export const cc3 = 0, cc4 :string = "", cc5 = null;
|
9 > export const cc3 = 0, cc4 :string = "", cc5 = null;
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (246 to 270) SpanInfo: {"start":250,"length":20}
|
~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (246 to 270) SpanInfo: {"start":257,"length":13}
|
||||||
>export const cc3 = 0
|
>const cc3 = 0
|
||||||
>:=> (line 9, col 4) to (line 9, col 24)
|
>:=> (line 9, col 11) to (line 9, col 24)
|
||||||
9 > export const cc3 = 0, cc4 :string = "", cc5 = null;
|
9 > export const cc3 = 0, cc4 :string = "", cc5 = null;
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~ => Pos: (271 to 288) SpanInfo: {"start":272,"length":16}
|
~~~~~~~~~~~~~~~~~~ => Pos: (271 to 288) SpanInfo: {"start":272,"length":16}
|
||||||
|
|
|
@ -84,9 +84,9 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
11 > export let ll2 = 0;
|
11 > export let ll2 = 0;
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (221 to 244) SpanInfo: {"start":225,"length":18}
|
~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (221 to 244) SpanInfo: {"start":232,"length":11}
|
||||||
>export let ll2 = 0
|
>let ll2 = 0
|
||||||
>:=> (line 11, col 4) to (line 11, col 22)
|
>:=> (line 11, col 11) to (line 11, col 22)
|
||||||
--------------------------------
|
--------------------------------
|
||||||
12 >}
|
12 >}
|
||||||
~ => Pos: (245 to 245) SpanInfo: {"start":245,"length":1}
|
~ => Pos: (245 to 245) SpanInfo: {"start":245,"length":1}
|
||||||
|
|
|
@ -50,9 +50,9 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
7 > export var x = 30;
|
7 > export var x = 30;
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (67 to 93) SpanInfo: {"start":75,"length":17}
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (67 to 93) SpanInfo: {"start":82,"length":10}
|
||||||
>export var x = 30
|
>var x = 30
|
||||||
>:=> (line 7, col 8) to (line 7, col 25)
|
>:=> (line 7, col 15) to (line 7, col 25)
|
||||||
--------------------------------
|
--------------------------------
|
||||||
8 > }
|
8 > }
|
||||||
|
|
||||||
|
@ -172,15 +172,15 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
25 > {
|
25 > {
|
||||||
|
|
||||||
~~~~~~ => Pos: (261 to 266) SpanInfo: {"start":275,"length":17}
|
~~~~~~ => Pos: (261 to 266) SpanInfo: {"start":282,"length":10}
|
||||||
>export var x = 30
|
>var x = 30
|
||||||
>:=> (line 26, col 8) to (line 26, col 25)
|
>:=> (line 26, col 15) to (line 26, col 25)
|
||||||
--------------------------------
|
--------------------------------
|
||||||
26 > export var x = 30;
|
26 > export var x = 30;
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (267 to 293) SpanInfo: {"start":275,"length":17}
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (267 to 293) SpanInfo: {"start":282,"length":10}
|
||||||
>export var x = 30
|
>var x = 30
|
||||||
>:=> (line 26, col 8) to (line 26, col 25)
|
>:=> (line 26, col 15) to (line 26, col 25)
|
||||||
--------------------------------
|
--------------------------------
|
||||||
27 > }
|
27 > }
|
||||||
|
|
||||||
|
|
|
@ -58,15 +58,13 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
9 > export var xx1;
|
9 > export var xx1;
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~ => Pos: (119 to 138) SpanInfo: {"start":123,"length":14}
|
~~~~~~~~~~~~~~~~~~~~ => Pos: (119 to 138) SpanInfo: undefined
|
||||||
>export var xx1
|
|
||||||
>:=> (line 9, col 4) to (line 9, col 18)
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
10 > export var xx2 = 10, xx3 = 10;
|
10 > export var xx2 = 10, xx3 = 10;
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (139 to 162) SpanInfo: {"start":143,"length":19}
|
~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (139 to 162) SpanInfo: {"start":150,"length":12}
|
||||||
>export var xx2 = 10
|
>var xx2 = 10
|
||||||
>:=> (line 10, col 4) to (line 10, col 23)
|
>:=> (line 10, col 11) to (line 10, col 23)
|
||||||
10 > export var xx2 = 10, xx3 = 10;
|
10 > export var xx2 = 10, xx3 = 10;
|
||||||
|
|
||||||
~~~~~~~~~~~ => Pos: (163 to 173) SpanInfo: {"start":164,"length":8}
|
~~~~~~~~~~~ => Pos: (163 to 173) SpanInfo: {"start":164,"length":8}
|
||||||
|
@ -75,14 +73,7 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
11 > export var xx4, xx5;
|
11 > export var xx4, xx5;
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~ => Pos: (174 to 192) SpanInfo: {"start":178,"length":14}
|
~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (174 to 198) SpanInfo: undefined
|
||||||
>export var xx4
|
|
||||||
>:=> (line 11, col 4) to (line 11, col 18)
|
|
||||||
11 > export var xx4, xx5;
|
|
||||||
|
|
||||||
~~~~~~ => Pos: (193 to 198) SpanInfo: {"start":194,"length":3}
|
|
||||||
>xx5
|
|
||||||
>:=> (line 11, col 20) to (line 11, col 23)
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
12 >}
|
12 >}
|
||||||
~ => Pos: (199 to 199) SpanInfo: {"start":199,"length":1}
|
~ => Pos: (199 to 199) SpanInfo: {"start":199,"length":1}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
tests/cases/compiler/constDeclarations-es5.ts(2,7): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/constDeclarations-es5.ts(2,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/constDeclarations-es5.ts(3,7): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/constDeclarations-es5.ts(3,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/constDeclarations-es5.ts(4,7): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/constDeclarations-es5.ts(4,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/constDeclarations-es5.ts (3 errors) ====
|
==== tests/cases/compiler/constDeclarations-es5.ts (3 errors) ====
|
||||||
|
|
||||||
const z7 = false;
|
const z7 = false;
|
||||||
~~
|
~~~~~
|
||||||
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
const z8: number = 23;
|
const z8: number = 23;
|
||||||
~~
|
~~~~~
|
||||||
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
const z9 = 0, z10 :string = "", z11 = null;
|
const z9 = 0, z10 :string = "", z11 = null;
|
||||||
~~
|
~~~~~
|
||||||
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
tests/cases/compiler/letDeclarations-es5-1.ts(1,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5-1.ts(1,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5-1.ts(2,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5-1.ts(2,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5-1.ts(3,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5-1.ts(3,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5-1.ts(4,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5-1.ts(4,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5-1.ts(5,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5-1.ts(5,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5-1.ts(6,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5-1.ts(6,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/letDeclarations-es5-1.ts (6 errors) ====
|
==== tests/cases/compiler/letDeclarations-es5-1.ts (6 errors) ====
|
||||||
let l1;
|
let l1;
|
||||||
~~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
let l2: number;
|
let l2: number;
|
||||||
~~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
let l3, l4, l5 :string, l6;
|
let l3, l4, l5 :string, l6;
|
||||||
~~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
let l7 = false;
|
let l7 = false;
|
||||||
~~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
let l8: number = 23;
|
let l8: number = 23;
|
||||||
~~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
let l9 = 0, l10 :string = "", l11 = null;
|
let l9 = 0, l10 :string = "", l11 = null;
|
||||||
~~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
|
@ -1,33 +1,33 @@
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(2,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(2,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(3,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(3,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(4,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(4,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(6,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(6,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(7,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(7,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(8,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(8,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(10,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(10,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(12,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(12,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/letDeclarations-es5.ts (8 errors) ====
|
==== tests/cases/compiler/letDeclarations-es5.ts (8 errors) ====
|
||||||
|
|
||||||
let l1;
|
let l1;
|
||||||
~~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
let l2: number;
|
let l2: number;
|
||||||
~~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
let l3, l4, l5 :string, l6;
|
let l3, l4, l5 :string, l6;
|
||||||
~~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
let l7 = false;
|
let l7 = false;
|
||||||
~~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
let l8: number = 23;
|
let l8: number = 23;
|
||||||
~~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
let l9 = 0, l10 :string = "", l11 = null;
|
let l9 = 0, l10 :string = "", l11 = null;
|
||||||
~~
|
~~~
|
||||||
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
for(let l11 in {}) { }
|
for(let l11 in {}) { }
|
||||||
|
|
|
@ -19,7 +19,7 @@ var Chain = (function () {
|
||||||
Chain.prototype.then = function (cb) {
|
Chain.prototype.then = function (cb) {
|
||||||
var result = cb(this.value);
|
var result = cb(this.value);
|
||||||
// should get a fresh type parameter which each then call
|
// should get a fresh type parameter which each then call
|
||||||
var z = this.then(function (x) { return result; }).then(function (x) { return "abc"; }).then(function (x) { return x.length; }) /*number*/; // No error
|
var z = this.then(function (x) { return result; }).then(function (x) { return "abc"; }).then(function (x) { return x.length; }); // No error
|
||||||
return new Chain(result);
|
return new Chain(result);
|
||||||
};
|
};
|
||||||
return Chain;
|
return Chain;
|
||||||
|
|
|
@ -19,7 +19,7 @@ var Chain2 = (function () {
|
||||||
Chain2.prototype.then = function (cb) {
|
Chain2.prototype.then = function (cb) {
|
||||||
var result = cb(this.value);
|
var result = cb(this.value);
|
||||||
// should get a fresh type parameter which each then call
|
// should get a fresh type parameter which each then call
|
||||||
var z = this.then(function (x) { return result; }).then(function (x) { return "abc"; }).then(function (x) { return x.length; }) /*number*/; // Should error on "abc" because it is not a Function
|
var z = this.then(function (x) { return result; }).then(function (x) { return "abc"; }).then(function (x) { return x.length; }); // Should error on "abc" because it is not a Function
|
||||||
return new Chain2(result);
|
return new Chain2(result);
|
||||||
};
|
};
|
||||||
return Chain2;
|
return Chain2;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
////var a2, a/*varName4*/
|
////var a2, a/*varName4*/
|
||||||
|
|
||||||
|
debugger;
|
||||||
test.markers().forEach((m) => {
|
test.markers().forEach((m) => {
|
||||||
goTo.position(m.position, m.fileName);
|
goTo.position(m.position, m.fileName);
|
||||||
verify.completionListIsEmpty();
|
verify.completionListIsEmpty();
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
////function foo() {
|
////function foo() {
|
||||||
//// {| "itemName": "d", "kind": "let", "parentName": "foo" |}let d = 10;
|
//// {| "itemName": "d", "kind": "let", "parentName": "foo" |}let d = 10;
|
||||||
////}
|
////}
|
||||||
|
debugger;
|
||||||
test.markers().forEach(marker => {
|
test.markers().forEach(marker => {
|
||||||
verify.navigationItemsListContains(
|
verify.navigationItemsListContains(
|
||||||
marker.data.itemName,
|
marker.data.itemName,
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
////function distance2(distanceParam1): void {
|
////function distance2(distanceParam1): void {
|
||||||
//// var distanceLocal1;
|
//// var distanceLocal1;
|
||||||
////}
|
////}
|
||||||
|
debugger;
|
||||||
goTo.marker("file1");
|
goTo.marker("file1");
|
||||||
verify.navigationItemsListCount(2, "point", "exact");
|
verify.navigationItemsListCount(2, "point", "exact");
|
||||||
verify.navigationItemsListCount(5, "distance", "prefix");
|
verify.navigationItemsListCount(5, "distance", "prefix");
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
/////*15*/h(10);
|
/////*15*/h(10);
|
||||||
/////*16*/h("hello");
|
/////*16*/h("hello");
|
||||||
|
|
||||||
|
debugger;
|
||||||
var marker = 0;
|
var marker = 0;
|
||||||
function verifyConst(name: string, typeDisplay: ts.SymbolDisplayPart[], optionalNameDisplay?: ts.SymbolDisplayPart[], optionalKindModifiers?: string) {
|
function verifyConst(name: string, typeDisplay: ts.SymbolDisplayPart[], optionalNameDisplay?: ts.SymbolDisplayPart[], optionalKindModifiers?: string) {
|
||||||
marker++;
|
marker++;
|
||||||
|
|
Loading…
Reference in a new issue