Merge branch 'master' into es6ImportExportEmit

This commit is contained in:
Mohamed Hegazy
2015-03-12 17:21:48 -07:00
143 changed files with 24028 additions and 8089 deletions
+9 -3
View File
@@ -179,19 +179,19 @@ interface ObjectConstructor {
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
seal(o: any): any;
seal<T>(o: T): T;
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
freeze(o: any): any;
freeze<T>(o: T): T;
/**
* Prevents the addition of new properties to an object.
* @param o Object to make non-extensible.
*/
preventExtensions(o: any): any;
preventExtensions<T>(o: T): T;
/**
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
@@ -425,6 +425,9 @@ interface String {
*/
substr(from: number, length?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): string;
[index: number]: string;
}
@@ -477,6 +480,9 @@ interface Number {
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
*/
toPrecision(precision?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): number;
}
interface NumberConstructor {
+9 -3
View File
@@ -179,19 +179,19 @@ interface ObjectConstructor {
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
seal(o: any): any;
seal<T>(o: T): T;
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
freeze(o: any): any;
freeze<T>(o: T): T;
/**
* Prevents the addition of new properties to an object.
* @param o Object to make non-extensible.
*/
preventExtensions(o: any): any;
preventExtensions<T>(o: T): T;
/**
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
@@ -425,6 +425,9 @@ interface String {
*/
substr(from: number, length?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): string;
[index: number]: string;
}
@@ -477,6 +480,9 @@ interface Number {
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
*/
toPrecision(precision?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): number;
}
interface NumberConstructor {
+9 -3
View File
@@ -179,19 +179,19 @@ interface ObjectConstructor {
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
seal(o: any): any;
seal<T>(o: T): T;
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
freeze(o: any): any;
freeze<T>(o: T): T;
/**
* Prevents the addition of new properties to an object.
* @param o Object to make non-extensible.
*/
preventExtensions(o: any): any;
preventExtensions<T>(o: T): T;
/**
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
@@ -425,6 +425,9 @@ interface String {
*/
substr(from: number, length?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): string;
[index: number]: string;
}
@@ -477,6 +480,9 @@ interface Number {
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
*/
toPrecision(precision?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): number;
}
interface NumberConstructor {
+9 -3
View File
@@ -179,19 +179,19 @@ interface ObjectConstructor {
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
seal(o: any): any;
seal<T>(o: T): T;
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
freeze(o: any): any;
freeze<T>(o: T): T;
/**
* Prevents the addition of new properties to an object.
* @param o Object to make non-extensible.
*/
preventExtensions(o: any): any;
preventExtensions<T>(o: T): T;
/**
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
@@ -425,6 +425,9 @@ interface String {
*/
substr(from: number, length?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): string;
[index: number]: string;
}
@@ -477,6 +480,9 @@ interface Number {
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
*/
toPrecision(precision?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): number;
}
interface NumberConstructor {
+573 -382
View File
File diff suppressed because it is too large Load Diff
+7600 -2490
View File
File diff suppressed because one or more lines are too long
+29 -21
View File
@@ -224,27 +224,28 @@ declare module "typescript" {
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
ImportEqualsDeclaration = 202,
ImportDeclaration = 203,
ImportClause = 204,
NamespaceImport = 205,
NamedImports = 206,
ImportSpecifier = 207,
ExportAssignment = 208,
ExportDeclaration = 209,
NamedExports = 210,
ExportSpecifier = 211,
ExternalModuleReference = 212,
CaseClause = 213,
DefaultClause = 214,
HeritageClause = 215,
CatchClause = 216,
PropertyAssignment = 217,
ShorthandPropertyAssignment = 218,
EnumMember = 219,
SourceFile = 220,
SyntaxList = 221,
Count = 222,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
@@ -619,6 +620,9 @@ declare module "typescript" {
}
interface SwitchStatement extends Statement {
expression: Expression;
caseBlock: CaseBlock;
}
interface CaseBlock extends Node {
clauses: NodeArray<CaseOrDefaultClause>;
}
interface CaseClause extends Node {
@@ -1197,6 +1201,7 @@ declare module "typescript" {
version?: boolean;
watch?: boolean;
stripInternal?: boolean;
preserveNewLines?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -1437,12 +1442,15 @@ declare module "typescript" {
function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker;
}
declare module "typescript" {
/** The version of the TypeScript compiler release */
var version: string;
function createCompilerHost(options: CompilerOptions): CompilerHost;
function getPreEmitDiagnostics(program: Program): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module "typescript" {
/** The version of the language service API */
var servicesVersion: string;
interface Node {
getSourceFile(): SourceFile;
+7264 -2344
View File
File diff suppressed because one or more lines are too long
+29 -21
View File
@@ -224,27 +224,28 @@ declare module ts {
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
ImportEqualsDeclaration = 202,
ImportDeclaration = 203,
ImportClause = 204,
NamespaceImport = 205,
NamedImports = 206,
ImportSpecifier = 207,
ExportAssignment = 208,
ExportDeclaration = 209,
NamedExports = 210,
ExportSpecifier = 211,
ExternalModuleReference = 212,
CaseClause = 213,
DefaultClause = 214,
HeritageClause = 215,
CatchClause = 216,
PropertyAssignment = 217,
ShorthandPropertyAssignment = 218,
EnumMember = 219,
SourceFile = 220,
SyntaxList = 221,
Count = 222,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
@@ -619,6 +620,9 @@ declare module ts {
}
interface SwitchStatement extends Statement {
expression: Expression;
caseBlock: CaseBlock;
}
interface CaseBlock extends Node {
clauses: NodeArray<CaseOrDefaultClause>;
}
interface CaseClause extends Node {
@@ -1197,6 +1201,7 @@ declare module ts {
version?: boolean;
watch?: boolean;
stripInternal?: boolean;
preserveNewLines?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -1437,12 +1442,15 @@ declare module ts {
function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker;
}
declare module ts {
/** The version of the TypeScript compiler release */
var version: string;
function createCompilerHost(options: CompilerOptions): CompilerHost;
function getPreEmitDiagnostics(program: Program): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module ts {
/** The version of the language service API */
var servicesVersion: string;
interface Node {
getSourceFile(): SourceFile;
+7264 -2344
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -171,6 +171,7 @@ declare module ts {
function unescapeIdentifier(identifier: string): string;
function makeIdentifierFromModuleName(moduleName: string): string;
function isBlockOrCatchScoped(declaration: Declaration): boolean;
function getEnclosingBlockScopeContainer(node: Node): Node;
function isCatchClauseVariableDeclaration(declaration: Declaration): boolean;
function declarationNameToString(name: DeclarationName): string;
function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic;
@@ -270,7 +271,6 @@ declare module ts {
function nodeIsSynthesized(node: Node): boolean;
function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node;
function generateUniqueName(baseName: string, isExistingName: (name: string) => boolean): string;
function createDiagnosticCollection(): DiagnosticCollection;
/**
* Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
* but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
+1 -1
View File
@@ -171,6 +171,7 @@ declare module "typescript" {
function unescapeIdentifier(identifier: string): string;
function makeIdentifierFromModuleName(moduleName: string): string;
function isBlockOrCatchScoped(declaration: Declaration): boolean;
function getEnclosingBlockScopeContainer(node: Node): Node;
function isCatchClauseVariableDeclaration(declaration: Declaration): boolean;
function declarationNameToString(name: DeclarationName): string;
function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic;
@@ -270,7 +271,6 @@ declare module "typescript" {
function nodeIsSynthesized(node: Node): boolean;
function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node;
function generateUniqueName(baseName: string, isExistingName: (name: string) => boolean): string;
function createDiagnosticCollection(): DiagnosticCollection;
/**
* Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
* but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
+145 -34
View File
@@ -435,18 +435,67 @@ module ts {
return undefined;
}
if (result.flags & SymbolFlags.BlockScopedVariable) {
// Block-scoped variables cannot be used before their definition
var declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) ? d : undefined);
Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
if (!isDefinedBefore(declaration, errorLocation)) {
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name));
}
checkResolvedBlockScopedVariable(result, errorLocation);
}
}
return result;
}
function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void {
Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0)
// Block-scoped variables cannot be used before their definition
var declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) ? d : undefined);
Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
// first check if usage is lexically located after the declaration
var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation);
if (!isUsedBeforeDeclaration) {
// lexical check succeeded however code still can be illegal.
// - block scoped variables cannot be used in its initializers
// let x = x; // illegal but usage is lexically after definition
// - in ForIn/ForOf statements variable cannot be contained in expression part
// for (let x in x)
// for (let x of x)
// climb up to the variable declaration skipping binding patterns
var variableDeclaration = <VariableDeclaration>getAncestor(declaration, SyntaxKind.VariableDeclaration);
var container = getEnclosingBlockScopeContainer(variableDeclaration);
if (variableDeclaration.parent.parent.kind === SyntaxKind.VariableStatement ||
variableDeclaration.parent.parent.kind === SyntaxKind.ForStatement) {
// variable statement/for statement case,
// use site should not be inside variable declaration (initializer of declaration or binding element)
isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container);
}
else if (variableDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement ||
variableDeclaration.parent.parent.kind === SyntaxKind.ForInStatement) {
// ForIn/ForOf case - use site should not be used in expression part
var expression = (<ForInStatement | ForOfStatement>variableDeclaration.parent.parent).expression;
isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container);
}
}
if (isUsedBeforeDeclaration) {
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name));
}
}
/* Starting from 'initial' node walk up the parent chain until 'stopAt' node is reached.
* If at any point current node is equal to 'parent' node - return true.
* Return false if 'stopAt' node is reached or isFunctionLike(current) === true.
*/
function isSameScopeDescendentOf(initial: Node, parent: Node, stopAt: Node): boolean {
if (!parent) {
return false;
}
for (var current = initial; current && current !== stopAt && !isFunctionLike(current); current = current.parent) {
if (current === parent) {
return true;
}
}
return false;
}
// An alias symbol is created by one of the following declarations:
// import <symbol> = ...
// import <symbol> from ...
@@ -1874,7 +1923,11 @@ module ts {
return anyType;
}
if (declaration.parent.parent.kind === SyntaxKind.ForOfStatement) {
return getTypeForVariableDeclarationInForOfStatement(<ForOfStatement>declaration.parent.parent);
// checkRightHandSideOfForOf will return undefined if the for-of expression type was
// missing properties/signatures required to get its iteratedType (like
// [Symbol.iterator] or next). This may be because we accessed properties from anyType,
// or it may have led to an error inside getIteratedType.
return checkRightHandSideOfForOf((<ForOfStatement>declaration.parent.parent).expression) || anyType;
}
if (isBindingPattern(declaration.parent)) {
return getTypeForBindingElement(<BindingElement>declaration);
@@ -4715,17 +4768,22 @@ module ts {
// For a union type, remove all constituent types that are of the given type kind (when isOfTypeKind is true)
// or not of the given type kind (when isOfTypeKind is false)
function removeTypesFromUnionType(type: Type, typeKind: TypeFlags, isOfTypeKind: boolean): Type {
function removeTypesFromUnionType(type: Type, typeKind: TypeFlags, isOfTypeKind: boolean, allowEmptyUnionResult: boolean): Type {
if (type.flags & TypeFlags.Union) {
var types = (<UnionType>type).types;
if (forEach(types, t => !!(t.flags & typeKind) === isOfTypeKind)) {
// Above we checked if we have anything to remove, now use the opposite test to do the removal
var narrowedType = getUnionType(filter(types, t => !(t.flags & typeKind) === isOfTypeKind));
if (narrowedType !== emptyObjectType) {
if (allowEmptyUnionResult || narrowedType !== emptyObjectType) {
return narrowedType;
}
}
}
else if (allowEmptyUnionResult && !!(type.flags & typeKind) === isOfTypeKind) {
// Use getUnionType(emptyArray) instead of emptyObjectType in case the way empty union types
// are represented ever changes.
return getUnionType(emptyArray);
}
return type;
}
@@ -4928,7 +4986,8 @@ module ts {
if (assumeTrue) {
// Assumed result is true. If check was not for a primitive type, remove all primitive types
if (!typeInfo) {
return removeTypesFromUnionType(type, /*typeKind*/ TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.Boolean | TypeFlags.ESSymbol, /*isOfTypeKind*/ true);
return removeTypesFromUnionType(type, /*typeKind*/ TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.Boolean | TypeFlags.ESSymbol,
/*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false);
}
// Check was for a primitive type, return that primitive type if it is a subtype
if (isTypeSubtypeOf(typeInfo.type, type)) {
@@ -4936,12 +4995,12 @@ module ts {
}
// Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is
// union of enum types and other types.
return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false);
return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ false);
}
else {
// Assumed result is false. If check was for a primitive type, remove that primitive type
if (typeInfo) {
return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true);
return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false);
}
// Otherwise we don't have enough information to do anything.
return type;
@@ -8782,16 +8841,11 @@ module ts {
}
function checkForOfStatement(node: ForOfStatement): void {
if (languageVersion < ScriptTarget.ES6) {
grammarErrorOnFirstToken(node, Diagnostics.for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher);
return;
}
checkGrammarForInOrForOfStatement(node)
// Check the LHS and RHS
// If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS
// via getTypeForVariableDeclarationInForOfStatement.
// via checkRightHandSideOfForOf.
// If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference.
// Then check that the RHS is assignable to it.
if (node.initializer.kind === SyntaxKind.VariableDeclarationList) {
@@ -8799,8 +8853,7 @@ module ts {
}
else {
var varExpr = <Expression>node.initializer;
var rightType = checkExpression(node.expression);
var iteratedType = checkIteratedType(rightType, node.expression);
var iteratedType = checkRightHandSideOfForOf(node.expression);
// There may be a destructuring assignment on the left side
if (varExpr.kind === SyntaxKind.ArrayLiteralExpression || varExpr.kind === SyntaxKind.ObjectLiteralExpression) {
@@ -8882,18 +8935,11 @@ module ts {
}
}
function getTypeForVariableDeclarationInForOfStatement(forOfStatement: ForOfStatement): Type {
// Temporarily return 'any' below ES6
if (languageVersion < ScriptTarget.ES6) {
return anyType;
}
// iteratedType will be undefined if the for-of expression type was missing properties/signatures
// required to get its iteratedType (like [Symbol.iterator] or next). This may be
// because we accessed properties from anyType, or it may have led to an error inside
// getIteratedType.
var expressionType = getTypeOfExpression(forOfStatement.expression);
return checkIteratedType(expressionType, forOfStatement.expression) || anyType;
function checkRightHandSideOfForOf(rhsExpression: Expression): Type {
var expressionType = getTypeOfExpression(rhsExpression);
return languageVersion >= ScriptTarget.ES6
? checkIteratedType(expressionType, rhsExpression)
: checkElementTypeOfArrayOrString(expressionType, rhsExpression);
}
/**
@@ -8992,6 +9038,72 @@ module 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.
*
* For example:
* string -> string
* number[] -> number
* string[] | number[] -> string | number
* string | number[] -> string | number
* string | string[] | number[] -> string | number
*
* It also errors if:
* 1. Some constituent is neither a string nor an array.
* 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable).
*/
function checkElementTypeOfArrayOrString(arrayOrStringType: Type, expressionForError: Expression): Type {
Debug.assert(languageVersion < ScriptTarget.ES6);
// After we remove all types that are StringLike, we will know if there was a string constituent
// based on whether the remaining type is the same as the initial type.
var arrayType = removeTypesFromUnionType(arrayOrStringType, TypeFlags.StringLike, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true);
var hasStringConstituent = arrayOrStringType !== arrayType;
var reportedError = false;
if (hasStringConstituent) {
if (languageVersion < ScriptTarget.ES5) {
error(expressionForError, Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
reportedError = true;
}
// Now that we've removed all the StringLike types, if no constituents remain, then the entire
// arrayOrStringType was a string.
if (arrayType === emptyObjectType) {
return stringType;
}
}
if (!isArrayLikeType(arrayType)) {
if (!reportedError) {
// Which error we report depends on whether there was a string constituent. For example,
// if the input type is number | string, we want to say that number is not an array type.
// But if the input was just number, we want to say that number is not an array type
// or a string type.
var diagnostic = hasStringConstituent
? Diagnostics.Type_0_is_not_an_array_type
: Diagnostics.Type_0_is_not_an_array_type_or_a_string_type;
error(expressionForError, diagnostic, typeToString(arrayType));
}
return hasStringConstituent ? stringType : unknownType;
}
var arrayElementType = getIndexTypeOfType(arrayType, IndexKind.Number) || unknownType;
if (hasStringConstituent) {
// This is just an optimization for the case where arrayOrStringType is string | string[]
if (arrayElementType.flags & TypeFlags.StringLike) {
return stringType;
}
return getUnionType([arrayElementType, stringType]);
}
return arrayElementType;
}
function checkBreakOrContinueStatement(node: BreakOrContinueStatement) {
// Grammar checking
checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node);
@@ -10953,7 +11065,6 @@ module ts {
}
function isUnknownIdentifier(location: Node, name: string): boolean {
// Do not call resolveName on a synthesized node!
Debug.assert(!nodeIsSynthesized(location), "isUnknownIdentifier called with a synthesized location");
return !resolveName(location, name, SymbolFlags.Value, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined) &&
!hasProperty(getGeneratedNamesForSourceFile(getSourceFile(location)), name);
+4
View File
@@ -269,8 +269,12 @@ module ts {
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
var end = start + length;
Debug.assert(start >= 0, "start must be non-negative, is " + start);
Debug.assert(length >= 0, "length must be non-negative, is " + length);
Debug.assert(start <= file.text.length, `start must be within the bounds of the file. ${ start } > ${ file.text.length }`);
Debug.assert(end <= file.text.length, `end must be the bounds of the file. ${ end } > ${ file.text.length }`);
var text = getLocaleSpecificMessage(message.key);
@@ -330,7 +330,6 @@ module ts {
Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." },
let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." },
Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." },
for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 2482, category: DiagnosticCategory.Error, key: "'for...of' statements are only available when targeting ECMAScript 6 or higher." },
The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." },
Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" },
The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." },
@@ -342,6 +341,8 @@ module ts {
The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." },
Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" },
Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." },
Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." },
Type_0_is_not_an_array_type_or_a_string_type: { code: 2461, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
+8 -4
View File
@@ -1312,10 +1312,6 @@
"category": "Error",
"code": 2481
},
"'for...of' statements are only available when targeting ECMAScript 6 or higher.": {
"category": "Error",
"code": 2482
},
"The left-hand side of a 'for...of' statement cannot use a type annotation.": {
"category": "Error",
"code": 2483
@@ -1360,6 +1356,14 @@
"category": "Error",
"code": 2493
},
"Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.": {
"category": "Error",
"code": 2494
},
"Type '{0}' is not an array type or a string type.": {
"category": "Error",
"code": 2461
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
-28
View File
@@ -4122,34 +4122,6 @@ module ts {
}
}
function getEnclosingBlockScopeContainer(node: Node): Node {
var current = node;
while (current) {
if (isFunctionLike(current)) {
return current;
}
switch (current.kind) {
case SyntaxKind.SourceFile:
case SyntaxKind.CaseBlock:
case SyntaxKind.CatchClause:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
return current;
case SyntaxKind.Block:
// function block is not considered block-scope container
// see comment in binder.ts: bind(...), case for SyntaxKind.Block
if (!isFunctionLike(current.parent)) {
return current;
}
}
current = current.parent;
}
}
function getCombinedFlagsForIdentifier(node: Identifier): NodeFlags {
if (!node.parent || (node.parent.kind !== SyntaxKind.VariableDeclaration && node.parent.kind !== SyntaxKind.BindingElement)) {
return 0;
+27
View File
@@ -203,6 +203,33 @@ module ts {
isCatchClauseVariableDeclaration(declaration);
}
export function getEnclosingBlockScopeContainer(node: Node): Node {
var current = node;
while (current) {
if (isFunctionLike(current)) {
return current;
}
switch (current.kind) {
case SyntaxKind.SourceFile:
case SyntaxKind.CaseBlock:
case SyntaxKind.CatchClause:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
return current;
case SyntaxKind.Block:
// function block is not considered block-scope container
// see comment in binder.ts: bind(...), case for SyntaxKind.Block
if (!isFunctionLike(current.parent)) {
return current;
}
}
current = current.parent;
}
}
export function isCatchClauseVariableDeclaration(declaration: Declaration) {
return declaration &&
declaration.kind === SyntaxKind.VariableDeclaration &&
@@ -0,0 +1,7 @@
tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck1.ts(1,15): error TS2494: Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.
==== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck1.ts (1 errors) ====
for (var v of "") { }
~~
!!! error TS2494: Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.
@@ -0,0 +1,7 @@
//// [ES3For-ofTypeCheck1.ts]
for (var v of "") { }
//// [ES3For-ofTypeCheck1.js]
for (var _i = 0, _a = ""; _i < _a.length; _i++) {
var v = _a[_i];
}
@@ -0,0 +1,9 @@
//// [ES3For-ofTypeCheck2.ts]
for (var v of [true]) { }
//// [ES3For-ofTypeCheck2.js]
for (var _i = 0, _a = [
true
]; _i < _a.length; _i++) {
var v = _a[_i];
}
@@ -0,0 +1,5 @@
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck2.ts ===
for (var v of [true]) { }
>v : boolean
>[true] : boolean[]
@@ -0,0 +1,8 @@
tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck4.ts(2,17): error TS2494: Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.
==== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck4.ts (1 errors) ====
var union: string | string[];
for (const v of union) { }
~~~~~
!!! error TS2494: Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.
@@ -0,0 +1,9 @@
//// [ES3For-ofTypeCheck4.ts]
var union: string | string[];
for (const v of union) { }
//// [ES3For-ofTypeCheck4.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,9 @@
//// [ES3For-ofTypeCheck6.ts]
var union: string[] | number[];
for (var v of union) { }
//// [ES3For-ofTypeCheck6.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck6.ts ===
var union: string[] | number[];
>union : string[] | number[]
for (var v of union) { }
>v : string | number
>union : string[] | number[]
@@ -1,9 +1,9 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts(2,5): error TS2304: Cannot find name 'console'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts (1 errors) ====
for (var v of ['a', 'b', 'c']) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
console.log(v);
~~~~~~~
!!! error TS2304: Cannot find name 'console'.
}
@@ -1,13 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of10.ts(4,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of10.ts (1 errors) ====
function foo() {
return { x: 0 };
}
for (foo().x of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
for (foo().x of [])
var p = foo().x;
}
@@ -0,0 +1,29 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of10.ts ===
function foo() {
>foo : () => { x: number; }
return { x: 0 };
>{ x: 0 } : { x: number; }
>x : number
}
for (foo().x of []) {
>foo().x : number
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
>[] : undefined[]
for (foo().x of [])
>foo().x : number
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
>[] : undefined[]
var p = foo().x;
>p : number
>foo().x : number
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
}
@@ -1,8 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of11.ts(2,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of11.ts (1 errors) ====
var v;
for (v of []) { }
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
@@ -0,0 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of11.ts ===
var v;
>v : any
for (v of []) { }
>v : any
>[] : undefined[]
@@ -1,7 +1,7 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts(1,7): error TS2364: Invalid left-hand side of assignment expression.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts (1 errors) ====
for ([""] of []) { }
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
for ([""] of [[""]]) { }
~~
!!! error TS2364: Invalid left-hand side of assignment expression.
+6 -2
View File
@@ -1,7 +1,11 @@
//// [ES5For-of12.ts]
for ([""] of []) { }
for ([""] of [[""]]) { }
//// [ES5For-of12.js]
for (var _i = 0, _a = []; _i < _a.length; _i++) {
for (var _i = 0, _a = [
[
""
]
]; _i < _a.length; _i++) {
"" = _a[_i][0];
}
@@ -1,9 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of13.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of13.ts (1 errors) ====
for (let v of ['a', 'b', 'c']) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = v;
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of13.ts ===
for (let v of ['a', 'b', 'c']) {
>v : string
>['a', 'b', 'c'] : string[]
var x = v;
>x : string
>v : string
}
@@ -1,9 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of14.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of14.ts (1 errors) ====
for (const v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = v;
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of14.ts ===
for (const v of []) {
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
}
@@ -1,12 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of15.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of15.ts (1 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
for (const v of []) {
var x = v;
}
}
@@ -0,0 +1,17 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of15.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
for (const v of []) {
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
}
}
@@ -1,13 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of16.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of16.ts (1 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
for (let v of []) {
var x = v;
v++;
}
}
@@ -0,0 +1,21 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of16.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
for (let v of []) {
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
v++;
>v++ : number
>v : any
}
}
@@ -1,12 +1,12 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of17.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of17.ts(3,20): error TS2448: Block-scoped variable 'v' used before its declaration.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of17.ts (1 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
for (let v of [v]) {
~
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
var x = v;
v++;
}
@@ -1,16 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of18.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of18.ts(4,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of18.ts (2 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
}
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
}
@@ -0,0 +1,16 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of18.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
}
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
}
@@ -1,15 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of19.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of19.ts (1 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
function foo() {
for (const v of []) {
v;
}
}
}
@@ -0,0 +1,21 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of19.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
function foo() {
>foo : () => void
for (const v of []) {
>v : any
>[] : undefined[]
v;
>v : any
}
}
}
@@ -1,9 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of2.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of2.ts (1 errors) ====
for (var v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = v;
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of2.ts ===
for (var v of []) {
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
}
@@ -1,12 +1,15 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts(3,20): error TS2448: Block-scoped variable 'v' used before its declaration.
tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts(4,15): error TS1155: 'const' declarations must be initialized
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts (1 errors) ====
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts (2 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
let v;
for (let v of [v]) {
~
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
const v;
~
!!! error TS1155: 'const' declarations must be initialized
}
}
@@ -1,9 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of21.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of21.ts (1 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
for (let _i of []) { }
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of21.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
for (let _i of []) { }
>_i : any
>[] : undefined[]
}
@@ -1,10 +1,10 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of22.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of22.ts(3,5): error TS2304: Cannot find name 'console'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of22.ts (1 errors) ====
for (var x of [1, 2, 3]) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
let _a = 0;
console.log(x);
~~~~~~~
!!! error TS2304: Cannot find name 'console'.
}
@@ -1,10 +1,10 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of23.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of23.ts(3,5): error TS2304: Cannot find name 'console'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of23.ts (1 errors) ====
for (var x of [1, 2, 3]) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var _a = 0;
console.log(x);
~~~~~~~
!!! error TS2304: Cannot find name 'console'.
}
@@ -1,10 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of24.ts(2,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of24.ts (1 errors) ====
var a = [1, 2, 3];
for (var v of a) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
let a = 0;
}
@@ -0,0 +1,12 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of24.ts ===
var a = [1, 2, 3];
>a : number[]
>[1, 2, 3] : number[]
for (var v of a) {
>v : number
>a : number[]
let a = 0;
>a : number
}
@@ -1,11 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of25.ts(2,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of25.ts (1 errors) ====
var a = [1, 2, 3];
for (var v of a) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
a;
}
@@ -0,0 +1,15 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of25.ts ===
var a = [1, 2, 3];
>a : number[]
>[1, 2, 3] : number[]
for (var v of a) {
>v : number
>a : number[]
v;
>v : number
a;
>a : number[]
}
@@ -1,10 +1,10 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of26.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of26.ts(1,10): error TS2461: Type 'number' is not an array type.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of26.ts (1 errors) ====
for (var [a = 0, b = 1] of [2, 3]) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~~~~~~~~~~~~~~
!!! error TS2461: Type 'number' is not an array type.
a;
b;
}
@@ -1,10 +1,13 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts(1,11): error TS2459: Type 'number' has no property 'x' and no string index signature.
tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts(1,21): error TS2459: Type 'number' has no property 'y' and no string index signature.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts (1 errors) ====
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts (2 errors) ====
for (var {x: a = 0, y: b = 1} of [2, 3]) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~
!!! error TS2459: Type 'number' has no property 'x' and no string index signature.
~
!!! error TS2459: Type 'number' has no property 'y' and no string index signature.
a;
b;
}
@@ -1,10 +1,10 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of28.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of28.ts(1,10): error TS2461: Type 'number' is not an array type.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of28.ts (1 errors) ====
for (let [a = 0, b = 1] of [2, 3]) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~~~~~~~~~~~~~~
!!! error TS2461: Type 'number' is not an array type.
a;
b;
}
@@ -1,10 +1,13 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of29.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of29.ts(1,13): error TS2459: Type 'number' has no property 'x' and no string index signature.
tests/cases/conformance/statements/for-ofStatements/ES5For-of29.ts(1,23): error TS2459: Type 'number' has no property 'y' and no string index signature.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of29.ts (1 errors) ====
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of29.ts (2 errors) ====
for (const {x: a = 0, y: b = 1} of [2, 3]) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~
!!! error TS2459: Type 'number' has no property 'x' and no string index signature.
~
!!! error TS2459: Type 'number' has no property 'y' and no string index signature.
a;
b;
}
@@ -1,8 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of3.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of3.ts (1 errors) ====
for (var v of ['a', 'b', 'c'])
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = v;
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of3.ts ===
for (var v of ['a', 'b', 'c'])
>v : string
>['a', 'b', 'c'] : string[]
var x = v;
>x : string
>v : string
@@ -1,12 +1,12 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,6): error TS2461: Type 'string | number' is not an array type.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts (1 errors) ====
var a: string, b: number;
var tuple: [number, string] = [2, "3"];
for ([a = 1, b = ""] of tuple) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~~~~~~~~~~~~~~~
!!! error TS2461: Type 'string | number' is not an array type.
a;
b;
}
@@ -1,12 +1,15 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of31.ts(3,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of31.ts(3,8): error TS2459: Type 'undefined' has no property 'a' and no string index signature.
tests/cases/conformance/statements/for-ofStatements/ES5For-of31.ts(3,18): error TS2459: Type 'undefined' has no property 'b' and no string index signature.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of31.ts (1 errors) ====
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of31.ts (2 errors) ====
var a: string, b: number;
for ({ a: b = 1, b: a = ""} of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~
!!! error TS2459: Type 'undefined' has no property 'a' and no string index signature.
~
!!! error TS2459: Type 'undefined' has no property 'b' and no string index signature.
a;
b;
}
@@ -1,9 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of4.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of4.ts (1 errors) ====
for (var v of [])
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = v;
var y = v;
@@ -0,0 +1,13 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of4.ts ===
for (var v of [])
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
var y = v;
>y : any
>v : any
@@ -1,9 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of5.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of5.ts (1 errors) ====
for (var _a of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = _a;
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of5.ts ===
for (var _a of []) {
>_a : any
>[] : undefined[]
var x = _a;
>x : any
>_a : any
}
@@ -1,11 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of6.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of6.ts (1 errors) ====
for (var w of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
for (var v of []) {
var x = [w, v];
}
}
@@ -0,0 +1,16 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of6.ts ===
for (var w of []) {
>w : any
>[] : undefined[]
for (var v of []) {
>v : any
>[] : undefined[]
var x = [w, v];
>x : any[]
>[w, v] : any[]
>w : any
>v : any
}
}
@@ -1,16 +1,13 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of7.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of7.ts(5,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of7.ts(6,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'any[]'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of7.ts (2 errors) ====
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of7.ts (1 errors) ====
for (var w of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = w;
}
for (var v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = [w, v];
~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'any[]'.
}
@@ -1,4 +1,4 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of8.ts(4,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of8.ts(4,6): error TS2322: Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of8.ts (1 errors) ====
@@ -6,7 +6,7 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-of8.ts(4,1): error TS
return { x: 0 };
}
for (foo().x of ['a', 'b', 'c']) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~~~~~~~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var p = foo().x;
}
@@ -1,14 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of9.ts(4,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of9.ts (1 errors) ====
function foo() {
return { x: 0 };
}
for (foo().x of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
for (foo().x of []) {
var p = foo().x;
}
}
@@ -0,0 +1,30 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of9.ts ===
function foo() {
>foo : () => { x: number; }
return { x: 0 };
>{ x: 0 } : { x: number; }
>x : number
}
for (foo().x of []) {
>foo().x : number
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
>[] : undefined[]
for (foo().x of []) {
>foo().x : number
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
>[] : undefined[]
var p = foo().x;
>p : number
>foo().x : number
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
}
}
@@ -0,0 +1,7 @@
//// [ES5For-ofTypeCheck1.ts]
for (var v of "") { }
//// [ES5For-ofTypeCheck1.js]
for (var _i = 0, _a = ""; _i < _a.length; _i++) {
var v = _a[_i];
}
@@ -0,0 +1,4 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck1.ts ===
for (var v of "") { }
>v : string
@@ -0,0 +1,23 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(1,15): error TS2461: Type 'StringIterator' is not an array type or a string type.
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(11,6): error TS2304: Cannot find name 'Symbol'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts (2 errors) ====
for (var v of new StringIterator) { }
~~~~~~~~~~~~~~~~~~
!!! error TS2461: Type 'StringIterator' is not an array type or a string type.
// In ES3/5, you cannot for...of over an arbitrary iterable.
class StringIterator {
next() {
return {
done: true,
value: ""
};
}
[Symbol.iterator]() {
~~~~~~
!!! error TS2304: Cannot find name 'Symbol'.
return this;
}
}
@@ -0,0 +1,35 @@
//// [ES5For-ofTypeCheck10.ts]
for (var v of new StringIterator) { }
// In ES3/5, you cannot for...of over an arbitrary iterable.
class StringIterator {
next() {
return {
done: true,
value: ""
};
}
[Symbol.iterator]() {
return this;
}
}
//// [ES5For-ofTypeCheck10.js]
for (var _i = 0, _a = new StringIterator; _i < _a.length; _i++) {
var v = _a[_i];
}
// In ES3/5, you cannot for...of over an arbitrary iterable.
var StringIterator = (function () {
function StringIterator() {
}
StringIterator.prototype.next = function () {
return {
done: true,
value: ""
};
};
StringIterator.prototype[Symbol.iterator] = function () {
return this;
};
return StringIterator;
})();
@@ -0,0 +1,11 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts(3,6): error TS2322: Type 'string | number' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts (1 errors) ====
var union: string | number[];
var v: string;
for (v of union) { }
~
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
@@ -0,0 +1,11 @@
//// [ES5For-ofTypeCheck11.ts]
var union: string | number[];
var v: string;
for (v of union) { }
//// [ES5For-ofTypeCheck11.js]
var union;
var v;
for (var _i = 0; _i < union.length; _i++) {
v = union[_i];
}
@@ -0,0 +1,7 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts(1,17): error TS2461: Type 'number' is not an array type or a string type.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts (1 errors) ====
for (const v of 0) { }
~
!!! error TS2461: Type 'number' is not an array type or a string type.
@@ -0,0 +1,7 @@
//// [ES5For-ofTypeCheck12.ts]
for (const v of 0) { }
//// [ES5For-ofTypeCheck12.js]
for (var _i = 0, _a = 0; _i < _a.length; _i++) {
var v = _a[_i];
}
@@ -0,0 +1,9 @@
//// [ES5For-ofTypeCheck2.ts]
for (var v of [true]) { }
//// [ES5For-ofTypeCheck2.js]
for (var _i = 0, _a = [
true
]; _i < _a.length; _i++) {
var v = _a[_i];
}
@@ -0,0 +1,5 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck2.ts ===
for (var v of [true]) { }
>v : boolean
>[true] : boolean[]
@@ -0,0 +1,12 @@
//// [ES5For-ofTypeCheck3.ts]
var tuple: [string, number] = ["", 0];
for (var v of tuple) { }
//// [ES5For-ofTypeCheck3.js]
var tuple = [
"",
0
];
for (var _i = 0; _i < tuple.length; _i++) {
var v = tuple[_i];
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck3.ts ===
var tuple: [string, number] = ["", 0];
>tuple : [string, number]
>["", 0] : [string, number]
for (var v of tuple) { }
>v : string | number
>tuple : [string, number]
@@ -0,0 +1,9 @@
//// [ES5For-ofTypeCheck4.ts]
var union: string | string[];
for (const v of union) { }
//// [ES5For-ofTypeCheck4.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck4.ts ===
var union: string | string[];
>union : string | string[]
for (const v of union) { }
>v : string
>union : string | string[]
@@ -0,0 +1,9 @@
//// [ES5For-ofTypeCheck5.ts]
var union: string | number[];
for (var v of union) { }
//// [ES5For-ofTypeCheck5.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck5.ts ===
var union: string | number[];
>union : string | number[]
for (var v of union) { }
>v : string | number
>union : string | number[]
@@ -0,0 +1,9 @@
//// [ES5For-ofTypeCheck6.ts]
var union: string[] | number[];
for (var v of union) { }
//// [ES5For-ofTypeCheck6.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck6.ts ===
var union: string[] | number[];
>union : string[] | number[]
for (var v of union) { }
>v : string | number
>union : string[] | number[]
@@ -0,0 +1,8 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck7.ts(2,15): error TS2461: Type 'number' is not an array type.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck7.ts (1 errors) ====
var union: string | number;
for (var v of union) { }
~~~~~
!!! error TS2461: Type 'number' is not an array type.
@@ -0,0 +1,9 @@
//// [ES5For-ofTypeCheck7.ts]
var union: string | number;
for (var v of union) { }
//// [ES5For-ofTypeCheck7.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,11 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck8.ts(3,6): error TS2322: Type 'string | number | symbol' is not assignable to type 'symbol'.
Type 'string' is not assignable to type 'symbol'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck8.ts (1 errors) ====
var union: string | string[]| number[]| symbol[];
var v: symbol;
for (v of union) { }
~
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'symbol'.
!!! error TS2322: Type 'string' is not assignable to type 'symbol'.
@@ -0,0 +1,11 @@
//// [ES5For-ofTypeCheck8.ts]
var union: string | string[]| number[]| symbol[];
var v: symbol;
for (v of union) { }
//// [ES5For-ofTypeCheck8.js]
var union;
var v;
for (var _i = 0; _i < union.length; _i++) {
v = union[_i];
}
@@ -0,0 +1,8 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts(2,15): error TS2461: Type 'number | symbol | string[]' is not an array type.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts (1 errors) ====
var union: string | string[] | number | symbol;
for (let v of union) { }
~~~~~
!!! error TS2461: Type 'number | symbol | string[]' is not an array type.
@@ -0,0 +1,9 @@
//// [ES5For-ofTypeCheck9.ts]
var union: string | string[] | number | symbol;
for (let v of union) { }
//// [ES5For-ofTypeCheck9.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -1,12 +1,10 @@
tests/cases/compiler/downlevelLetConst16.ts(188,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(195,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(202,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(209,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(216,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(195,14): error TS2461: Type 'undefined' is not an array type.
tests/cases/compiler/downlevelLetConst16.ts(202,15): error TS2459: Type 'undefined' has no property 'a' and no string index signature.
tests/cases/compiler/downlevelLetConst16.ts(216,16): error TS2461: Type 'undefined' is not an array type.
tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefined' has no property 'a' and no string index signature.
==== tests/cases/compiler/downlevelLetConst16.ts (6 errors) ====
==== tests/cases/compiler/downlevelLetConst16.ts (4 errors) ====
'use strict'
declare function use(a: any);
@@ -195,8 +193,6 @@ tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' sta
function foo7() {
for (let x of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
use(x);
}
use(x);
@@ -204,8 +200,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' sta
function foo8() {
for (let [x] of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~~~
!!! error TS2461: Type 'undefined' is not an array type.
use(x);
}
use(x);
@@ -213,8 +209,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' sta
function foo9() {
for (let {a: x} of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~
!!! error TS2459: Type 'undefined' has no property 'a' and no string index signature.
use(x);
}
use(x);
@@ -222,8 +218,6 @@ tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' sta
function foo10() {
for (const x of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
use(x);
}
use(x);
@@ -231,8 +225,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' sta
function foo11() {
for (const [x] of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~~~
!!! error TS2461: Type 'undefined' is not an array type.
use(x);
}
use(x);
@@ -240,8 +234,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' sta
function foo12() {
for (const {a: x} of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~
!!! error TS2459: Type 'undefined' has no property 'a' and no string index signature.
use(x);
}
use(x);

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