Merge branch 'master' into es6ImportExportEmit

Conflicts:
	src/compiler/diagnosticInformationMap.generated.ts
	src/compiler/diagnosticMessages.json
This commit is contained in:
Mohamed Hegazy
2015-03-16 12:11:43 -07:00
27 changed files with 688 additions and 237 deletions
+22 -9
View File
@@ -448,7 +448,7 @@ module ts {
let 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
let isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation);
if (!isUsedBeforeDeclaration) {
@@ -465,7 +465,7 @@ module ts {
if (variableDeclaration.parent.parent.kind === SyntaxKind.VariableStatement ||
variableDeclaration.parent.parent.kind === SyntaxKind.ForStatement) {
// variable statement/for statement case,
// variable statement/for statement case,
// use site should not be inside variable declaration (initializer of declaration or binding element)
isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container);
}
@@ -4417,7 +4417,7 @@ module ts {
}
/**
* Check if a Type was written as a tuple type literal.
* Check if a Type was written as a tuple type literal.
* Prefer using isTupleLikeType() unless the use of `elementTypes` is required.
*/
function isTupleType(type: Type) : boolean {
@@ -9097,7 +9097,7 @@ module ts {
*/
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.
let arrayType = removeTypesFromUnionType(arrayOrStringType, TypeFlags.StringLike, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true);
@@ -11357,16 +11357,15 @@ module ts {
}
}
function checkGrammarTypeParameterList(node: FunctionLikeDeclaration, typeParameters: NodeArray<TypeParameterDeclaration>): boolean {
function checkGrammarTypeParameterList(node: FunctionLikeDeclaration, typeParameters: NodeArray<TypeParameterDeclaration>, file: SourceFile): boolean {
if (checkGrammarForDisallowedTrailingComma(typeParameters)) {
return true;
}
if (typeParameters && typeParameters.length === 0) {
let start = typeParameters.pos - "<".length;
let sourceFile = getSourceFileOfNode(node);
let end = skipTrivia(sourceFile.text, typeParameters.end) + ">".length;
return grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Type_parameter_list_cannot_be_empty);
let end = skipTrivia(file.text, typeParameters.end) + ">".length;
return grammarErrorAtPos(file, start, end - start, Diagnostics.Type_parameter_list_cannot_be_empty);
}
}
@@ -11410,7 +11409,21 @@ module ts {
function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean {
// Prevent cascading error by short-circuit
return checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters) || checkGrammarParameterList(node.parameters);
let file = getSourceFileOfNode(node);
return checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) ||
checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file);
}
function checkGrammarArrowFunction(node: FunctionLikeDeclaration, file: SourceFile): boolean {
if (node.kind === SyntaxKind.ArrowFunction) {
let arrowFunction = <ArrowFunction>node;
let startLine = getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line;
let endLine = getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line;
if (startLine !== endLine) {
return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, Diagnostics.Line_terminator_not_permitted_before_arrow);
}
}
return false;
}
function checkGrammarIndexSignatureParameters(node: SignatureDeclaration): boolean {
@@ -157,9 +157,10 @@ module ts {
Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." },
An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." },
Unterminated_Unicode_escape_sequence: { code: 1199, category: DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." },
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1200, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." },
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1201, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." },
Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1202, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." },
Line_terminator_not_permitted_before_arrow: { code: 1200, category: DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." },
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1201, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." },
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1202, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." },
Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1203, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." },
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
+7 -3
View File
@@ -619,18 +619,22 @@
"category": "Error",
"code": 1199
},
"Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead.": {
"Line terminator not permitted before arrow.": {
"category": "Error",
"code": 1200
},
"Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.": {
"Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead.": {
"category": "Error",
"code": 1201
},
"Cannot compile external modules into amd or commonjs when targeting es6 or higher.": {
"Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.": {
"category": "Error",
"code": 1202
},
"Cannot compile external modules into amd or commonjs when targeting es6 or higher.": {
"category": "Error",
"code": 1203
},
"Duplicate identifier '{0}'.": {
"category": "Error",
+175 -176
View File
File diff suppressed because it is too large Load Diff
+24 -20
View File
@@ -329,7 +329,7 @@ module ts {
// If the parser encountered an error when parsing the code that created this node. Note
// the parser only sets this directly on the node it creates right after encountering the
// error.
// error.
ThisNodeHasError = 1 << 4,
// Context flags set directly by the parser.
@@ -337,7 +337,7 @@ module ts {
// Context flags computed by aggregating child flags upwards.
// Used during incremental parsing to determine if this node or any of its children had an
// Used during incremental parsing to determine if this node or any of its children had an
// error. Computed only once and then cached.
ThisNodeOrAnySubNodesHasError = 1 << 5,
@@ -354,7 +354,7 @@ module ts {
export interface Node extends TextRange {
kind: SyntaxKind;
flags: NodeFlags;
// Specific context the parser was in when this node was created. Normally undefined.
// Specific context the parser was in when this node was created. Normally undefined.
// Only set when the parser was in some interesting context (like async/yield).
parserContextFlags?: ParserContextFlags;
modifiers?: ModifiersArray; // Array of modifiers
@@ -524,7 +524,7 @@ module ts {
body?: Block;
}
// See the comment on MethodDeclaration for the intuition behind AccessorDeclaration being a
// See the comment on MethodDeclaration for the intuition behind AccessorDeclaration being a
// ClassElement and an ObjectLiteralElement.
export interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
_accessorDeclarationBrand: any;
@@ -575,12 +575,12 @@ module ts {
export interface StringLiteralTypeNode extends LiteralExpression, TypeNode { }
// Note: 'brands' in our syntax nodes serve to give us a small amount of nominal typing.
// Note: 'brands' in our syntax nodes serve to give us a small amount of nominal typing.
// Consider 'Expression'. Without the brand, 'Expression' is actually no different
// (structurally) than 'Node'. Because of this you can pass any Node to a function that
// takes an Expression without any error. By using the 'brands' we ensure that the type
// checker actually thinks you have something of the right type. Note: the brands are
// never actually given values. At runtime they have zero cost.
// checker actually thinks you have something of the right type. Note: the brands are
// never actually given values. At runtime they have zero cost.
export interface Expression extends Node {
_expressionBrand: any;
@@ -653,6 +653,10 @@ module ts {
body: Block | Expression; // Required, whereas the member inherited from FunctionDeclaration is optional
}
export interface ArrowFunction extends Expression, FunctionLikeDeclaration {
equalsGreaterThanToken: Node;
}
// The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral,
// or any literal of a template, this means quotes have been removed and escapes have been converted to actual characters.
// For a NumericLiteral, the stored value is the toString() representation of the number. For example 1, 1.00, and 1e0 are all stored as just "1".
@@ -735,7 +739,7 @@ module ts {
}
export interface VariableStatement extends Statement {
declarationList: VariableDeclarationList;
declarationList: VariableDeclarationList;
}
export interface ExpressionStatement extends Statement {
@@ -903,7 +907,7 @@ module ts {
moduleSpecifier: Expression;
}
// In case of:
// In case of:
// import d from "mod" => name = d, namedBinding = undefined
// import * as ns from "mod" => name = undefined, namedBinding: NamespaceImport = { name: ns }
// import d, * as ns from "mod" => name = d, namedBinding: NamespaceImport = { name: ns }
@@ -969,7 +973,7 @@ module ts {
externalModuleIndicator: Node;
languageVersion: ScriptTarget;
identifiers: Map<string>;
/* @internal */ nodeCount: number;
/* @internal */ identifierCount: number;
/* @internal */ symbolCount: number;
@@ -977,10 +981,10 @@ module ts {
// File level diagnostics reported by the parser (includes diagnostics about /// references
// as well as code diagnostics).
/* @internal */ parseDiagnostics: Diagnostic[];
// File level diagnostics reported by the binder.
/* @internal */ bindDiagnostics: Diagnostic[];
// Stores a line map for the file.
// This field should never be used directly to obtain line map, use getLineMap function instead.
/* @internal */ lineMap: number[];
@@ -1000,10 +1004,10 @@ module ts {
getSourceFiles(): SourceFile[];
/**
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
* the javascript and declaration files will be produced for all the files in this program.
* If targetSourceFile is specified, then only the javascript and declaration for that
* specific file will be generated.
* specific file will be generated.
*
* If writeFile is not specified then the writeFile callback from the compiler host will be
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
@@ -1021,7 +1025,7 @@ module ts {
getCommonSourceDirectory(): string;
// For testing purposes only. Should not be used by any other consumers (including the
// For testing purposes only. Should not be used by any other consumers (including the
// language service).
/* @internal */ getDiagnosticsProducingTypeChecker(): TypeChecker;
@@ -1058,7 +1062,7 @@ module ts {
// when -version or -help was provided, or this was a normal compilation, no diagnostics
// were produced, and all outputs were generated successfully.
Success = 0,
// Diagnostics were produced and because of them no code was generated.
DiagnosticsPresent_OutputsSkipped = 1,
@@ -1168,12 +1172,12 @@ module ts {
// Write symbols's type argument if it is instantiated symbol
// eg. class C<T> { p: T } <-- Show p as C<T>.p here
// var a: C<number>;
// var a: C<number>;
// var p = a.p; <--- Here p is property of C<number> so show it as C<number>.p instead of just C.p
WriteTypeParametersOrArguments = 0x00000001,
WriteTypeParametersOrArguments = 0x00000001,
// Use only external alias information to get the symbol name in the given context
// eg. module m { export class c { } } import x = m.c;
// eg. module m { export class c { } } import x = m.c;
// When this flag is specified m.c will be used to refer to the class instead of alias symbol x
UseOnlyExternalAliasing = 0x00000002,
}
@@ -1778,7 +1782,7 @@ module ts {
// Gets a count of how many times this collection has been modified. This value changes
// each time 'add' is called (regardless of whether or not an equivalent diagnostic was
// already in the collection). As such, it can be used as a simple way to tell if any
// operation caused diagnostics to be returned by storing and comparing the return value
// operation caused diagnostics to be returned by storing and comparing the return value
// of this method before/after the operation is performed.
getModificationCount(): number;
}