mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge master
This commit is contained in:
+16
-4
@@ -173,6 +173,14 @@ namespace ts {
|
||||
return node.name ? declarationNameToString(node.name) : getDeclarationName(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names.
|
||||
* @param symbolTable - The symbol table which node will be added to.
|
||||
* @param parent - node's parent declaration.
|
||||
* @param node - The declaration to be added to the symbol table
|
||||
* @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.)
|
||||
* @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations.
|
||||
*/
|
||||
function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
|
||||
Debug.assert(!hasDynamicName(node));
|
||||
|
||||
@@ -181,10 +189,11 @@ namespace ts {
|
||||
|
||||
let symbol: Symbol;
|
||||
if (name !== undefined) {
|
||||
|
||||
// Check and see if the symbol table already has a symbol with this name. If not,
|
||||
// create a new symbol with this name and add it to the table. Note that we don't
|
||||
// give the new symbol any flags *yet*. This ensures that it will not conflict
|
||||
// witht he 'excludes' flags we pass in.
|
||||
// with the 'excludes' flags we pass in.
|
||||
//
|
||||
// If we do get an existing symbol, see if it conflicts with the new symbol we're
|
||||
// creating. For example, a 'var' symbol and a 'class' symbol will conflict within
|
||||
@@ -314,6 +323,7 @@ namespace ts {
|
||||
|
||||
addToContainerChain(container);
|
||||
}
|
||||
|
||||
else if (containerFlags & ContainerFlags.IsBlockScopedContainer) {
|
||||
blockScopeContainer = node;
|
||||
blockScopeContainer.locals = undefined;
|
||||
@@ -882,7 +892,8 @@ namespace ts {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
checkStrictModeFunctionName(<FunctionExpression>node);
|
||||
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, "__function");
|
||||
let bindingName = (<FunctionExpression>node).name ? (<FunctionExpression>node).name.text : "__function";
|
||||
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, bindingName);
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return bindClassLikeDeclaration(<ClassLikeDeclaration>node);
|
||||
@@ -954,7 +965,8 @@ namespace ts {
|
||||
bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
|
||||
}
|
||||
else {
|
||||
bindAnonymousDeclaration(node, SymbolFlags.Class, "__class");
|
||||
let bindingName = node.name ? node.name.text : "__class";
|
||||
bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName);
|
||||
}
|
||||
|
||||
let symbol = node.symbol;
|
||||
@@ -1044,4 +1056,4 @@ namespace ts {
|
||||
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1761
-344
File diff suppressed because it is too large
Load Diff
@@ -38,6 +38,16 @@ namespace ts {
|
||||
name: "inlineSources",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "jsx",
|
||||
type: {
|
||||
"preserve": JsxEmit.Preserve,
|
||||
"react": JsxEmit.React
|
||||
},
|
||||
paramType: Diagnostics.KIND,
|
||||
description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react,
|
||||
error: Diagnostics.Argument_for_jsx_must_be_preserve_or_react
|
||||
},
|
||||
{
|
||||
name: "listFiles",
|
||||
type: "boolean",
|
||||
@@ -193,6 +203,11 @@ namespace ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Watch_input_files,
|
||||
},
|
||||
{
|
||||
name: "experimentalAsyncFunctions",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Enables_experimental_support_for_ES7_async_functions
|
||||
},
|
||||
{
|
||||
name: "experimentalDecorators",
|
||||
type: "boolean",
|
||||
@@ -348,7 +363,7 @@ namespace ts {
|
||||
* Parse the contents of a config file (tsconfig.json).
|
||||
* @param json The contents of the config file to parse
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
export function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
|
||||
let errors: Diagnostic[] = [];
|
||||
@@ -410,10 +425,21 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
let exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
|
||||
let sysFiles = host.readDirectory(basePath, ".ts", exclude);
|
||||
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
|
||||
for (let i = 0; i < sysFiles.length; i++) {
|
||||
let name = sysFiles[i];
|
||||
if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) {
|
||||
if (fileExtensionIs(name, ".d.ts")) {
|
||||
let baseName = name.substr(0, name.length - ".d.ts".length);
|
||||
if (!contains(sysFiles, baseName + ".tsx") && !contains(sysFiles, baseName + ".ts")) {
|
||||
fileNames.push(name);
|
||||
}
|
||||
}
|
||||
else if (fileExtensionIs(name, ".ts")) {
|
||||
if (!contains(sysFiles, name + "x")) {
|
||||
fileNames.push(name)
|
||||
}
|
||||
}
|
||||
else {
|
||||
fileNames.push(name);
|
||||
}
|
||||
}
|
||||
|
||||
+20
-13
@@ -2,17 +2,19 @@
|
||||
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
// Ternary values are defined such that
|
||||
// x & y is False if either x or y is False.
|
||||
// x & y is Maybe if either x or y is Maybe, but neither x or y is False.
|
||||
// x & y is True if both x and y are True.
|
||||
// x | y is False if both x and y are False.
|
||||
// x | y is Maybe if either x or y is Maybe, but neither x or y is True.
|
||||
// x | y is True if either x or y is True.
|
||||
/**
|
||||
* Ternary values are defined such that
|
||||
* x & y is False if either x or y is False.
|
||||
* x & y is Maybe if either x or y is Maybe, but neither x or y is False.
|
||||
* x & y is True if both x and y are True.
|
||||
* x | y is False if both x and y are False.
|
||||
* x | y is Maybe if either x or y is Maybe, but neither x or y is True.
|
||||
* x | y is True if either x or y is True.
|
||||
*/
|
||||
export const enum Ternary {
|
||||
False = 0,
|
||||
Maybe = 1,
|
||||
True = -1
|
||||
True = -1
|
||||
}
|
||||
|
||||
export function createFileMap<T>(getCanonicalFileName: (fileName: string) => string): FileMap<T> {
|
||||
@@ -59,6 +61,11 @@ namespace ts {
|
||||
|
||||
export interface StringSet extends Map<any> { }
|
||||
|
||||
/**
|
||||
* Iterates through 'array' by index and performs the callback on each element of array until the callback
|
||||
* returns a truthy value, then returns that value.
|
||||
* If no such value is found, the callback is applied to each element of array and undefined is returned.
|
||||
*/
|
||||
export function forEach<T, U>(array: T[], callback: (element: T, index: number) => U): U {
|
||||
if (array) {
|
||||
for (let i = 0, len = array.length; i < len; i++) {
|
||||
@@ -702,9 +709,9 @@ namespace ts {
|
||||
/**
|
||||
* List of supported extensions in order of file resolution precedence.
|
||||
*/
|
||||
export const supportedExtensions = [".ts", ".d.ts"];
|
||||
export const supportedExtensions = [".tsx", ".ts", ".d.ts"];
|
||||
|
||||
const extensionsToRemove = [".d.ts", ".ts", ".js"];
|
||||
const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"];
|
||||
export function removeFileExtension(path: string): string {
|
||||
for (let ext of extensionsToRemove) {
|
||||
if (fileExtensionIs(path, ext)) {
|
||||
@@ -757,8 +764,8 @@ namespace ts {
|
||||
}
|
||||
Node.prototype = {
|
||||
kind: kind,
|
||||
pos: 0,
|
||||
end: 0,
|
||||
pos: -1,
|
||||
end: -1,
|
||||
flags: 0,
|
||||
parent: undefined,
|
||||
};
|
||||
@@ -798,4 +805,4 @@ namespace ts {
|
||||
Debug.assert(false, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,6 +340,8 @@ namespace ts {
|
||||
return emitTupleType(<TupleTypeNode>type);
|
||||
case SyntaxKind.UnionType:
|
||||
return emitUnionType(<UnionTypeNode>type);
|
||||
case SyntaxKind.IntersectionType:
|
||||
return emitIntersectionType(<IntersectionTypeNode>type);
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
return emitParenType(<ParenthesizedTypeNode>type);
|
||||
case SyntaxKind.FunctionType:
|
||||
@@ -416,6 +418,10 @@ namespace ts {
|
||||
emitSeparatedList(type.types, " | ", emitType);
|
||||
}
|
||||
|
||||
function emitIntersectionType(type: IntersectionTypeNode) {
|
||||
emitSeparatedList(type.types, " & ", emitType);
|
||||
}
|
||||
|
||||
function emitParenType(type: ParenthesizedTypeNode) {
|
||||
write("(");
|
||||
emitType(type.type);
|
||||
@@ -588,6 +594,9 @@ namespace ts {
|
||||
if (node.flags & NodeFlags.Static) {
|
||||
write("static ");
|
||||
}
|
||||
if (node.flags & NodeFlags.Abstract) {
|
||||
write("abstract ");
|
||||
}
|
||||
}
|
||||
|
||||
function writeImportEqualsDeclaration(node: ImportEqualsDeclaration) {
|
||||
@@ -912,6 +921,10 @@ namespace ts {
|
||||
|
||||
emitJsDocComments(node);
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
if (node.flags & NodeFlags.Abstract) {
|
||||
write("abstract ");
|
||||
}
|
||||
|
||||
write("class ");
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
let prevEnclosingDeclaration = enclosingDeclaration;
|
||||
|
||||
@@ -20,22 +20,21 @@ namespace ts {
|
||||
An_index_signature_must_have_a_type_annotation: { code: 1021, category: DiagnosticCategory.Error, key: "An index signature must have a type annotation." },
|
||||
An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." },
|
||||
An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." },
|
||||
A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." },
|
||||
An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." },
|
||||
A_class_can_only_extend_a_single_class: { code: 1026, category: DiagnosticCategory.Error, key: "A class can only extend a single class." },
|
||||
A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." },
|
||||
Accessibility_modifier_already_seen: { code: 1028, category: DiagnosticCategory.Error, key: "Accessibility modifier already seen." },
|
||||
_0_modifier_must_precede_1_modifier: { code: 1029, category: DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." },
|
||||
_0_modifier_already_seen: { code: 1030, category: DiagnosticCategory.Error, key: "'{0}' modifier already seen." },
|
||||
_0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." },
|
||||
An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." },
|
||||
super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." },
|
||||
Only_ambient_modules_can_use_quoted_names: { code: 1035, category: DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." },
|
||||
Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." },
|
||||
A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." },
|
||||
Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." },
|
||||
_0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used in an ambient context." },
|
||||
_0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a class declaration." },
|
||||
_0_modifier_cannot_be_used_here: { code: 1042, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used here." },
|
||||
_0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a data property." },
|
||||
_0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." },
|
||||
A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." },
|
||||
A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an interface declaration." },
|
||||
A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." },
|
||||
A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional." },
|
||||
A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." },
|
||||
@@ -44,12 +43,18 @@ namespace ts {
|
||||
A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." },
|
||||
A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." },
|
||||
A_get_accessor_cannot_have_parameters: { code: 1054, category: DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." },
|
||||
Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: DiagnosticCategory.Error, key: "Type '{0}' is not a valid async function return type." },
|
||||
Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." },
|
||||
An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." },
|
||||
Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." },
|
||||
Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." },
|
||||
Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." },
|
||||
Enum_member_must_have_initializer: { code: 1061, category: DiagnosticCategory.Error, key: "Enum member must have initializer." },
|
||||
_0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." },
|
||||
An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." },
|
||||
Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." },
|
||||
Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." },
|
||||
A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." },
|
||||
A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." },
|
||||
Invalid_reference_directive_syntax: { code: 1084, category: DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." },
|
||||
Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." },
|
||||
An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." },
|
||||
@@ -94,7 +99,6 @@ namespace ts {
|
||||
case_or_default_expected: { code: 1130, category: DiagnosticCategory.Error, key: "'case' or 'default' expected." },
|
||||
Property_or_signature_expected: { code: 1131, category: DiagnosticCategory.Error, key: "Property or signature expected." },
|
||||
Enum_member_expected: { code: 1132, category: DiagnosticCategory.Error, key: "Enum member expected." },
|
||||
Type_reference_expected: { code: 1133, category: DiagnosticCategory.Error, key: "Type reference expected." },
|
||||
Variable_declaration_expected: { code: 1134, category: DiagnosticCategory.Error, key: "Variable declaration expected." },
|
||||
Argument_expression_expected: { code: 1135, category: DiagnosticCategory.Error, key: "Argument expression expected." },
|
||||
Property_assignment_expected: { code: 1136, category: DiagnosticCategory.Error, key: "Property assignment expected." },
|
||||
@@ -111,9 +115,6 @@ namespace ts {
|
||||
Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." },
|
||||
File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" },
|
||||
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead." },
|
||||
var_let_or_const_expected: { code: 1152, category: DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." },
|
||||
let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." },
|
||||
const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." },
|
||||
const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized" },
|
||||
const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." },
|
||||
let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." },
|
||||
@@ -124,7 +125,6 @@ namespace ts {
|
||||
Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." },
|
||||
A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." },
|
||||
A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." },
|
||||
Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." },
|
||||
A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." },
|
||||
A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." },
|
||||
A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." },
|
||||
@@ -140,7 +140,6 @@ namespace ts {
|
||||
Property_destructuring_pattern_expected: { code: 1180, category: DiagnosticCategory.Error, key: "Property destructuring pattern expected." },
|
||||
Array_element_destructuring_pattern_expected: { code: 1181, category: DiagnosticCategory.Error, key: "Array element destructuring pattern expected." },
|
||||
A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." },
|
||||
Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." },
|
||||
An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." },
|
||||
Modifiers_cannot_appear_here: { code: 1184, category: DiagnosticCategory.Error, key: "Modifiers cannot appear here." },
|
||||
Merge_conflict_marker_encountered: { code: 1185, category: DiagnosticCategory.Error, key: "Merge conflict marker encountered." },
|
||||
@@ -191,12 +190,20 @@ namespace ts {
|
||||
An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: DiagnosticCategory.Error, key: "An export declaration can only be used in a module." },
|
||||
An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." },
|
||||
A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." },
|
||||
Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." },
|
||||
with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." },
|
||||
await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." },
|
||||
Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." },
|
||||
The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." },
|
||||
The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." },
|
||||
Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." },
|
||||
Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." },
|
||||
Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." },
|
||||
Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." },
|
||||
abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." },
|
||||
_0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." },
|
||||
Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." },
|
||||
Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." },
|
||||
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." },
|
||||
@@ -205,7 +212,6 @@ namespace ts {
|
||||
Module_0_has_no_exported_member_1: { code: 2305, category: DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." },
|
||||
File_0_is_not_a_module: { code: 2306, category: DiagnosticCategory.Error, key: "File '{0}' is not a module." },
|
||||
Cannot_find_module_0: { code: 2307, category: DiagnosticCategory.Error, key: "Cannot find module '{0}'." },
|
||||
A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." },
|
||||
An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." },
|
||||
Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." },
|
||||
A_class_may_only_extend_another_class: { code: 2311, category: DiagnosticCategory.Error, key: "A class may only extend another class." },
|
||||
@@ -233,10 +239,10 @@ namespace ts {
|
||||
this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." },
|
||||
super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." },
|
||||
super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." },
|
||||
Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" },
|
||||
super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" },
|
||||
Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." },
|
||||
super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." },
|
||||
Property_0_does_not_exist_on_type_1: { code: 2339, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." },
|
||||
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" },
|
||||
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." },
|
||||
Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." },
|
||||
An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
|
||||
Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
|
||||
@@ -395,6 +401,29 @@ namespace ts {
|
||||
No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." },
|
||||
Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." },
|
||||
Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." },
|
||||
Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." },
|
||||
Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." },
|
||||
Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." },
|
||||
Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." },
|
||||
Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." },
|
||||
All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." },
|
||||
Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type" },
|
||||
Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." },
|
||||
Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." },
|
||||
Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." },
|
||||
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." },
|
||||
yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." },
|
||||
await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." },
|
||||
JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." },
|
||||
The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." },
|
||||
JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." },
|
||||
Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" },
|
||||
JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." },
|
||||
JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." },
|
||||
Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." },
|
||||
JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" },
|
||||
The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" },
|
||||
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
|
||||
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}'." },
|
||||
@@ -531,15 +560,18 @@ namespace ts {
|
||||
File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." },
|
||||
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." },
|
||||
Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." },
|
||||
Preserve_new_lines_when_emitting_code: { code: 6057, category: DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
|
||||
Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." },
|
||||
File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." },
|
||||
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
|
||||
NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" },
|
||||
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
|
||||
Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" },
|
||||
Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." },
|
||||
Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." },
|
||||
Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." },
|
||||
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." },
|
||||
Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
|
||||
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
|
||||
@@ -556,6 +588,7 @@ namespace ts {
|
||||
_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
|
||||
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
|
||||
Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." },
|
||||
JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" },
|
||||
You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." },
|
||||
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." },
|
||||
import_can_only_be_used_in_a_ts_file: { code: 8002, category: DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." },
|
||||
@@ -573,5 +606,12 @@ namespace ts {
|
||||
enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." },
|
||||
type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." },
|
||||
decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." },
|
||||
Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." },
|
||||
class_expressions_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'class' expressions are not currently supported." },
|
||||
JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." },
|
||||
JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." },
|
||||
Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." },
|
||||
JSX_attribute_expected: { code: 17003, category: DiagnosticCategory.Error, key: "JSX attribute expected." },
|
||||
Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." },
|
||||
};
|
||||
}
|
||||
@@ -67,22 +67,6 @@
|
||||
"category": "Error",
|
||||
"code": 1023
|
||||
},
|
||||
"A class or interface declaration can only have one 'extends' clause.": {
|
||||
"category": "Error",
|
||||
"code": 1024
|
||||
},
|
||||
"An 'extends' clause must precede an 'implements' clause.": {
|
||||
"category": "Error",
|
||||
"code": 1025
|
||||
},
|
||||
"A class can only extend a single class.": {
|
||||
"category": "Error",
|
||||
"code": 1026
|
||||
},
|
||||
"A class declaration can only have one 'implements' clause.": {
|
||||
"category": "Error",
|
||||
"code": 1027
|
||||
},
|
||||
"Accessibility modifier already seen.": {
|
||||
"category": "Error",
|
||||
"code": 1028
|
||||
@@ -99,10 +83,6 @@
|
||||
"category": "Error",
|
||||
"code": 1031
|
||||
},
|
||||
"An interface declaration cannot have an 'implements' clause.": {
|
||||
"category": "Error",
|
||||
"code": 1032
|
||||
},
|
||||
"'super' must be followed by an argument list or member access.": {
|
||||
"category": "Error",
|
||||
"code": 1034
|
||||
@@ -123,11 +103,27 @@
|
||||
"category": "Error",
|
||||
"code": 1039
|
||||
},
|
||||
"'{0}' modifier cannot be used in an ambient context.": {
|
||||
"category": "Error",
|
||||
"code": 1040
|
||||
},
|
||||
"'{0}' modifier cannot be used with a class declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1041
|
||||
},
|
||||
"'{0}' modifier cannot be used here.": {
|
||||
"category": "Error",
|
||||
"code": 1042
|
||||
},
|
||||
"'{0}' modifier cannot appear on a data property.": {
|
||||
"category": "Error",
|
||||
"code": 1043
|
||||
},
|
||||
"'{0}' modifier cannot appear on a module element.": {
|
||||
"category": "Error",
|
||||
"code": 1044
|
||||
},
|
||||
"A 'declare' modifier cannot be used with an interface declaration.": {
|
||||
"A '{0}' modifier cannot be used with an interface declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1045
|
||||
},
|
||||
@@ -163,14 +159,38 @@
|
||||
"category": "Error",
|
||||
"code": 1054
|
||||
},
|
||||
"Type '{0}' is not a valid async function return type.": {
|
||||
"category": "Error",
|
||||
"code": 1055
|
||||
},
|
||||
"Accessors are only available when targeting ECMAScript 5 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1056
|
||||
},
|
||||
"An async function or method must have a valid awaitable return type.": {
|
||||
"category": "Error",
|
||||
"code": 1057
|
||||
},
|
||||
"Operand for 'await' does not have a valid callable 'then' member.": {
|
||||
"category": "Error",
|
||||
"code": 1058
|
||||
},
|
||||
"Return expression in async function does not have a valid callable 'then' member.": {
|
||||
"category": "Error",
|
||||
"code": 1059
|
||||
},
|
||||
"Expression body for async arrow function does not have a valid callable 'then' member.": {
|
||||
"category": "Error",
|
||||
"code": 1060
|
||||
},
|
||||
"Enum member must have initializer.": {
|
||||
"category": "Error",
|
||||
"code": 1061
|
||||
},
|
||||
"{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method.": {
|
||||
"category": "Error",
|
||||
"code": 1062
|
||||
},
|
||||
"An export assignment cannot be used in a namespace.": {
|
||||
"category": "Error",
|
||||
"code": 1063
|
||||
@@ -183,7 +203,7 @@
|
||||
"category": "Error",
|
||||
"code": 1068
|
||||
},
|
||||
"A 'declare' modifier cannot be used with an import declaration.": {
|
||||
"A '{0}' modifier cannot be used with an import declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1079
|
||||
},
|
||||
@@ -363,10 +383,6 @@
|
||||
"category": "Error",
|
||||
"code": 1132
|
||||
},
|
||||
"Type reference expected.": {
|
||||
"category": "Error",
|
||||
"code": 1133
|
||||
},
|
||||
"Variable declaration expected.": {
|
||||
"category": "Error",
|
||||
"code": 1134
|
||||
@@ -431,18 +447,6 @@
|
||||
"category": "Error",
|
||||
"code": 1150
|
||||
},
|
||||
"'var', 'let' or 'const' expected.": {
|
||||
"category": "Error",
|
||||
"code": 1152
|
||||
},
|
||||
"'let' declarations are only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1153
|
||||
},
|
||||
"'const' declarations are only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1154
|
||||
},
|
||||
"'const' declarations must be initialized": {
|
||||
"category": "Error",
|
||||
"code": 1155
|
||||
@@ -483,10 +487,6 @@
|
||||
"category": "Error",
|
||||
"code": 1166
|
||||
},
|
||||
"Computed property names are only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1167
|
||||
},
|
||||
"A computed property name in a method overload must directly refer to a built-in symbol.": {
|
||||
"category": "Error",
|
||||
"code": 1168
|
||||
@@ -547,10 +547,6 @@
|
||||
"category": "Error",
|
||||
"code": 1182
|
||||
},
|
||||
"Destructuring declarations are not allowed in ambient contexts.": {
|
||||
"category": "Error",
|
||||
"code": 1183
|
||||
},
|
||||
"An implementation cannot be declared in ambient contexts.": {
|
||||
"category": "Error",
|
||||
"code": 1184
|
||||
@@ -686,7 +682,7 @@
|
||||
"Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.": {
|
||||
"category": "Error",
|
||||
"code": 1219
|
||||
},
|
||||
},
|
||||
"Generators are only available when targeting ECMAScript 6 or higher.": {
|
||||
"category": "Error",
|
||||
"code": 1220
|
||||
@@ -751,8 +747,24 @@
|
||||
"category": "Error",
|
||||
"code": 1235
|
||||
},
|
||||
"Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning.": {
|
||||
"category": "Error",
|
||||
"code": 1236
|
||||
},
|
||||
|
||||
|
||||
"'with' statements are not allowed in an async function block.": {
|
||||
"category": "Error",
|
||||
"code": 1300
|
||||
},
|
||||
"'await' expression is only allowed within an async function.": {
|
||||
"category": "Error",
|
||||
"code": 1308
|
||||
},
|
||||
"Async functions are only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1311
|
||||
},
|
||||
"The return type of a property decorator function must be either 'void' or 'any'.": {
|
||||
"category": "Error",
|
||||
"code": 1236
|
||||
@@ -777,7 +789,22 @@
|
||||
"category": "Error",
|
||||
"code": 1241
|
||||
},
|
||||
|
||||
"'abstract' modifier can only appear on a class or method declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1242
|
||||
},
|
||||
"'{0}' modifier cannot be used with '{1}' modifier.": {
|
||||
"category": "Error",
|
||||
"code": 1243
|
||||
},
|
||||
"Abstract methods can only appear within an abstract class.": {
|
||||
"category": "Error",
|
||||
"code": 1244
|
||||
},
|
||||
"Method '{0}' cannot have an implementation because it is marked abstract.": {
|
||||
"category": "Error",
|
||||
"code": 1245
|
||||
},
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2300
|
||||
@@ -810,10 +837,6 @@
|
||||
"category": "Error",
|
||||
"code": 2307
|
||||
},
|
||||
"A module cannot have more than one export assignment.": {
|
||||
"category": "Error",
|
||||
"code": 2308
|
||||
},
|
||||
"An export assignment cannot be used in a module with other exported elements.": {
|
||||
"category": "Error",
|
||||
"code": 2309
|
||||
@@ -922,11 +945,11 @@
|
||||
"category": "Error",
|
||||
"code": 2336
|
||||
},
|
||||
"Super calls are not permitted outside constructors or in nested functions inside constructors": {
|
||||
"Super calls are not permitted outside constructors or in nested functions inside constructors.": {
|
||||
"category": "Error",
|
||||
"code": 2337
|
||||
},
|
||||
"'super' property access is permitted only in a constructor, member function, or member accessor of a derived class": {
|
||||
"'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": {
|
||||
"category": "Error",
|
||||
"code": 2338
|
||||
},
|
||||
@@ -934,7 +957,7 @@
|
||||
"category": "Error",
|
||||
"code": 2339
|
||||
},
|
||||
"Only public and protected methods of the base class are accessible via the 'super' keyword": {
|
||||
"Only public and protected methods of the base class are accessible via the 'super' keyword.": {
|
||||
"category": "Error",
|
||||
"code": 2340
|
||||
},
|
||||
@@ -1570,7 +1593,98 @@
|
||||
"category": "Error",
|
||||
"code": 2510
|
||||
},
|
||||
|
||||
"Cannot create an instance of the abstract class '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2511
|
||||
},
|
||||
"Overload signatures must all be abstract or not abstract.": {
|
||||
"category": "Error",
|
||||
"code": 2512
|
||||
},
|
||||
"Abstract method '{0}' in class '{1}' cannot be accessed via super expression.": {
|
||||
"category": "Error",
|
||||
"code": 2513
|
||||
},
|
||||
"Classes containing abstract methods must be marked abstract.": {
|
||||
"category": "Error",
|
||||
"code": 2514
|
||||
},
|
||||
"Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'.": {
|
||||
"category": "Error",
|
||||
"code": 2515
|
||||
},
|
||||
"All declarations of an abstract method must be consecutive.": {
|
||||
"category": "Error",
|
||||
"code": 2516
|
||||
},
|
||||
"Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type": {
|
||||
"category": "Error",
|
||||
"code":2517
|
||||
},
|
||||
"Only an ambient class can be merged with an interface.": {
|
||||
"category": "Error",
|
||||
"code": 2518
|
||||
},
|
||||
"Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": {
|
||||
"category": "Error",
|
||||
"code": 2520
|
||||
},
|
||||
"Expression resolves to variable declaration '{0}' that compiler uses to support async functions.": {
|
||||
"category": "Error",
|
||||
"code": 2521
|
||||
},
|
||||
"The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression.": {
|
||||
"category": "Error",
|
||||
"code": 2522
|
||||
},
|
||||
"'yield' expressions cannot be used in a parameter initializer.": {
|
||||
"category": "Error",
|
||||
"code": 2523
|
||||
},
|
||||
"'await' expressions cannot be used in a parameter initializer.": {
|
||||
"category": "Error",
|
||||
"code": 2524
|
||||
},
|
||||
"JSX element attributes type '{0}' must be an object type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
},
|
||||
"The return type of a JSX element constructor must return an object type.": {
|
||||
"category": "Error",
|
||||
"code": 2601
|
||||
},
|
||||
"JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist.": {
|
||||
"category": "Error",
|
||||
"code": 2602
|
||||
},
|
||||
"Property '{0}' in type '{1}' is not assignable to type '{2}'": {
|
||||
"category": "Error",
|
||||
"code": 2603
|
||||
},
|
||||
"JSX element type '{0}' does not have any construct or call signatures.": {
|
||||
"category": "Error",
|
||||
"code": 2604
|
||||
},
|
||||
"JSX element type '{0}' is not a constructor function for JSX elements.": {
|
||||
"category": "Error",
|
||||
"code": 2605
|
||||
},
|
||||
"Property '{0}' of JSX spread attribute is not assignable to target property.": {
|
||||
"category": "Error",
|
||||
"code": 2606
|
||||
},
|
||||
"JSX element class does not support attributes because it does not have a '{0}' property": {
|
||||
"category": "Error",
|
||||
"code": 2607
|
||||
},
|
||||
"The global type 'JSX.{0}' may not have more than one property": {
|
||||
"category": "Error",
|
||||
"code": 2608
|
||||
},
|
||||
"Cannot emit namespaced JSX elements in React": {
|
||||
"category": "Error",
|
||||
"code": 2650
|
||||
},
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4000
|
||||
@@ -1939,7 +2053,7 @@
|
||||
"category": "Error",
|
||||
"code": 5050
|
||||
},
|
||||
"Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": {
|
||||
"Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": {
|
||||
"category": "Error",
|
||||
"code": 5051
|
||||
},
|
||||
@@ -2116,10 +2230,6 @@
|
||||
"category": "Message",
|
||||
"code": 6056
|
||||
},
|
||||
"Preserve new-lines when emitting code.": {
|
||||
"category": "Message",
|
||||
"code": 6057
|
||||
},
|
||||
"Specifies the root directory of input files. Use to control the output directory structure with --outDir.": {
|
||||
"category": "Message",
|
||||
"code": 6058
|
||||
@@ -2132,14 +2242,22 @@
|
||||
"category": "Message",
|
||||
"code": 6060
|
||||
},
|
||||
"NEWLINE": {
|
||||
"category": "Message",
|
||||
"NEWLINE": {
|
||||
"category": "Message",
|
||||
"code": 6061
|
||||
},
|
||||
"Argument for '--newLine' option must be 'CRLF' or 'LF'.": {
|
||||
"category": "Error",
|
||||
"category": "Error",
|
||||
"code": 6062
|
||||
},
|
||||
"Specify JSX code generation: 'preserve' or 'react'": {
|
||||
"category": "Message",
|
||||
"code": 6080
|
||||
},
|
||||
"Argument for '--jsx' must be 'preserve' or 'react'.": {
|
||||
"category": "Message",
|
||||
"code": 6081
|
||||
},
|
||||
"Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified.": {
|
||||
"category": "Error",
|
||||
"code": 6064
|
||||
@@ -2152,6 +2270,14 @@
|
||||
"category": "Message",
|
||||
"code": 6066
|
||||
},
|
||||
"Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower.": {
|
||||
"category": "Message",
|
||||
"code": 6067
|
||||
},
|
||||
"Enables experimental support for ES7 async functions.": {
|
||||
"category": "Message",
|
||||
"code": 6068
|
||||
},
|
||||
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
@@ -2217,6 +2343,12 @@
|
||||
"category": "Error",
|
||||
"code": 7025
|
||||
},
|
||||
"JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists": {
|
||||
"category": "Error",
|
||||
"code": 7026
|
||||
},
|
||||
|
||||
|
||||
"You cannot rename this element.": {
|
||||
"category": "Error",
|
||||
"code": 8000
|
||||
@@ -2284,5 +2416,34 @@
|
||||
"'decorators' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8017
|
||||
},
|
||||
|
||||
"Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.": {
|
||||
"category": "Error",
|
||||
"code": 9002
|
||||
},
|
||||
"'class' expressions are not currently supported.": {
|
||||
"category": "Error",
|
||||
"code": 9003
|
||||
},
|
||||
"JSX attributes must only be assigned a non-empty 'expression'.": {
|
||||
"category": "Error",
|
||||
"code": 17000
|
||||
},
|
||||
"JSX elements cannot have multiple attributes with the same name.": {
|
||||
"category": "Error",
|
||||
"code": 17001
|
||||
},
|
||||
"Expected corresponding JSX closing tag for '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 17002
|
||||
},
|
||||
"JSX attribute expected.": {
|
||||
"category": "Error",
|
||||
"code": 17003
|
||||
},
|
||||
"Cannot use JSX unless the '--jsx' flag is provided.": {
|
||||
"category": "Error",
|
||||
"code": 17004
|
||||
}
|
||||
}
|
||||
|
||||
+534
-21
@@ -47,16 +47,33 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};`;
|
||||
|
||||
const awaiterHelper = `
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
generator = generator.call(thisArg, _arguments);
|
||||
function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }
|
||||
function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } }
|
||||
function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } }
|
||||
function step(verb, value) {
|
||||
var result = generator[verb](value);
|
||||
result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);
|
||||
}
|
||||
step("next", void 0);
|
||||
});
|
||||
};`;
|
||||
|
||||
let compilerOptions = host.getCompilerOptions();
|
||||
let languageVersion = compilerOptions.target || ScriptTarget.ES3;
|
||||
let sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined;
|
||||
let diagnostics: Diagnostic[] = [];
|
||||
let newLine = host.getNewLine();
|
||||
let jsxDesugaring = host.getCompilerOptions().jsx !== JsxEmit.Preserve;
|
||||
let shouldEmitJsx = (s: SourceFile) => (s.languageVariant === LanguageVariant.JSX && !jsxDesugaring);
|
||||
|
||||
if (targetSourceFile === undefined) {
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (shouldEmitToOwnFile(sourceFile, compilerOptions)) {
|
||||
let jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, ".js");
|
||||
let jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js");
|
||||
emitFile(jsFilePath, sourceFile);
|
||||
}
|
||||
});
|
||||
@@ -68,7 +85,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
else {
|
||||
// targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service)
|
||||
if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) {
|
||||
let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js");
|
||||
let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js");
|
||||
emitFile(jsFilePath, targetSourceFile);
|
||||
}
|
||||
else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) {
|
||||
@@ -112,7 +129,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
let writeLine = writer.writeLine;
|
||||
let increaseIndent = writer.increaseIndent;
|
||||
let decreaseIndent = writer.decreaseIndent;
|
||||
|
||||
|
||||
let currentSourceFile: SourceFile;
|
||||
// name of an exporter function if file is a System external module
|
||||
// System.register([...], function (<exporter>) {...})
|
||||
@@ -129,6 +146,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
let extendsEmitted = false;
|
||||
let decorateEmitted = false;
|
||||
let paramEmitted = false;
|
||||
let awaiterEmitted = false;
|
||||
let tempFlags = 0;
|
||||
let tempVariables: Identifier[];
|
||||
let tempParameters: Identifier[];
|
||||
@@ -1111,6 +1129,224 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
emit(span.literal);
|
||||
}
|
||||
|
||||
function jsxEmitReact(node: JsxElement|JsxSelfClosingElement) {
|
||||
/// Emit a tag name, which is either '"div"' for lower-cased names, or
|
||||
/// 'Div' for upper-cased or dotted names
|
||||
function emitTagName(name: Identifier|QualifiedName) {
|
||||
if (name.kind === SyntaxKind.Identifier && isIntrinsicJsxName((<Identifier>name).text)) {
|
||||
write('"');
|
||||
emit(name);
|
||||
write('"');
|
||||
}
|
||||
else {
|
||||
emit(name);
|
||||
}
|
||||
}
|
||||
|
||||
/// Emit an attribute name, which is quoted if it needs to be quoted. Because
|
||||
/// these emit into an object literal property name, we don't need to be worried
|
||||
/// about keywords, just non-identifier characters
|
||||
function emitAttributeName(name: Identifier) {
|
||||
if (/[A-Za-z_]+[\w*]/.test(name.text)) {
|
||||
write('"');
|
||||
emit(name);
|
||||
write('"');
|
||||
}
|
||||
else {
|
||||
emit(name);
|
||||
}
|
||||
}
|
||||
|
||||
/// Emit an name/value pair for an attribute (e.g. "x: 3")
|
||||
function emitJsxAttribute(node: JsxAttribute) {
|
||||
emitAttributeName(node.name);
|
||||
write(": ");
|
||||
if (node.initializer) {
|
||||
emit(node.initializer);
|
||||
}
|
||||
else {
|
||||
write("true");
|
||||
}
|
||||
}
|
||||
|
||||
function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) {
|
||||
// Call React.createElement(tag, ...
|
||||
emitLeadingComments(openingNode);
|
||||
write("React.createElement(");
|
||||
emitTagName(openingNode.tagName);
|
||||
write(", ");
|
||||
|
||||
// Attribute list
|
||||
if (openingNode.attributes.length === 0) {
|
||||
// When there are no attributes, React wants "null"
|
||||
write("null");
|
||||
}
|
||||
else {
|
||||
// Either emit one big object literal (no spread attribs), or
|
||||
// a call to React.__spread
|
||||
let attrs = openingNode.attributes;
|
||||
if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) {
|
||||
write("React.__spread(");
|
||||
|
||||
let haveOpenedObjectLiteral = false;
|
||||
for (let i = 0; i < attrs.length; i++) {
|
||||
if (attrs[i].kind === SyntaxKind.JsxSpreadAttribute) {
|
||||
// If this is the first argument, we need to emit a {} as the first argument
|
||||
if (i === 0) {
|
||||
write("{}, ");
|
||||
}
|
||||
|
||||
if (haveOpenedObjectLiteral) {
|
||||
write("}");
|
||||
haveOpenedObjectLiteral = false;
|
||||
}
|
||||
if (i > 0) {
|
||||
write(", ");
|
||||
}
|
||||
emit((<JsxSpreadAttribute>attrs[i]).expression);
|
||||
}
|
||||
else {
|
||||
Debug.assert(attrs[i].kind === SyntaxKind.JsxAttribute);
|
||||
if (haveOpenedObjectLiteral) {
|
||||
write(", ");
|
||||
}
|
||||
else {
|
||||
haveOpenedObjectLiteral = true;
|
||||
if (i > 0) {
|
||||
write(", ");
|
||||
}
|
||||
write("{");
|
||||
}
|
||||
emitJsxAttribute(<JsxAttribute>attrs[i]);
|
||||
}
|
||||
}
|
||||
if (haveOpenedObjectLiteral) write("}");
|
||||
|
||||
write(")"); // closing paren to React.__spread(
|
||||
}
|
||||
else {
|
||||
// One object literal with all the attributes in them
|
||||
write("{");
|
||||
for (var i = 0; i < attrs.length; i++) {
|
||||
if (i > 0) {
|
||||
write(", ");
|
||||
}
|
||||
emitJsxAttribute(<JsxAttribute>attrs[i]);
|
||||
}
|
||||
write("}");
|
||||
}
|
||||
}
|
||||
|
||||
// Children
|
||||
if (children) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
// Don't emit empty expressions
|
||||
if (children[i].kind === SyntaxKind.JsxExpression && !((<JsxExpression>children[i]).expression)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't emit empty strings
|
||||
if (children[i].kind === SyntaxKind.JsxText) {
|
||||
let text = getTextToEmit(<JsxText>children[i]);
|
||||
if(text !== undefined) {
|
||||
write(', "');
|
||||
write(text);
|
||||
write('"');
|
||||
}
|
||||
}
|
||||
else {
|
||||
write(", ");
|
||||
emit(children[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Closing paren
|
||||
write(")"); // closes "React.createElement("
|
||||
emitTrailingComments(openingNode);
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.JsxElement) {
|
||||
emitJsxElement((<JsxElement>node).openingElement, (<JsxElement>node).children);
|
||||
}
|
||||
else {
|
||||
Debug.assert(node.kind === SyntaxKind.JsxSelfClosingElement);
|
||||
emitJsxElement(<JsxSelfClosingElement>node);
|
||||
}
|
||||
}
|
||||
|
||||
function jsxEmitPreserve(node: JsxElement|JsxSelfClosingElement) {
|
||||
function emitJsxAttribute(node: JsxAttribute) {
|
||||
emit(node.name);
|
||||
write("=");
|
||||
emit(node.initializer);
|
||||
}
|
||||
|
||||
function emitJsxSpreadAttribute(node: JsxSpreadAttribute) {
|
||||
write("{...");
|
||||
emit(node.expression);
|
||||
write("}");
|
||||
}
|
||||
|
||||
function emitAttributes(attribs: NodeArray<JsxAttribute|JsxSpreadAttribute>) {
|
||||
for (let i = 0, n = attribs.length; i < n; i++) {
|
||||
if (i > 0) {
|
||||
write(" ");
|
||||
}
|
||||
|
||||
if (attribs[i].kind === SyntaxKind.JsxSpreadAttribute) {
|
||||
emitJsxSpreadAttribute(<JsxSpreadAttribute>attribs[i]);
|
||||
}
|
||||
else {
|
||||
Debug.assert(attribs[i].kind === SyntaxKind.JsxAttribute);
|
||||
emitJsxAttribute(<JsxAttribute>attribs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function emitJsxOpeningOrSelfClosingElement(node: JsxOpeningElement|JsxSelfClosingElement) {
|
||||
write("<");
|
||||
emit(node.tagName);
|
||||
if (node.attributes.length > 0 || (node.kind === SyntaxKind.JsxSelfClosingElement)) {
|
||||
write(" ");
|
||||
}
|
||||
|
||||
emitAttributes(node.attributes);
|
||||
|
||||
if (node.kind === SyntaxKind.JsxSelfClosingElement) {
|
||||
write("/>");
|
||||
}
|
||||
else {
|
||||
write(">");
|
||||
}
|
||||
}
|
||||
|
||||
function emitJsxClosingElement(node: JsxClosingElement) {
|
||||
write("</");
|
||||
emit(node.tagName);
|
||||
write(">");
|
||||
}
|
||||
|
||||
function emitJsxElement(node: JsxElement) {
|
||||
emitJsxOpeningOrSelfClosingElement(node.openingElement);
|
||||
|
||||
for (var i = 0, n = node.children.length; i < n; i++) {
|
||||
emit(node.children[i]);
|
||||
}
|
||||
|
||||
emitJsxClosingElement(node.closingElement);
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.JsxElement) {
|
||||
emitJsxElement(<JsxElement>node);
|
||||
}
|
||||
else {
|
||||
Debug.assert(node.kind === SyntaxKind.JsxSelfClosingElement);
|
||||
emitJsxOpeningOrSelfClosingElement(<JsxSelfClosingElement>node);
|
||||
}
|
||||
}
|
||||
|
||||
// This function specifically handles numeric/string literals for enum and accessor 'identifiers'.
|
||||
// In a sense, it does not actually emit identifiers as much as it declares a name for a specific property.
|
||||
// For example, this is utilized when feeding in a result to Object.defineProperty.
|
||||
@@ -1187,6 +1423,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
case SyntaxKind.JsxOpeningElement:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
@@ -1226,6 +1464,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
|
||||
function emitExpressionIdentifier(node: Identifier) {
|
||||
if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.LexicalArguments) {
|
||||
write("_arguments");
|
||||
return;
|
||||
}
|
||||
|
||||
let container = resolver.getReferencedExportContainer(node);
|
||||
if (container) {
|
||||
if (container.kind === SyntaxKind.SourceFile) {
|
||||
@@ -1365,6 +1608,30 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
emit(node.expression);
|
||||
}
|
||||
}
|
||||
|
||||
function emitAwaitExpression(node: AwaitExpression) {
|
||||
let needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node);
|
||||
if (needsParenthesis) {
|
||||
write("(");
|
||||
}
|
||||
write(tokenToString(SyntaxKind.YieldKeyword));
|
||||
write(" ");
|
||||
emit(node.expression);
|
||||
if (needsParenthesis) {
|
||||
write(")");
|
||||
}
|
||||
}
|
||||
|
||||
function needsParenthesisForAwaitExpressionAsYield(node: AwaitExpression) {
|
||||
if (node.parent.kind === SyntaxKind.BinaryExpression && !isAssignmentOperator((<BinaryExpression>node.parent).operatorToken.kind)) {
|
||||
return true;
|
||||
}
|
||||
else if (node.parent.kind === SyntaxKind.ConditionalExpression && (<ConditionalExpression>node.parent).condition === node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function needsParenthesisForPropertyAccessOrInvocation(node: Expression) {
|
||||
switch (node.kind) {
|
||||
@@ -1663,8 +1930,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
function parenthesizeForAccess(expr: Expression): LeftHandSideExpression {
|
||||
// When diagnosing whether the expression needs parentheses, the decision should be based
|
||||
// on the innermost expression in a chain of nested type assertions.
|
||||
while (expr.kind === SyntaxKind.TypeAssertionExpression) {
|
||||
expr = (<TypeAssertion>expr).expression;
|
||||
while (expr.kind === SyntaxKind.TypeAssertionExpression || expr.kind === SyntaxKind.AsExpression) {
|
||||
expr = (<AssertionExpression>expr).expression;
|
||||
}
|
||||
|
||||
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
||||
@@ -1824,8 +2091,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
|
||||
function skipParentheses(node: Expression): Expression {
|
||||
while (node.kind === SyntaxKind.ParenthesizedExpression || node.kind === SyntaxKind.TypeAssertionExpression) {
|
||||
node = (<ParenthesizedExpression | TypeAssertion>node).expression;
|
||||
while (node.kind === SyntaxKind.ParenthesizedExpression || node.kind === SyntaxKind.TypeAssertionExpression || node.kind === SyntaxKind.AsExpression) {
|
||||
node = (<ParenthesizedExpression | AssertionExpression>node).expression;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
@@ -1975,12 +2242,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
// not the user. If we didn't want them, the emitter would not have put them
|
||||
// there.
|
||||
if (!nodeIsSynthesized(node) && node.parent.kind !== SyntaxKind.ArrowFunction) {
|
||||
if (node.expression.kind === SyntaxKind.TypeAssertionExpression) {
|
||||
if (node.expression.kind === SyntaxKind.TypeAssertionExpression || node.expression.kind === SyntaxKind.AsExpression) {
|
||||
let operand = (<TypeAssertion>node.expression).expression;
|
||||
|
||||
// Make sure we consider all nested cast expressions, e.g.:
|
||||
// (<any><number><any>-A).x;
|
||||
while (operand.kind === SyntaxKind.TypeAssertionExpression) {
|
||||
while (operand.kind === SyntaxKind.TypeAssertionExpression || operand.kind === SyntaxKind.AsExpression) {
|
||||
operand = (<TypeAssertion>operand).expression;
|
||||
}
|
||||
|
||||
@@ -3345,8 +3612,149 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
emit(node.parameters[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
emitSignatureParameters(node);
|
||||
}
|
||||
|
||||
function emitAsyncFunctionBodyForES6(node: FunctionLikeDeclaration) {
|
||||
let promiseConstructor = getEntityNameFromTypeNode(node.type);
|
||||
let isArrowFunction = node.kind === SyntaxKind.ArrowFunction;
|
||||
let hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0;
|
||||
let args: string;
|
||||
|
||||
// An async function is emit as an outer function that calls an inner
|
||||
// generator function. To preserve lexical bindings, we pass the current
|
||||
// `this` and `arguments` objects to `__awaiter`. The generator function
|
||||
// passed to `__awaiter` is executed inside of the callback to the
|
||||
// promise constructor.
|
||||
//
|
||||
// The emit for an async arrow without a lexical `arguments` binding might be:
|
||||
//
|
||||
// // input
|
||||
// let a = async (b) => { await b; }
|
||||
//
|
||||
// // output
|
||||
// let a = (b) => __awaiter(this, void 0, void 0, function* () {
|
||||
// yield b;
|
||||
// });
|
||||
//
|
||||
// The emit for an async arrow with a lexical `arguments` binding might be:
|
||||
//
|
||||
// // input
|
||||
// let a = async (b) => { await arguments[0]; }
|
||||
//
|
||||
// // output
|
||||
// let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) {
|
||||
// yield arguments[0];
|
||||
// });
|
||||
//
|
||||
// The emit for an async function expression without a lexical `arguments` binding
|
||||
// might be:
|
||||
//
|
||||
// // input
|
||||
// let a = async function (b) {
|
||||
// await b;
|
||||
// }
|
||||
//
|
||||
// // output
|
||||
// let a = function (b) {
|
||||
// return __awaiter(this, void 0, void 0, function* () {
|
||||
// yield b;
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// The emit for an async function expression with a lexical `arguments` binding
|
||||
// might be:
|
||||
//
|
||||
// // input
|
||||
// let a = async function (b) {
|
||||
// await arguments[0];
|
||||
// }
|
||||
//
|
||||
// // output
|
||||
// let a = function (b) {
|
||||
// return __awaiter(this, arguments, void 0, function* (_arguments) {
|
||||
// yield _arguments[0];
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// The emit for an async function expression with a lexical `arguments` binding
|
||||
// and a return type annotation might be:
|
||||
//
|
||||
// // input
|
||||
// let a = async function (b): MyPromise<any> {
|
||||
// await arguments[0];
|
||||
// }
|
||||
//
|
||||
// // output
|
||||
// let a = function (b) {
|
||||
// return __awaiter(this, arguments, MyPromise, function* (_arguments) {
|
||||
// yield _arguments[0];
|
||||
// });
|
||||
// }
|
||||
//
|
||||
|
||||
// If this is not an async arrow, emit the opening brace of the function body
|
||||
// and the start of the return statement.
|
||||
if (!isArrowFunction) {
|
||||
write(" {");
|
||||
increaseIndent();
|
||||
writeLine();
|
||||
write("return");
|
||||
}
|
||||
|
||||
write(" __awaiter(this");
|
||||
if (hasLexicalArguments) {
|
||||
write(", arguments");
|
||||
}
|
||||
else {
|
||||
write(", void 0");
|
||||
}
|
||||
|
||||
if (promiseConstructor) {
|
||||
write(", ");
|
||||
emitNodeWithoutSourceMap(promiseConstructor);
|
||||
}
|
||||
else {
|
||||
write(", Promise");
|
||||
}
|
||||
|
||||
// Emit the call to __awaiter.
|
||||
if (hasLexicalArguments) {
|
||||
write(", function* (_arguments)");
|
||||
}
|
||||
else {
|
||||
write(", function* ()");
|
||||
}
|
||||
|
||||
// Emit the signature and body for the inner generator function.
|
||||
emitFunctionBody(node);
|
||||
write(")");
|
||||
|
||||
// If this is not an async arrow, emit the closing brace of the outer function body.
|
||||
if (!isArrowFunction) {
|
||||
write(";");
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
write("}");
|
||||
}
|
||||
}
|
||||
|
||||
function emitFunctionBody(node: FunctionLikeDeclaration) {
|
||||
if (!node.body) {
|
||||
// There can be no body when there are parse errors. Just emit an empty block
|
||||
// in that case.
|
||||
write(" { }");
|
||||
}
|
||||
else {
|
||||
if (node.body.kind === SyntaxKind.Block) {
|
||||
emitBlockFunctionBody(node, <Block>node.body);
|
||||
}
|
||||
else {
|
||||
emitExpressionFunctionBody(node, <Expression>node.body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function emitSignatureAndBody(node: FunctionLikeDeclaration) {
|
||||
let saveTempFlags = tempFlags;
|
||||
@@ -3364,19 +3772,15 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
else {
|
||||
emitSignatureParameters(node);
|
||||
}
|
||||
|
||||
if (!node.body) {
|
||||
// There can be no body when there are parse errors. Just emit an empty block
|
||||
// in that case.
|
||||
write(" { }");
|
||||
}
|
||||
else if (node.body.kind === SyntaxKind.Block) {
|
||||
emitBlockFunctionBody(node, <Block>node.body);
|
||||
|
||||
let isAsync = isAsyncFunctionLike(node);
|
||||
if (isAsync && languageVersion === ScriptTarget.ES6) {
|
||||
emitAsyncFunctionBodyForES6(node);
|
||||
}
|
||||
else {
|
||||
emitExpressionFunctionBody(node, <Expression>node.body);
|
||||
emitFunctionBody(node);
|
||||
}
|
||||
|
||||
|
||||
if (!isES6ExportedDeclaration(node)) {
|
||||
emitExportMemberAssignment(node);
|
||||
}
|
||||
@@ -3394,7 +3798,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
|
||||
function emitExpressionFunctionBody(node: FunctionLikeDeclaration, body: Expression) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6 || node.flags & NodeFlags.Async) {
|
||||
emitDownLevelExpressionFunctionBody(node, body);
|
||||
return;
|
||||
}
|
||||
@@ -5692,6 +6096,99 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
}
|
||||
|
||||
function emitJsxElement(node: JsxElement | JsxSelfClosingElement) {
|
||||
switch (compilerOptions.jsx) {
|
||||
case JsxEmit.React:
|
||||
jsxEmitReact(node);
|
||||
break;
|
||||
case JsxEmit.Preserve:
|
||||
// Fall back to preserve if None was specified (we'll error earlier)
|
||||
default:
|
||||
jsxEmitPreserve(node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function trimReactWhitespace(node: JsxText): string {
|
||||
let result: string = undefined;
|
||||
let text = getTextOfNode(node);
|
||||
let firstNonWhitespace = 0;
|
||||
let lastNonWhitespace = -1;
|
||||
|
||||
// JSX trims whitespace at the end and beginning of lines, except that the
|
||||
// start/end of a tag is considered a start/end of a line only if that line is
|
||||
// on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
let c = text.charCodeAt(i);
|
||||
if (isLineBreak(c)) {
|
||||
if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) {
|
||||
let part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1);
|
||||
result = (result ? result + '" + \' \' + "' : '') + part;
|
||||
}
|
||||
firstNonWhitespace = -1;
|
||||
}
|
||||
else if (!isWhiteSpace(c)) {
|
||||
lastNonWhitespace = i;
|
||||
if (firstNonWhitespace === -1) {
|
||||
firstNonWhitespace = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (firstNonWhitespace !== -1) {
|
||||
let part = text.substr(firstNonWhitespace);
|
||||
result = (result ? result + '" + \' \' + "' : '') + part;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function getTextToEmit(node: JsxText) {
|
||||
switch (compilerOptions.jsx) {
|
||||
case JsxEmit.React:
|
||||
let text = trimReactWhitespace(node);
|
||||
if (text.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
else {
|
||||
return text;
|
||||
}
|
||||
case JsxEmit.Preserve:
|
||||
default:
|
||||
return getTextOfNode(node, true);
|
||||
}
|
||||
}
|
||||
|
||||
function emitJsxText(node: JsxText) {
|
||||
switch (compilerOptions.jsx) {
|
||||
case JsxEmit.React:
|
||||
write('"');
|
||||
write(trimReactWhitespace(node));
|
||||
write('"');
|
||||
break;
|
||||
|
||||
case JsxEmit.Preserve:
|
||||
default: // Emit JSX-preserve as default when no --jsx flag is specified
|
||||
write(getTextOfNode(node, true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function emitJsxExpression(node: JsxExpression) {
|
||||
if (node.expression) {
|
||||
switch (compilerOptions.jsx) {
|
||||
case JsxEmit.Preserve:
|
||||
default:
|
||||
write('{');
|
||||
emit(node.expression);
|
||||
write('}');
|
||||
break;
|
||||
case JsxEmit.React:
|
||||
emit(node.expression);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function emitDirectivePrologues(statements: Node[], startWithNewLine: boolean): number {
|
||||
for (let i = 0; i < statements.length; ++i) {
|
||||
if (isPrologueDirective(statements[i])) {
|
||||
@@ -5748,6 +6245,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
writeLines(paramHelper);
|
||||
paramEmitted = true;
|
||||
}
|
||||
|
||||
if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitAwaiter) {
|
||||
writeLines(awaiterHelper);
|
||||
awaiterEmitted = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isExternalModule(node) || compilerOptions.isolatedModules) {
|
||||
@@ -5879,6 +6381,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return emitTemplateExpression(<TemplateExpression>node);
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return emitTemplateSpan(<TemplateSpan>node);
|
||||
case SyntaxKind.JsxElement:
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
return emitJsxElement(<JsxElement|JsxSelfClosingElement>node);
|
||||
case SyntaxKind.JsxText:
|
||||
return emitJsxText(<JsxText>node);
|
||||
case SyntaxKind.JsxExpression:
|
||||
return emitJsxExpression(<JsxExpression>node);
|
||||
case SyntaxKind.QualifiedName:
|
||||
return emitQualifiedName(<QualifiedName>node);
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
@@ -5909,6 +6418,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return emitTaggedTemplateExpression(<TaggedTemplateExpression>node);
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
return emit((<TypeAssertion>node).expression);
|
||||
case SyntaxKind.AsExpression:
|
||||
return emit((<AsExpression>node).expression);
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return emitParenExpression(<ParenthesizedExpression>node);
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
@@ -5921,6 +6432,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return emitTypeOfExpression(<TypeOfExpression>node);
|
||||
case SyntaxKind.VoidExpression:
|
||||
return emitVoidExpression(<VoidExpression>node);
|
||||
case SyntaxKind.AwaitExpression:
|
||||
return emitAwaitExpression(<AwaitExpression>node);
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
return emitPrefixUnaryExpression(<PrefixUnaryExpression>node);
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
@@ -6173,4 +6686,4 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+548
-189
File diff suppressed because it is too large
Load Diff
+82
-39
@@ -104,14 +104,14 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile): Diagnostic[] {
|
||||
let diagnostics = program.getOptionsDiagnostics().concat(
|
||||
program.getSyntacticDiagnostics(sourceFile),
|
||||
program.getGlobalDiagnostics(),
|
||||
program.getSemanticDiagnostics(sourceFile));
|
||||
export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[] {
|
||||
let diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(
|
||||
program.getSyntacticDiagnostics(sourceFile, cancellationToken),
|
||||
program.getGlobalDiagnostics(cancellationToken),
|
||||
program.getSemanticDiagnostics(sourceFile, cancellationToken));
|
||||
|
||||
if (program.getCompilerOptions().declaration) {
|
||||
diagnostics.concat(program.getDeclarationDiagnostics(sourceFile));
|
||||
diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken));
|
||||
}
|
||||
|
||||
return sortAndDeduplicateDiagnostics(diagnostics);
|
||||
@@ -233,10 +233,15 @@ namespace ts {
|
||||
return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false));
|
||||
}
|
||||
|
||||
function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback): EmitResult {
|
||||
function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult {
|
||||
return runWithCancellationToken(() => emitWorker(this, sourceFile, writeFileCallback, cancellationToken));
|
||||
}
|
||||
|
||||
function emitWorker(program: Program, sourceFile: SourceFile, writeFileCallback: WriteFileCallback, cancellationToken: CancellationToken): EmitResult {
|
||||
// If the noEmitOnError flag is set, then check if we have any errors so far. If so,
|
||||
// immediately bail out.
|
||||
if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) {
|
||||
// immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
|
||||
// get any preEmit diagnostics, not just the ones
|
||||
if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) {
|
||||
return { diagnostics: [], sourceMaps: undefined, emitSkipped: true };
|
||||
}
|
||||
|
||||
@@ -265,55 +270,88 @@ namespace ts {
|
||||
return filesByName.get(fileName);
|
||||
}
|
||||
|
||||
function getDiagnosticsHelper(sourceFile: SourceFile, getDiagnostics: (sourceFile: SourceFile) => Diagnostic[]): Diagnostic[] {
|
||||
function getDiagnosticsHelper(
|
||||
sourceFile: SourceFile,
|
||||
getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken) => Diagnostic[],
|
||||
cancellationToken: CancellationToken): Diagnostic[] {
|
||||
if (sourceFile) {
|
||||
return getDiagnostics(sourceFile);
|
||||
return getDiagnostics(sourceFile, cancellationToken);
|
||||
}
|
||||
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
forEach(program.getSourceFiles(), sourceFile => {
|
||||
addRange(allDiagnostics, getDiagnostics(sourceFile));
|
||||
if (cancellationToken) {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
}
|
||||
addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken));
|
||||
});
|
||||
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
function getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile);
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken);
|
||||
}
|
||||
|
||||
function getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile);
|
||||
function getSemanticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken);
|
||||
}
|
||||
|
||||
function getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile);
|
||||
function getDeclarationDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken);
|
||||
}
|
||||
|
||||
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return sourceFile.parseDiagnostics;
|
||||
}
|
||||
|
||||
function getSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
let typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
function runWithCancellationToken<T>(func: () => T): T {
|
||||
try {
|
||||
return func();
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof OperationCanceledException) {
|
||||
// We were canceled while performing the operation. Because our type checker
|
||||
// might be a bad state, we need to throw it away.
|
||||
//
|
||||
// Note: we are overly agressive here. We do not actually *have* to throw away
|
||||
// the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep
|
||||
// the lifetimes of these two TypeCheckers the same. Also, we generally only
|
||||
// cancel when the user has made a change anyways. And, in that case, we (the
|
||||
// program instance) will get thrown away anyways. So trying to keep one of
|
||||
// these type checkers alive doesn't serve much purpose.
|
||||
noDiagnosticsTypeChecker = undefined;
|
||||
diagnosticsProducingTypeChecker = undefined;
|
||||
}
|
||||
|
||||
Debug.assert(!!sourceFile.bindDiagnostics);
|
||||
let bindDiagnostics = sourceFile.bindDiagnostics;
|
||||
let checkDiagnostics = typeChecker.getDiagnostics(sourceFile);
|
||||
let programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
|
||||
|
||||
return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics);
|
||||
}
|
||||
|
||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile);
|
||||
// Don't actually write any files since we're just getting diagnostics.
|
||||
let writeFile: WriteFileCallback = () => { };
|
||||
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return runWithCancellationToken(() => {
|
||||
let typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
Debug.assert(!!sourceFile.bindDiagnostics);
|
||||
let bindDiagnostics = sourceFile.bindDiagnostics;
|
||||
let checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken);
|
||||
let programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
|
||||
|
||||
return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics);
|
||||
});
|
||||
}
|
||||
|
||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return runWithCancellationToken(() => {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
|
||||
// Don't actually write any files since we're just getting diagnostics.
|
||||
var writeFile: WriteFileCallback = () => { };
|
||||
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getOptionsDiagnostics(): Diagnostic[] {
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
|
||||
@@ -475,7 +513,7 @@ namespace ts {
|
||||
}
|
||||
else if (node.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) {
|
||||
// TypeScript 1.0 spec (April 2014): 12.1.6
|
||||
// An AmbientExternalModuleDeclaration declares an external module.
|
||||
// An AmbientExternalModuleDeclaration declares an external module.
|
||||
// This type of declaration is permitted only in the global module.
|
||||
// The StringLiteral must specify a top - level external module name.
|
||||
// Relative external module names are not permitted
|
||||
@@ -487,7 +525,7 @@ namespace ts {
|
||||
let moduleName = nameLiteral.text;
|
||||
if (moduleName) {
|
||||
// TypeScript 1.0 spec (April 2014): 12.1.6
|
||||
// An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules
|
||||
// An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules
|
||||
// only through top - level external module names. Relative external module names are not permitted.
|
||||
let searchName = normalizePath(combinePaths(basePath, moduleName));
|
||||
forEach(supportedExtensions, extension => findModuleSourceFile(searchName + extension, nameLiteral));
|
||||
@@ -626,7 +664,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
|
||||
}
|
||||
@@ -653,7 +691,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== directorySeparator) {
|
||||
// Make sure directory path ends with directory separator so this string can directly
|
||||
// Make sure directory path ends with directory separator so this string can directly
|
||||
// used to replace with "" to get the relative path of the source file and the relative path doesn't
|
||||
// start with / making it rooted path
|
||||
commonSourceDirectory += directorySeparator;
|
||||
@@ -674,6 +712,11 @@ namespace ts {
|
||||
!options.experimentalDecorators) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified));
|
||||
}
|
||||
|
||||
if (options.experimentalAsyncFunctions &&
|
||||
options.target !== ScriptTarget.ES6) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+471
-395
File diff suppressed because one or more lines are too long
+2
-1
@@ -191,7 +191,8 @@ namespace ts {
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
||||
if (commandLine.options.watch) {
|
||||
// Firefox has Object.prototype.watch
|
||||
if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) {
|
||||
if (!sys.watchFile) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
|
||||
+191
-61
@@ -48,6 +48,7 @@ namespace ts {
|
||||
SemicolonToken,
|
||||
CommaToken,
|
||||
LessThanToken,
|
||||
LessThanSlashToken,
|
||||
GreaterThanToken,
|
||||
LessThanEqualsToken,
|
||||
GreaterThanEqualsToken,
|
||||
@@ -139,8 +140,11 @@ namespace ts {
|
||||
StaticKeyword,
|
||||
YieldKeyword,
|
||||
// Contextual keywords
|
||||
AbstractKeyword,
|
||||
AsKeyword,
|
||||
AnyKeyword,
|
||||
AsyncKeyword,
|
||||
AwaitKeyword,
|
||||
BooleanKeyword,
|
||||
ConstructorKeyword,
|
||||
DeclareKeyword,
|
||||
@@ -187,6 +191,7 @@ namespace ts {
|
||||
ArrayType,
|
||||
TupleType,
|
||||
UnionType,
|
||||
IntersectionType,
|
||||
ParenthesizedType,
|
||||
// Binding patterns
|
||||
ObjectBindingPattern,
|
||||
@@ -207,6 +212,7 @@ namespace ts {
|
||||
DeleteExpression,
|
||||
TypeOfExpression,
|
||||
VoidExpression,
|
||||
AwaitExpression,
|
||||
PrefixUnaryExpression,
|
||||
PostfixUnaryExpression,
|
||||
BinaryExpression,
|
||||
@@ -217,6 +223,8 @@ namespace ts {
|
||||
ClassExpression,
|
||||
OmittedExpression,
|
||||
ExpressionWithTypeArguments,
|
||||
AsExpression,
|
||||
|
||||
// Misc
|
||||
TemplateSpan,
|
||||
SemicolonClassElement,
|
||||
@@ -265,6 +273,16 @@ namespace ts {
|
||||
// Module references
|
||||
ExternalModuleReference,
|
||||
|
||||
//JSX
|
||||
JsxElement,
|
||||
JsxSelfClosingElement,
|
||||
JsxOpeningElement,
|
||||
JsxText,
|
||||
JsxClosingElement,
|
||||
JsxAttribute,
|
||||
JsxSpreadAttribute,
|
||||
JsxExpression,
|
||||
|
||||
// Clauses
|
||||
CaseClause,
|
||||
DefaultClause,
|
||||
@@ -343,17 +361,19 @@ namespace ts {
|
||||
Private = 0x00000020, // Property/Method
|
||||
Protected = 0x00000040, // Property/Method
|
||||
Static = 0x00000080, // Property/Method
|
||||
Default = 0x00000100, // Function/Class (export default declaration)
|
||||
MultiLine = 0x00000200, // Multi-line array or object literal
|
||||
Synthetic = 0x00000400, // Synthetic node (for full fidelity)
|
||||
DeclarationFile = 0x00000800, // Node is a .d.ts file
|
||||
Let = 0x00001000, // Variable declaration
|
||||
Const = 0x00002000, // Variable declaration
|
||||
OctalLiteral = 0x00004000, // Octal numeric literal
|
||||
Namespace = 0x00008000, // Namespace declaration
|
||||
ExportContext = 0x00010000, // Export context (initialized by binding)
|
||||
Abstract = 0x00000100, // Class/Method/ConstructSignature
|
||||
Async = 0x00000200, // Property/Method/Function
|
||||
Default = 0x00000400, // Function/Class (export default declaration)
|
||||
MultiLine = 0x00000800, // Multi-line array or object literal
|
||||
Synthetic = 0x00001000, // Synthetic node (for full fidelity)
|
||||
DeclarationFile = 0x00002000, // Node is a .d.ts file
|
||||
Let = 0x00004000, // Variable declaration
|
||||
Const = 0x00008000, // Variable declaration
|
||||
OctalLiteral = 0x00010000, // Octal numeric literal
|
||||
Namespace = 0x00020000, // Namespace declaration
|
||||
ExportContext = 0x00040000, // Export context (initialized by binding)
|
||||
|
||||
Modifier = Export | Ambient | Public | Private | Protected | Static | Default,
|
||||
Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async,
|
||||
AccessibilityModifier = Public | Private | Protected,
|
||||
BlockScoped = Let | Const
|
||||
}
|
||||
@@ -363,39 +383,53 @@ namespace ts {
|
||||
None = 0,
|
||||
|
||||
// If this node was parsed in a context where 'in-expressions' are not allowed.
|
||||
DisallowIn = 1 << 1,
|
||||
DisallowIn = 1 << 0,
|
||||
|
||||
// If this node was parsed in the 'yield' context created when parsing a generator.
|
||||
Yield = 1 << 2,
|
||||
|
||||
// If this node was parsed in the parameters of a generator.
|
||||
GeneratorParameter = 1 << 3,
|
||||
Yield = 1 << 1,
|
||||
|
||||
// If this node was parsed as part of a decorator
|
||||
Decorator = 1 << 4,
|
||||
Decorator = 1 << 2,
|
||||
|
||||
// If this node was parsed in the 'await' context created when parsing an async function.
|
||||
Await = 1 << 3,
|
||||
|
||||
// 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.
|
||||
ThisNodeHasError = 1 << 5,
|
||||
ThisNodeHasError = 1 << 4,
|
||||
|
||||
// This node was parsed in a JavaScript file and can be processed differently. For example
|
||||
// its type can be specified usign a JSDoc comment.
|
||||
JavaScriptFile = 1 << 6,
|
||||
JavaScriptFile = 1 << 5,
|
||||
|
||||
// Context flags set directly by the parser.
|
||||
ParserGeneratedFlags = DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError,
|
||||
ParserGeneratedFlags = DisallowIn | Yield | Decorator | ThisNodeHasError | Await,
|
||||
|
||||
// Exclude these flags when parsing a Type
|
||||
TypeExcludesFlags = Yield | Await,
|
||||
|
||||
// Context flags computed by aggregating child flags upwards.
|
||||
|
||||
// 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 << 7,
|
||||
ThisNodeOrAnySubNodesHasError = 1 << 6,
|
||||
|
||||
// Used to know if we've computed data from children and cached it in this node.
|
||||
HasAggregatedChildData = 1 << 8
|
||||
HasAggregatedChildData = 1 << 7
|
||||
}
|
||||
|
||||
export const enum JsxFlags {
|
||||
None = 0,
|
||||
IntrinsicNamedElement = 1 << 0,
|
||||
IntrinsicIndexedElement = 1 << 1,
|
||||
ClassElement = 1 << 2,
|
||||
UnknownElement = 1 << 3,
|
||||
|
||||
IntrinsicElement = IntrinsicNamedElement | IntrinsicIndexedElement
|
||||
}
|
||||
|
||||
|
||||
/* @internal */
|
||||
export const enum RelationComparisonResult {
|
||||
Succeeded = 1, // Should be truthy
|
||||
@@ -634,10 +668,14 @@ namespace ts {
|
||||
elementTypes: NodeArray<TypeNode>;
|
||||
}
|
||||
|
||||
export interface UnionTypeNode extends TypeNode {
|
||||
export interface UnionOrIntersectionTypeNode extends TypeNode {
|
||||
types: NodeArray<TypeNode>;
|
||||
}
|
||||
|
||||
export interface UnionTypeNode extends UnionOrIntersectionTypeNode { }
|
||||
|
||||
export interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { }
|
||||
|
||||
export interface ParenthesizedTypeNode extends TypeNode {
|
||||
type: TypeNode;
|
||||
}
|
||||
@@ -702,6 +740,10 @@ namespace ts {
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
|
||||
export interface AwaitExpression extends UnaryExpression {
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
|
||||
export interface YieldExpression extends Expression {
|
||||
asteriskToken?: Node;
|
||||
expression?: Expression;
|
||||
@@ -799,11 +841,64 @@ namespace ts {
|
||||
|
||||
export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator;
|
||||
|
||||
export interface AsExpression extends Expression {
|
||||
expression: Expression;
|
||||
type: TypeNode;
|
||||
}
|
||||
|
||||
export interface TypeAssertion extends UnaryExpression {
|
||||
type: TypeNode;
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
|
||||
export type AssertionExpression = TypeAssertion | AsExpression;
|
||||
|
||||
/// A JSX expression of the form <TagName attrs>...</TagName>
|
||||
export interface JsxElement extends PrimaryExpression {
|
||||
openingElement: JsxOpeningElement;
|
||||
children: NodeArray<JsxChild>;
|
||||
closingElement: JsxClosingElement;
|
||||
}
|
||||
|
||||
/// The opening element of a <Tag>...</Tag> JsxElement
|
||||
export interface JsxOpeningElement extends Expression {
|
||||
_openingElementBrand?: any;
|
||||
tagName: EntityName;
|
||||
attributes: NodeArray<JsxAttribute | JsxSpreadAttribute>;
|
||||
}
|
||||
|
||||
/// A JSX expression of the form <TagName attrs />
|
||||
export interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement {
|
||||
_selfClosingElementBrand?: any;
|
||||
}
|
||||
|
||||
/// Either the opening tag in a <Tag>...</Tag> pair, or the lone <Tag /> in a self-closing form
|
||||
export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement;
|
||||
|
||||
export interface JsxAttribute extends Node {
|
||||
name: Identifier;
|
||||
/// JSX attribute initializers are optional; <X y /> is sugar for <X y={true} />
|
||||
initializer?: Expression;
|
||||
}
|
||||
|
||||
export interface JsxSpreadAttribute extends Node {
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
export interface JsxClosingElement extends Node {
|
||||
tagName: EntityName;
|
||||
}
|
||||
|
||||
export interface JsxExpression extends Expression {
|
||||
expression?: Expression;
|
||||
}
|
||||
|
||||
export interface JsxText extends Node {
|
||||
_jsxTextExpressionBrand: any;
|
||||
}
|
||||
|
||||
export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement;
|
||||
|
||||
export interface Statement extends Node {
|
||||
_statementBrand: any;
|
||||
}
|
||||
@@ -1144,6 +1239,7 @@ namespace ts {
|
||||
amdDependencies: {path: string; name: string}[];
|
||||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
languageVariant: LanguageVariant;
|
||||
|
||||
/**
|
||||
* lib.d.ts should have a reference comment like
|
||||
@@ -1194,6 +1290,15 @@ namespace ts {
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
}
|
||||
|
||||
export class OperationCanceledException { }
|
||||
|
||||
export interface CancellationToken {
|
||||
isCancellationRequested(): boolean;
|
||||
|
||||
/** @throws OperationCanceledException if isCancellationRequested is true */
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
|
||||
export interface Program extends ScriptReferenceHost {
|
||||
/**
|
||||
* Get a list of files in the program
|
||||
@@ -1210,15 +1315,15 @@ namespace ts {
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult;
|
||||
|
||||
getOptionsDiagnostics(): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
|
||||
/**
|
||||
/**
|
||||
* Gets a type checker that can be used to semantically analyze source fils in the program.
|
||||
*/
|
||||
getTypeChecker(): TypeChecker;
|
||||
@@ -1323,10 +1428,13 @@ namespace ts {
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
|
||||
|
||||
getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type;
|
||||
getJsxIntrinsicTagNames(): Symbol[];
|
||||
|
||||
// Should not be called directly. Should only be accessed through the Program instance.
|
||||
/* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
/* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
/* @internal */ getGlobalDiagnostics(): Diagnostic[];
|
||||
/* @internal */ getEmitResolver(sourceFile?: SourceFile): EmitResolver;
|
||||
/* @internal */ getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken): EmitResolver;
|
||||
|
||||
/* @internal */ getNodeCount(): number;
|
||||
/* @internal */ getIdentifierCount(): number;
|
||||
@@ -1479,7 +1587,7 @@ namespace ts {
|
||||
Merged = 0x02000000, // Merged symbol (created during program binding)
|
||||
Transient = 0x04000000, // Transient symbol (created during type check)
|
||||
Prototype = 0x08000000, // Prototype property (no source representation)
|
||||
UnionProperty = 0x10000000, // Property in union type
|
||||
SyntheticProperty = 0x10000000, // Property in union or intersection type
|
||||
Optional = 0x20000000, // Optional property
|
||||
ExportStar = 0x40000000, // Export * declaration
|
||||
|
||||
@@ -1503,8 +1611,8 @@ namespace ts {
|
||||
PropertyExcludes = Value,
|
||||
EnumMemberExcludes = Value,
|
||||
FunctionExcludes = Value & ~(Function | ValueModule),
|
||||
ClassExcludes = (Value | Type) & ~ValueModule,
|
||||
InterfaceExcludes = Type & ~Interface,
|
||||
ClassExcludes = (Value | Type) & ~(ValueModule | Interface), // class-interface mergability done in checker.ts
|
||||
InterfaceExcludes = Type & ~(Interface | Class),
|
||||
RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules
|
||||
ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums
|
||||
ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule),
|
||||
@@ -1529,7 +1637,7 @@ namespace ts {
|
||||
Export = ExportNamespace | ExportType | ExportValue,
|
||||
|
||||
/* @internal */
|
||||
// The set of things we consider semantically classifiable. Used to speed up the LS during
|
||||
// The set of things we consider semantically classifiable. Used to speed up the LS during
|
||||
// classification.
|
||||
Classifiable = Class | Enum | TypeAlias | Interface | TypeParameter | Module,
|
||||
}
|
||||
@@ -1558,7 +1666,7 @@ namespace ts {
|
||||
instantiations?: Map<Type>; // Instantiations of generic type alias (undefined if non-generic)
|
||||
mapper?: TypeMapper; // Type mapper for instantiation alias
|
||||
referenced?: boolean; // True if alias symbol has been referenced as a value
|
||||
unionType?: UnionType; // Containing union type for union property
|
||||
containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property
|
||||
resolvedExports?: SymbolTable; // Resolved exports of module
|
||||
exportsChecked?: boolean; // True if exports of external module have been checked
|
||||
isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration
|
||||
@@ -1577,21 +1685,26 @@ namespace ts {
|
||||
LexicalThis = 0x00000002, // Lexical 'this' reference
|
||||
CaptureThis = 0x00000004, // Lexical 'this' used in body
|
||||
EmitExtends = 0x00000008, // Emit __extends
|
||||
SuperInstance = 0x00000010, // Instance 'super' reference
|
||||
SuperStatic = 0x00000020, // Static 'super' reference
|
||||
ContextChecked = 0x00000040, // Contextual types have been assigned
|
||||
EmitDecorate = 0x00000010, // Emit __decorate
|
||||
EmitParam = 0x00000020, // Emit __param helper for decorators
|
||||
EmitAwaiter = 0x00000040, // Emit __awaiter
|
||||
EmitGenerator = 0x00000080, // Emit __generator
|
||||
SuperInstance = 0x00000100, // Instance 'super' reference
|
||||
SuperStatic = 0x00000200, // Static 'super' reference
|
||||
ContextChecked = 0x00000400, // Contextual types have been assigned
|
||||
LexicalArguments = 0x00000800,
|
||||
CaptureArguments = 0x00001000, // Lexical 'arguments' used in body (for async functions)
|
||||
|
||||
// Values for enum members have been computed, and any errors have been reported for them.
|
||||
EnumValuesComputed = 0x00000080,
|
||||
BlockScopedBindingInLoop = 0x00000100,
|
||||
EmitDecorate = 0x00000200, // Emit __decorate
|
||||
EmitParam = 0x00000400, // Emit __param helper for decorators
|
||||
LexicalModuleMergesWithClass = 0x00000800, // Instantiated lexical module declaration is merged with a previous class declaration.
|
||||
EnumValuesComputed = 0x00002000,
|
||||
BlockScopedBindingInLoop = 0x00004000,
|
||||
LexicalModuleMergesWithClass= 0x00008000, // Instantiated lexical module declaration is merged with a previous class declaration.
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export interface NodeLinks {
|
||||
resolvedType?: Type; // Cached type of type node
|
||||
resolvedAwaitedType?: Type; // Cached awaited type of type node
|
||||
resolvedSignature?: Signature; // Cached signature of signature node or call expression
|
||||
resolvedSymbol?: Symbol; // Cached name resolution result
|
||||
flags?: NodeCheckFlags; // Set of flags specific to Node
|
||||
@@ -1603,6 +1716,8 @@ namespace ts {
|
||||
assignmentChecks?: Map<boolean>; // Cache of assignment checks
|
||||
hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context
|
||||
importOnRightSide?: Symbol; // for import declarations - import that appear on the right side
|
||||
jsxFlags?: JsxFlags; // flags for knowning what kind of element/attributes we're dealing with
|
||||
resolvedJsxType?: Type; // resolved element attributes type of a JSX openinglike element
|
||||
}
|
||||
|
||||
export const enum TypeFlags {
|
||||
@@ -1620,17 +1735,18 @@ namespace ts {
|
||||
Interface = 0x00000800, // Interface
|
||||
Reference = 0x00001000, // Generic type reference
|
||||
Tuple = 0x00002000, // Tuple
|
||||
Union = 0x00004000, // Union
|
||||
Anonymous = 0x00008000, // Anonymous
|
||||
Instantiated = 0x00010000, // Instantiated anonymous type
|
||||
Union = 0x00004000, // Union (T | U)
|
||||
Intersection = 0x00008000, // Intersection (T & U)
|
||||
Anonymous = 0x00010000, // Anonymous
|
||||
Instantiated = 0x00020000, // Instantiated anonymous type
|
||||
/* @internal */
|
||||
FromSignature = 0x00020000, // Created for signature assignment check
|
||||
ObjectLiteral = 0x00040000, // Originates in an object literal
|
||||
FromSignature = 0x00040000, // Created for signature assignment check
|
||||
ObjectLiteral = 0x00080000, // Originates in an object literal
|
||||
/* @internal */
|
||||
ContainsUndefinedOrNull = 0x00080000, // Type is or contains Undefined or Null type
|
||||
ContainsUndefinedOrNull = 0x00100000, // Type is or contains Undefined or Null type
|
||||
/* @internal */
|
||||
ContainsObjectLiteral = 0x00100000, // Type is or contains object literal type
|
||||
ESSymbol = 0x00200000, // Type of symbol primitive introduced in ES6
|
||||
ContainsObjectLiteral = 0x00200000, // Type is or contains object literal type
|
||||
ESSymbol = 0x00400000, // Type of symbol primitive introduced in ES6
|
||||
|
||||
/* @internal */
|
||||
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
|
||||
@@ -1639,8 +1755,10 @@ namespace ts {
|
||||
StringLike = String | StringLiteral,
|
||||
NumberLike = Number | Enum,
|
||||
ObjectType = Class | Interface | Reference | Tuple | Anonymous,
|
||||
UnionOrIntersection = Union | Intersection,
|
||||
StructuredType = ObjectType | Union | Intersection,
|
||||
/* @internal */
|
||||
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral
|
||||
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral
|
||||
}
|
||||
|
||||
// Properties common to all types
|
||||
@@ -1698,7 +1816,7 @@ namespace ts {
|
||||
baseArrayType: TypeReference; // Array<T> where T is best common type of element types
|
||||
}
|
||||
|
||||
export interface UnionType extends Type {
|
||||
export interface UnionOrIntersectionType extends Type {
|
||||
types: Type[]; // Constituent types
|
||||
/* @internal */
|
||||
reducedType: Type; // Reduced union type (all subtypes removed)
|
||||
@@ -1706,9 +1824,13 @@ namespace ts {
|
||||
resolvedProperties: SymbolTable; // Cache of resolved properties
|
||||
}
|
||||
|
||||
export interface UnionType extends UnionOrIntersectionType { }
|
||||
|
||||
export interface IntersectionType extends UnionOrIntersectionType { }
|
||||
|
||||
/* @internal */
|
||||
// Resolved object or union type
|
||||
export interface ResolvedType extends ObjectType, UnionType {
|
||||
// Resolved object, union, or intersection type
|
||||
export interface ResolvedType extends ObjectType, UnionOrIntersectionType {
|
||||
members: SymbolTable; // Properties by name
|
||||
properties: Symbol[]; // Properties
|
||||
callSignatures: Signature[]; // Call signatures of type
|
||||
@@ -1834,6 +1956,7 @@ namespace ts {
|
||||
help?: boolean;
|
||||
inlineSourceMap?: boolean;
|
||||
inlineSources?: boolean;
|
||||
jsx?: JsxEmit;
|
||||
listFiles?: boolean;
|
||||
locale?: string;
|
||||
mapRoot?: string;
|
||||
@@ -1860,6 +1983,7 @@ namespace ts {
|
||||
watch?: boolean;
|
||||
isolatedModules?: boolean;
|
||||
experimentalDecorators?: boolean;
|
||||
experimentalAsyncFunctions?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
/* @internal */ stripInternal?: boolean;
|
||||
|
||||
@@ -1877,6 +2001,12 @@ namespace ts {
|
||||
System = 4,
|
||||
}
|
||||
|
||||
export const enum JsxEmit {
|
||||
None = 0,
|
||||
Preserve = 1,
|
||||
React = 2
|
||||
}
|
||||
|
||||
export const enum NewLineKind {
|
||||
CarriageReturnLineFeed = 0,
|
||||
LineFeed = 1,
|
||||
@@ -1897,6 +2027,11 @@ namespace ts {
|
||||
Latest = ES6,
|
||||
}
|
||||
|
||||
export const enum LanguageVariant {
|
||||
Standard,
|
||||
JSX
|
||||
}
|
||||
|
||||
export interface ParsedCommandLine {
|
||||
options: CompilerOptions;
|
||||
fileNames: string[];
|
||||
@@ -2052,14 +2187,9 @@ namespace ts {
|
||||
verticalTab = 0x0B, // \v
|
||||
}
|
||||
|
||||
export interface CancellationToken {
|
||||
isCancellationRequested(): boolean;
|
||||
}
|
||||
|
||||
export interface CompilerHost {
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getCancellationToken? (): CancellationToken;
|
||||
writeFile: WriteFileCallback;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
|
||||
+51
-14
@@ -144,7 +144,7 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
return node.pos === node.end && node.kind !== SyntaxKind.EndOfFileToken;
|
||||
return node.pos === node.end && node.pos >= 0 && node.kind !== SyntaxKind.EndOfFileToken;
|
||||
}
|
||||
|
||||
export function nodeIsPresent(node: Node) {
|
||||
@@ -169,13 +169,13 @@ namespace ts {
|
||||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end);
|
||||
}
|
||||
|
||||
export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string {
|
||||
export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia = false): string {
|
||||
if (nodeIsMissing(node)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
let text = sourceFile.text;
|
||||
return text.substring(skipTrivia(text, node.pos), node.end);
|
||||
return text.substring(includeTrivia ? node.pos : skipTrivia(text, node.pos), node.end);
|
||||
}
|
||||
|
||||
export function getTextOfNodeFromSourceText(sourceText: string, node: Node): string {
|
||||
@@ -186,8 +186,8 @@ namespace ts {
|
||||
return sourceText.substring(skipTrivia(sourceText, node.pos), node.end);
|
||||
}
|
||||
|
||||
export function getTextOfNode(node: Node): string {
|
||||
return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node);
|
||||
export function getTextOfNode(node: Node, includeTrivia = false): string {
|
||||
return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia);
|
||||
}
|
||||
|
||||
// Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__'
|
||||
@@ -274,7 +274,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan {
|
||||
let scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.text, /*onError:*/ undefined, pos);
|
||||
let scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos);
|
||||
scanner.scan();
|
||||
let start = scanner.getTokenPos();
|
||||
return createTextSpanFromBounds(start, scanner.getTextPos());
|
||||
@@ -746,6 +746,22 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getEntityNameFromTypeNode(node: TypeNode): EntityName | Expression {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeReference:
|
||||
return (<TypeReferenceNode>node).typeName;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return (<ExpressionWithTypeArguments>node).expression
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.QualifiedName:
|
||||
return (<EntityName><Node>node);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getInvokedExpression(node: CallLikeExpression): Expression {
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
@@ -848,6 +864,7 @@ namespace ts {
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.AsExpression:
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
@@ -864,6 +881,8 @@ namespace ts {
|
||||
case SyntaxKind.TemplateExpression:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case SyntaxKind.OmittedExpression:
|
||||
case SyntaxKind.JsxElement:
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
case SyntaxKind.YieldExpression:
|
||||
return true;
|
||||
case SyntaxKind.QualifiedName:
|
||||
@@ -910,7 +929,8 @@ namespace ts {
|
||||
return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) ||
|
||||
forInStatement.expression === node;
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
return node === (<TypeAssertion>parent).expression;
|
||||
case SyntaxKind.AsExpression:
|
||||
return node === (<AssertionExpression>parent).expression;
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return node === (<TemplateSpan>parent).expression;
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
@@ -1317,6 +1337,10 @@ namespace ts {
|
||||
return SyntaxKind.FirstTriviaToken <= token && token <= SyntaxKind.LastTriviaToken;
|
||||
}
|
||||
|
||||
export function isAsyncFunctionLike(node: Node): boolean {
|
||||
return isFunctionLike(node) && (node.flags & NodeFlags.Async) !== 0 && !isAccessor(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* A declaration has a dynamic name if both of the following are true:
|
||||
* 1. The declaration has a computed property name
|
||||
@@ -1367,14 +1391,16 @@ namespace ts {
|
||||
|
||||
export function isModifier(token: SyntaxKind): boolean {
|
||||
switch (token) {
|
||||
case SyntaxKind.AbstractKeyword:
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.DefaultKeyword:
|
||||
case SyntaxKind.ExportKeyword:
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
case SyntaxKind.StaticKeyword:
|
||||
case SyntaxKind.ExportKeyword:
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
case SyntaxKind.DefaultKeyword:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1402,8 +1428,6 @@ namespace ts {
|
||||
|
||||
export function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node {
|
||||
let node = <SynthesizedNode>createNode(kind);
|
||||
node.pos = -1;
|
||||
node.end = -1;
|
||||
node.startsOnNewLine = startsOnNewLine;
|
||||
return node;
|
||||
}
|
||||
@@ -1530,6 +1554,11 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function isIntrinsicJsxName(name: string) {
|
||||
let ch = name.substr(0, 1);
|
||||
return ch.toLowerCase() === ch;
|
||||
}
|
||||
|
||||
function get16BitUnicodeEscapeSequence(charCode: number): string {
|
||||
let hexCharCode = charCode.toString(16).toUpperCase();
|
||||
let paddedHexCode = ("0000" + hexCharCode).slice(-4);
|
||||
@@ -1870,10 +1899,12 @@ namespace ts {
|
||||
case SyntaxKind.PublicKeyword: return NodeFlags.Public;
|
||||
case SyntaxKind.ProtectedKeyword: return NodeFlags.Protected;
|
||||
case SyntaxKind.PrivateKeyword: return NodeFlags.Private;
|
||||
case SyntaxKind.AbstractKeyword: return NodeFlags.Abstract;
|
||||
case SyntaxKind.ExportKeyword: return NodeFlags.Export;
|
||||
case SyntaxKind.DeclareKeyword: return NodeFlags.Ambient;
|
||||
case SyntaxKind.ConstKeyword: return NodeFlags.Const;
|
||||
case SyntaxKind.DefaultKeyword: return NodeFlags.Default;
|
||||
case SyntaxKind.AsyncKeyword: return NodeFlags.Async;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1885,6 +1916,8 @@ namespace ts {
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.JsxElement:
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
@@ -1936,7 +1969,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function isRightSideOfQualifiedNameOrPropertyAccess(node: Node) {
|
||||
return (node.parent.kind === SyntaxKind.QualifiedName && (<QualifiedName>node.parent).right === node) ||
|
||||
(node.parent.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>node.parent).name === node);
|
||||
@@ -1950,6 +1983,10 @@ namespace ts {
|
||||
return fileExtensionIs(fileName, ".js");
|
||||
}
|
||||
|
||||
export function isTsx(fileName: string) {
|
||||
return fileExtensionIs(fileName, ".tsx");
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
|
||||
* representing the UTF-8 encoding of the character, and return the expanded char code list.
|
||||
|
||||
Reference in New Issue
Block a user