diff --git a/Jakefile.js b/Jakefile.js
index 3ac2e8fad13..77d81071e66 100644
--- a/Jakefile.js
+++ b/Jakefile.js
@@ -394,6 +394,7 @@ var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
var nodePackageFile = path.join(builtLocalDirectory, "typescript.js");
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
+var nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_standalone.d.ts");
compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
/*prefixes*/ [copyright],
@@ -410,11 +411,19 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
prependFile(copyright, standaloneDefinitionsFile);
- // Create the node definition file by replacing 'ts' module with '"typescript"' as a module.
+ // Stanalone/web definition file using global 'ts' namespace
jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true});
var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString();
- definitionFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
- fs.writeFileSync(nodeDefinitionsFile, definitionFileContents);
+
+ // Official node package definition file, pointed to by 'typings' in package.json
+ // Created by appending 'export = ts;' at the end of the standalone file to turn it into an external module
+ var nodeDefinitionsFileContents = definitionFileContents + "\r\nexport = ts;";
+ fs.writeFileSync(nodeDefinitionsFile, nodeDefinitionsFileContents);
+
+ // Node package definition file to be distributed without the package. Created by replacing
+ // 'ts' namespace with '"typescript"' as a module.
+ var nodeStandaloneDefinitionsFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
+ fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents);
});
diff --git a/lib/lib.d.ts b/lib/lib.d.ts
index c55970d9aca..d25e29bddb4 100644
--- a/lib/lib.d.ts
+++ b/lib/lib.d.ts
@@ -3928,6 +3928,7 @@ declare module Intl {
timeZoneName?: string;
formatMatcher?: string;
hour12?: boolean;
+ timeZone?: string;
}
interface ResolvedDateTimeFormatOptions {
@@ -3997,18 +3998,45 @@ interface Number {
interface Date {
/**
- * Converts a date to a string by using the current or specified locale.
+ * Converts a date and time to a string by using the current or specified locale.
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
+ /**
+ * Converts a date to a string by using the current or specified locale.
+ * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
+ /**
+ * Converts a time to a string by using the current or specified locale.
+ * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string;
+
+ /**
+ * Converts a date and time to a string by using the current or specified locale.
+ * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
+
/**
* Converts a date to a string by using the current or specified locale.
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
- toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
+ toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
+
+ /**
+ * Converts a time to a string by using the current or specified locale.
+ * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
}
diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts
index 54461afef40..76e5f1b20a1 100644
--- a/lib/lib.dom.d.ts
+++ b/lib/lib.dom.d.ts
@@ -104,6 +104,7 @@ declare module Intl {
timeZoneName?: string;
formatMatcher?: string;
hour12?: boolean;
+ timeZone?: string;
}
interface ResolvedDateTimeFormatOptions {
@@ -173,18 +174,45 @@ interface Number {
interface Date {
/**
- * Converts a date to a string by using the current or specified locale.
+ * Converts a date and time to a string by using the current or specified locale.
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
+ /**
+ * Converts a date to a string by using the current or specified locale.
+ * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
+ /**
+ * Converts a time to a string by using the current or specified locale.
+ * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string;
+
+ /**
+ * Converts a date and time to a string by using the current or specified locale.
+ * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
+
/**
* Converts a date to a string by using the current or specified locale.
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
- toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
+ toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
+
+ /**
+ * Converts a time to a string by using the current or specified locale.
+ * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
}
diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts
index de051a44edd..507f0da5004 100644
--- a/lib/lib.es6.d.ts
+++ b/lib/lib.es6.d.ts
@@ -5216,6 +5216,7 @@ declare module Intl {
timeZoneName?: string;
formatMatcher?: string;
hour12?: boolean;
+ timeZone?: string;
}
interface ResolvedDateTimeFormatOptions {
@@ -5285,18 +5286,45 @@ interface Number {
interface Date {
/**
- * Converts a date to a string by using the current or specified locale.
+ * Converts a date and time to a string by using the current or specified locale.
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
+ /**
+ * Converts a date to a string by using the current or specified locale.
+ * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
+ /**
+ * Converts a time to a string by using the current or specified locale.
+ * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string;
+
+ /**
+ * Converts a date and time to a string by using the current or specified locale.
+ * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
+
/**
* Converts a date to a string by using the current or specified locale.
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
- toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
+ toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
+
+ /**
+ * Converts a time to a string by using the current or specified locale.
+ * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
}
diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts
index 0f3e85da9f1..56e08ff6efc 100644
--- a/lib/lib.webworker.d.ts
+++ b/lib/lib.webworker.d.ts
@@ -104,6 +104,7 @@ declare module Intl {
timeZoneName?: string;
formatMatcher?: string;
hour12?: boolean;
+ timeZone?: string;
}
interface ResolvedDateTimeFormatOptions {
@@ -173,18 +174,45 @@ interface Number {
interface Date {
/**
- * Converts a date to a string by using the current or specified locale.
+ * Converts a date and time to a string by using the current or specified locale.
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
+ /**
+ * Converts a date to a string by using the current or specified locale.
+ * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
+ /**
+ * Converts a time to a string by using the current or specified locale.
+ * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string;
+
+ /**
+ * Converts a date and time to a string by using the current or specified locale.
+ * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
+
/**
* Converts a date to a string by using the current or specified locale.
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
- toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
+ toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
+
+ /**
+ * Converts a time to a string by using the current or specified locale.
+ * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
}
diff --git a/lib/tsc.js b/lib/tsc.js
index 591a22bceb9..3983b8c1e1b 100644
--- a/lib/tsc.js
+++ b/lib/tsc.js
@@ -1248,7 +1248,7 @@ var ts;
Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.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: ts.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: ts.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: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
+ An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.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: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." },
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." },
@@ -1419,6 +1419,7 @@ var ts;
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.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: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." },
await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." },
+ Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." },
JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.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: ts.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: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." },
@@ -1431,6 +1432,10 @@ var ts;
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
+ Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." },
+ Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." },
+ Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." },
+ Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.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: ts.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: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -1564,13 +1569,14 @@ var ts;
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" },
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
+ Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." },
Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" },
Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." },
Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." },
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.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: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
- Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
+ Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." },
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
@@ -1622,6 +1628,10 @@ var ts;
///
var ts;
(function (ts) {
+ function tokenIsIdentifierOrKeyword(token) {
+ return token >= 67;
+ }
+ ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
var textToToken = {
"abstract": 113,
"any": 115,
@@ -2913,7 +2923,7 @@ var ts;
return token = 234;
}
function scanJsxIdentifier() {
- if (token === 67) {
+ if (tokenIsIdentifierOrKeyword(token)) {
var firstCharPosition = pos;
while (pos < end) {
var ch = text.charCodeAt(pos);
@@ -3759,21 +3769,21 @@ var ts;
return true;
}
ts.arrayIsEqualTo = arrayIsEqualTo;
- function hasResolvedModuleName(sourceFile, moduleNameText) {
+ function hasResolvedModule(sourceFile, moduleNameText) {
return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText);
}
- ts.hasResolvedModuleName = hasResolvedModuleName;
- function getResolvedModuleFileName(sourceFile, moduleNameText) {
- return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined;
+ ts.hasResolvedModule = hasResolvedModule;
+ function getResolvedModule(sourceFile, moduleNameText) {
+ return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined;
}
- ts.getResolvedModuleFileName = getResolvedModuleFileName;
- function setResolvedModuleName(sourceFile, moduleNameText, resolvedFileName) {
+ ts.getResolvedModule = getResolvedModule;
+ function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
if (!sourceFile.resolvedModules) {
sourceFile.resolvedModules = {};
}
- sourceFile.resolvedModules[moduleNameText] = resolvedFileName;
+ sourceFile.resolvedModules[moduleNameText] = resolvedModule;
}
- ts.setResolvedModuleName = setResolvedModuleName;
+ ts.setResolvedModule = setResolvedModule;
function containsParseError(node) {
aggregateChildData(node);
return (node.parserContextFlags & 64) !== 0;
@@ -4029,6 +4039,7 @@ var ts;
}
ts.getJsDocComments = getJsDocComments;
ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/;
+ ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/;
function isTypeNode(node) {
if (149 <= node.kind && node.kind <= 158) {
return true;
@@ -4975,11 +4986,21 @@ var ts;
add: add,
getGlobalDiagnostics: getGlobalDiagnostics,
getDiagnostics: getDiagnostics,
- getModificationCount: getModificationCount
+ getModificationCount: getModificationCount,
+ reattachFileDiagnostics: reattachFileDiagnostics
};
function getModificationCount() {
return modificationCount;
}
+ function reattachFileDiagnostics(newFile) {
+ if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) {
+ return;
+ }
+ for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) {
+ var diagnostic = _a[_i];
+ diagnostic.file = newFile;
+ }
+ }
function add(diagnostic) {
var diagnostics;
if (diagnostic.file) {
@@ -6421,10 +6442,10 @@ var ts;
return createIdentifier(isIdentifier(), diagnosticMessage);
}
function parseIdentifierName() {
- return createIdentifier(isIdentifierOrKeyword());
+ return createIdentifier(ts.tokenIsIdentifierOrKeyword(token));
}
function isLiteralPropertyName() {
- return isIdentifierOrKeyword() ||
+ return ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 ||
token === 8;
}
@@ -6444,7 +6465,7 @@ var ts;
return parsePropertyNameWorker(false);
}
function isSimplePropertyName() {
- return token === 9 || token === 8 || isIdentifierOrKeyword();
+ return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token);
}
function parseComputedPropertyName() {
var node = createNode(134);
@@ -6535,9 +6556,9 @@ var ts;
case 20:
return isHeritageClause();
case 21:
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
case 13:
- return isIdentifierOrKeyword() || token === 15;
+ return ts.tokenIsIdentifierOrKeyword(token) || token === 15;
case 14:
return true;
case 22:
@@ -6563,7 +6584,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeyword() {
nextToken();
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
function isHeritageClauseExtendsOrImplementsKeyword() {
if (token === 104 ||
@@ -6931,7 +6952,7 @@ var ts;
return entity;
}
function parseRightSideOfDot(allowIdentifierNames) {
- if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) {
+ if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) {
var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
if (matchesPattern) {
return createMissingNode(67, true, ts.Diagnostics.Identifier_expected);
@@ -7221,7 +7242,7 @@ var ts;
return result;
}
}
- if (isIdentifierOrKeyword()) {
+ if (ts.tokenIsIdentifierOrKeyword(token)) {
return parsePropertyOrMethodSignature();
}
}
@@ -8514,12 +8535,9 @@ var ts;
return finishNode(expressionStatement);
}
}
- function isIdentifierOrKeyword() {
- return token >= 67;
- }
function nextTokenIsIdentifierOrKeywordOnSameLine() {
nextToken();
- return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak();
+ return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak();
}
function nextTokenIsFunctionKeywordOnSameLine() {
nextToken();
@@ -8527,7 +8545,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() {
nextToken();
- return (isIdentifierOrKeyword() || token === 8) && !scanner.hasPrecedingLineBreak();
+ return (ts.tokenIsIdentifierOrKeyword(token) || token === 8) && !scanner.hasPrecedingLineBreak();
}
function isDeclaration() {
while (true) {
@@ -8555,7 +8573,7 @@ var ts;
case 87:
nextToken();
return token === 9 || token === 37 ||
- token === 15 || isIdentifierOrKeyword();
+ token === 15 || ts.tokenIsIdentifierOrKeyword(token);
case 80:
nextToken();
if (token === 55 || token === 37 ||
@@ -9042,7 +9060,7 @@ var ts;
if (isIndexSignature()) {
return parseIndexSignatureDeclaration(fullStart, decorators, modifiers);
}
- if (isIdentifierOrKeyword() ||
+ if (ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 ||
token === 8 ||
token === 37 ||
@@ -9170,12 +9188,13 @@ var ts;
}
function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) {
var node = createNode(216, fullStart);
+ var namespaceFlag = flags & 131072;
node.decorators = decorators;
setModifiers(node, modifiers);
node.flags |= flags;
node.name = parseIdentifier();
node.body = parseOptional(21)
- ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1)
+ ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag)
: parseModuleBlock();
return finishNode(node);
}
@@ -9435,7 +9454,7 @@ var ts;
case 95:
return true;
}
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
JSDocParser.isJSDocType = isJSDocType;
function parseJSDocTypeExpressionForTests(content, start, length) {
@@ -10955,7 +10974,7 @@ var ts;
var moduleReferenceLiteral = moduleReferenceExpression;
var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName);
var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text);
- if (!moduleName) {
+ if (moduleName === undefined) {
return;
}
var isRelative = isExternalModuleNameRelative(moduleName);
@@ -10965,8 +10984,8 @@ var ts;
return symbol;
}
}
- var fileName = ts.getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text);
- var sourceFile = fileName && host.getSourceFile(fileName);
+ var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text);
+ var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName);
if (sourceFile) {
if (sourceFile.symbol) {
return sourceFile.symbol;
@@ -12086,52 +12105,52 @@ var ts;
return checkIdentifier(declaration.name);
}
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, false);
}
return undefined;
}
- function getTypeFromBindingElement(element) {
+ function getTypeFromBindingElement(element, includePatternInType) {
if (element.initializer) {
return getWidenedType(checkExpressionCached(element.initializer));
}
if (ts.isBindingPattern(element.name)) {
- return getTypeFromBindingPattern(element.name);
+ return getTypeFromBindingPattern(element.name, includePatternInType);
}
return anyType;
}
- function getTypeFromObjectBindingPattern(pattern) {
+ function getTypeFromObjectBindingPattern(pattern, includePatternInType) {
var members = {};
ts.forEach(pattern.elements, function (e) {
var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0);
var name = e.propertyName || e.name;
var symbol = createSymbol(flags, name.text);
- symbol.type = getTypeFromBindingElement(e);
+ symbol.type = getTypeFromBindingElement(e, includePatternInType);
+ symbol.bindingElement = e;
members[symbol.name] = symbol;
});
- return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ if (includePatternInType) {
+ result.pattern = pattern;
+ }
+ return result;
}
- function getTypeFromArrayBindingPattern(pattern) {
- var hasSpreadElement = false;
- var elementTypes = [];
- ts.forEach(pattern.elements, function (e) {
- elementTypes.push(e.kind === 185 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e));
- if (e.dotDotDotToken) {
- hasSpreadElement = true;
- }
- });
- if (!elementTypes.length) {
+ function getTypeFromArrayBindingPattern(pattern, includePatternInType) {
+ var elements = pattern.elements;
+ if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) {
return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType;
}
- else if (hasSpreadElement) {
- var unionOfElements = getUnionType(elementTypes);
- return languageVersion >= 2 ? createIterableType(unionOfElements) : createArrayType(unionOfElements);
+ var elementTypes = ts.map(elements, function (e) { return e.kind === 185 ? anyType : getTypeFromBindingElement(e, includePatternInType); });
+ if (includePatternInType) {
+ var result = createNewTupleType(elementTypes);
+ result.pattern = pattern;
+ return result;
}
return createTupleType(elementTypes);
}
- function getTypeFromBindingPattern(pattern) {
+ function getTypeFromBindingPattern(pattern, includePatternInType) {
return pattern.kind === 159
- ? getTypeFromObjectBindingPattern(pattern)
- : getTypeFromArrayBindingPattern(pattern);
+ ? getTypeFromObjectBindingPattern(pattern, includePatternInType)
+ : getTypeFromArrayBindingPattern(pattern, includePatternInType);
}
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
var type = getTypeForVariableLikeDeclaration(declaration);
@@ -13453,11 +13472,11 @@ var ts;
}
function createTupleType(elementTypes) {
var id = getTypeListId(elementTypes);
- var type = tupleTypes[id];
- if (!type) {
- type = tupleTypes[id] = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes));
- type.elementTypes = elementTypes;
- }
+ return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes));
+ }
+ function createNewTupleType(elementTypes) {
+ var type = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes));
+ type.elementTypes = elementTypes;
return type;
}
function getTypeFromTupleTypeNode(node) {
@@ -13945,7 +13964,9 @@ var ts;
}
return 0;
}
- source = getRegularTypeOfObjectLiteral(source);
+ if (target.flags & 49152) {
+ source = getRegularTypeOfObjectLiteral(source);
+ }
}
var saveErrorInfo = errorInfo;
if (source.flags & 16384) {
@@ -14049,6 +14070,7 @@ var ts;
var prop = _a[_i];
if (!isKnownProperty(target, prop.name)) {
if (reportErrors) {
+ errorNode = prop.valueDeclaration;
reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target));
}
return true;
@@ -14343,8 +14365,8 @@ var ts;
return result;
function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) {
if (sourceSig && targetSig) {
- var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212);
- var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212);
+ var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol);
+ var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol);
if (!sourceDecl) {
return -1;
}
@@ -14352,8 +14374,8 @@ var ts;
var targetErasedSignature = getErasedSignature(targetSig);
var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
- var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212);
- var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212);
+ var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol);
+ var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol);
var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256;
var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256;
if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) {
@@ -14676,6 +14698,7 @@ var ts;
regularType.constructSignatures = type.constructSignatures;
regularType.stringIndexType = type.stringIndexType;
regularType.numberIndexType = type.numberIndexType;
+ type.regularType = regularType;
}
return regularType;
}
@@ -15572,7 +15595,7 @@ var ts;
}
}
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, true);
}
}
return undefined;
@@ -15864,11 +15887,12 @@ var ts;
var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false);
}
+ function hasDefaultValue(node) {
+ return (node.kind === 161 && !!node.initializer) ||
+ (node.kind === 179 && node.operatorToken.kind === 55);
+ }
function checkArrayLiteral(node, contextualMapper) {
var elements = node.elements;
- if (!elements.length) {
- return createArrayType(undefinedType);
- }
var hasSpreadElement = false;
var elementTypes = [];
var inDestructuringPattern = isAssignmentTarget(node);
@@ -15889,12 +15913,35 @@ var ts;
hasSpreadElement = hasSpreadElement || e.kind === 183;
}
if (!hasSpreadElement) {
+ if (inDestructuringPattern && elementTypes.length) {
+ var type = createNewTupleType(elementTypes);
+ type.pattern = node;
+ return type;
+ }
var contextualType = getContextualType(node);
- if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) {
- return createTupleType(elementTypes);
+ if (contextualType && contextualTypeIsTupleLikeType(contextualType)) {
+ var pattern = contextualType.pattern;
+ if (pattern && (pattern.kind === 160 || pattern.kind === 162)) {
+ var patternElements = pattern.elements;
+ for (var i = elementTypes.length; i < patternElements.length; i++) {
+ var patternElement = patternElements[i];
+ if (hasDefaultValue(patternElement)) {
+ elementTypes.push(contextualType.elementTypes[i]);
+ }
+ else {
+ if (patternElement.kind !== 185) {
+ error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ elementTypes.push(unknownType);
+ }
+ }
+ }
+ if (elementTypes.length) {
+ return createTupleType(elementTypes);
+ }
}
}
- return createArrayType(getUnionType(elementTypes));
+ return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType);
}
function isNumericName(name) {
return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text);
@@ -15926,6 +15973,9 @@ var ts;
var propertiesTable = {};
var propertiesArray = [];
var contextualType = getContextualType(node);
+ var contextualTypeHasPattern = contextualType && contextualType.pattern &&
+ (contextualType.pattern.kind === 159 || contextualType.pattern.kind === 163);
+ var inDestructuringPattern = isAssignmentTarget(node);
var typeFlags = 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var memberDecl = _a[_i];
@@ -15946,6 +15996,20 @@ var ts;
}
typeFlags |= type.flags;
var prop = createSymbol(4 | 67108864 | member.flags, member.name);
+ if (inDestructuringPattern) {
+ if (memberDecl.kind === 243 && hasDefaultValue(memberDecl.initializer)) {
+ prop.flags |= 536870912;
+ }
+ }
+ else if (contextualTypeHasPattern) {
+ var impliedProp = getPropertyOfType(contextualType, member.name);
+ if (impliedProp) {
+ prop.flags |= impliedProp.flags & 536870912;
+ }
+ else if (!compilerOptions.suppressExcessPropertyErrors) {
+ error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
+ }
+ }
prop.declarations = member.declarations;
prop.parent = member.parent;
if (member.valueDeclaration) {
@@ -15964,11 +16028,26 @@ var ts;
}
propertiesArray.push(member);
}
+ if (contextualTypeHasPattern) {
+ for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) {
+ var prop = _c[_b];
+ if (!ts.hasProperty(propertiesTable, prop.name)) {
+ if (!(prop.flags & 536870912)) {
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ propertiesTable[prop.name] = prop;
+ propertiesArray.push(prop);
+ }
+ }
+ }
var stringIndexType = getIndexType(0);
var numberIndexType = getIndexType(1);
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576;
result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064);
+ if (inDestructuringPattern) {
+ result.pattern = node;
+ }
return result;
function getIndexType(kind) {
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
@@ -17052,7 +17131,7 @@ var ts;
if (expressionType === unknownType) {
return resolveErrorCall(node);
}
- var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212);
+ var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol);
if (valueDecl && valueDecl.flags & 256) {
error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name));
return resolveErrorCall(node);
@@ -19718,6 +19797,9 @@ var ts;
function getTargetSymbol(s) {
return s.flags & 16777216 ? getSymbolLinks(s).target : s;
}
+ function getClassLikeDeclarationOfSymbol(symbol) {
+ return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; });
+ }
function checkKindsOfPropertyMemberOverrides(type, baseType) {
// TypeScript 1.0 spec (April 2014): 8.2.3
// A derived class inherits all members from its base class it doesn't override.
@@ -19744,9 +19826,14 @@ var ts;
ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
if (derived) {
if (derived === base) {
- var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212);
+ var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol);
if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) {
- error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ if (derivedClassDecl.kind === 184) {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
+ }
+ else {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ }
}
}
else {
@@ -20970,7 +21057,10 @@ var ts;
var symbols = [];
var name_15 = symbol.name;
ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) {
- symbols.push(getPropertyOfType(t, name_15));
+ var symbol = getPropertyOfType(t, name_15);
+ if (symbol) {
+ symbols.push(symbol);
+ }
});
return symbols;
}
@@ -23679,6 +23769,7 @@ var ts;
var scopeEmitStart = function (scopeDeclaration, scopeName) { };
var scopeEmitEnd = function () { };
var sourceMapData;
+ var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker;
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
initializeEmitterWithSourceMaps();
}
@@ -24505,8 +24596,10 @@ var ts;
function jsxEmitPreserve(node) {
function emitJsxAttribute(node) {
emit(node.name);
- write("=");
- emit(node.initializer);
+ if (node.initializer) {
+ write("=");
+ emit(node.initializer);
+ }
}
function emitJsxSpreadAttribute(node) {
write("{...");
@@ -25345,7 +25438,8 @@ var ts;
operand.kind !== 178 &&
operand.kind !== 167 &&
!(operand.kind === 166 && node.parent.kind === 167) &&
- !(operand.kind === 171 && node.parent.kind === 166)) {
+ !(operand.kind === 171 && node.parent.kind === 166) &&
+ !(operand.kind === 8 && node.parent.kind === 164)) {
emit(operand);
return;
}
@@ -25978,6 +26072,9 @@ var ts;
}
function emitExportSpecifierInSystemModule(specifier) {
ts.Debug.assert(compilerOptions.module === 4);
+ if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) {
+ return;
+ }
writeLine();
emitStart(specifier.name);
write(exportFunctionForFile + "(\"");
@@ -26029,19 +26126,19 @@ var ts;
write(")");
}
}
- function ensureIdentifier(expr) {
- if (expr.kind !== 67) {
- var identifier = createTempVariable(0);
- if (!canDefineTempVariablesInPlace) {
- recordTempDeclaration(identifier);
- }
- emitAssignment(identifier, expr);
- expr = identifier;
+ function ensureIdentifier(expr, reuseIdentifierExpressions) {
+ if (expr.kind === 67 && reuseIdentifierExpressions) {
+ return expr;
}
- return expr;
+ var identifier = createTempVariable(0);
+ if (!canDefineTempVariablesInPlace) {
+ recordTempDeclaration(identifier);
+ }
+ emitAssignment(identifier, expr);
+ return identifier;
}
function createDefaultValueCheck(value, defaultValue) {
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, true);
var equals = ts.createSynthesizedNode(179);
equals.left = value;
equals.operatorToken = ts.createSynthesizedNode(32);
@@ -26082,7 +26179,7 @@ var ts;
function emitObjectLiteralAssignment(target, value) {
var properties = target.properties;
if (properties.length !== 1) {
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, true);
}
for (var _a = 0; _a < properties.length; _a++) {
var p = properties[_a];
@@ -26095,7 +26192,7 @@ var ts;
function emitArrayLiteralAssignment(target, value) {
var elements = target.elements;
if (elements.length !== 1) {
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, true);
}
for (var i = 0; i < elements.length; i++) {
var e = elements[i];
@@ -26137,7 +26234,7 @@ var ts;
if (root.parent.kind !== 170) {
write("(");
}
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, true);
emitDestructuringAssignment(target, value);
write(", ");
emit(value);
@@ -26156,10 +26253,11 @@ var ts;
if (ts.isBindingPattern(target.name)) {
var pattern = target.name;
var elements = pattern.elements;
- if (elements.length !== 1) {
- value = ensureIdentifier(value);
+ var numElements = elements.length;
+ if (numElements !== 1) {
+ value = ensureIdentifier(value, numElements !== 0);
}
- for (var i = 0; i < elements.length; i++) {
+ for (var i = 0; i < numElements; i++) {
var element = elements[i];
if (pattern.kind === 159) {
var propName = element.propertyName || element.name;
@@ -26169,7 +26267,7 @@ var ts;
if (!element.dotDotDotToken) {
emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i)));
}
- else if (i === elements.length - 1) {
+ else if (i === numElements - 1) {
emitBindingElement(element, createSliceCall(value, i));
}
}
@@ -26409,7 +26507,7 @@ var ts;
}
function emitFunctionDeclaration(node) {
if (ts.nodeIsMissing(node.body)) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
if (node.kind !== 141 && node.kind !== 140 &&
node.parent && node.parent.kind !== 243 &&
@@ -26727,7 +26825,7 @@ var ts;
}
else if (member.kind === 141 || node.kind === 140) {
if (!member.body) {
- return emitOnlyPinnedOrTripleSlashComments(member);
+ return emitCommentsOnNotEmittedNode(member);
}
writeLine();
emitLeadingComments(member);
@@ -26793,7 +26891,7 @@ var ts;
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
if ((member.kind === 141 || node.kind === 140) && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
else if (member.kind === 141 ||
member.kind === 143 ||
@@ -26840,7 +26938,7 @@ var ts;
var hasInstancePropertyWithInitializer = false;
ts.forEach(node.members, function (member) {
if (member.kind === 142 && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) {
hasInstancePropertyWithInitializer = true;
@@ -27289,50 +27387,49 @@ var ts;
write("void 0");
}
function emitSerializedTypeNode(node) {
- if (!node) {
- return;
- }
- switch (node.kind) {
- case 101:
- write("void 0");
- return;
- case 158:
- emitSerializedTypeNode(node.type);
- return;
- case 150:
- case 151:
- write("Function");
- return;
- case 154:
- case 155:
- write("Array");
- return;
- case 148:
- case 118:
- write("Boolean");
- return;
- case 128:
- case 9:
- write("String");
- return;
- case 126:
- write("Number");
- return;
- case 129:
- write("Symbol");
- return;
- case 149:
- emitSerializedTypeReferenceNode(node);
- return;
- case 152:
- case 153:
- case 156:
- case 157:
- case 115:
- break;
- default:
- ts.Debug.fail("Cannot serialize unexpected type node.");
- break;
+ if (node) {
+ switch (node.kind) {
+ case 101:
+ write("void 0");
+ return;
+ case 158:
+ emitSerializedTypeNode(node.type);
+ return;
+ case 150:
+ case 151:
+ write("Function");
+ return;
+ case 154:
+ case 155:
+ write("Array");
+ return;
+ case 148:
+ case 118:
+ write("Boolean");
+ return;
+ case 128:
+ case 9:
+ write("String");
+ return;
+ case 126:
+ write("Number");
+ return;
+ case 129:
+ write("Symbol");
+ return;
+ case 149:
+ emitSerializedTypeReferenceNode(node);
+ return;
+ case 152:
+ case 153:
+ case 156:
+ case 157:
+ case 115:
+ break;
+ default:
+ ts.Debug.fail("Cannot serialize unexpected type node.");
+ break;
+ }
}
write("Object");
}
@@ -27471,7 +27568,7 @@ var ts;
return argumentsWritten;
}
function emitInterfaceDeclaration(node) {
- emitOnlyPinnedOrTripleSlashComments(node);
+ emitCommentsOnNotEmittedNode(node);
}
function shouldEmitEnumDeclaration(node) {
var isConstEnum = ts.isConst(node);
@@ -27578,7 +27675,7 @@ var ts;
function emitModuleDeclaration(node) {
var shouldEmit = shouldEmitModuleDeclaration(node);
if (!shouldEmit) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node);
var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node);
@@ -28246,7 +28343,7 @@ var ts;
}
return;
}
- if (ts.isInternalModuleImportEqualsDeclaration(node)) {
+ if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) {
if (!hoistedVars) {
hoistedVars = [];
}
@@ -28716,7 +28813,7 @@ var ts;
function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) {
if (node) {
if (node.flags & 2) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
if (isSpecializedCommentHandling(node)) {
return emitNodeWithoutSourceMap(node);
@@ -28948,14 +29045,20 @@ var ts;
}
return leadingComments;
}
- function filterComments(ranges, onlyPinnedOrTripleSlashComments) {
- if (ranges && onlyPinnedOrTripleSlashComments) {
- ranges = ts.filter(ranges, isPinnedOrTripleSlashComment);
- if (ranges.length === 0) {
- return undefined;
- }
+ function isPinnedComments(comment) {
+ return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 33;
+ }
+ function isTripleSlashComment(comment) {
+ if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 &&
+ comment.pos + 2 < comment.end &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) {
+ var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end);
+ return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
+ textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ?
+ true : false;
}
- return ranges;
+ return false;
}
function getLeadingCommentsToEmit(node) {
if (node.parent) {
@@ -28976,26 +29079,46 @@ var ts;
}
}
}
- function emitOnlyPinnedOrTripleSlashComments(node) {
- emitLeadingCommentsWorker(node, true);
+ function emitCommentsOnNotEmittedNode(node) {
+ emitLeadingCommentsWorker(node, false);
}
function emitLeadingComments(node) {
- return emitLeadingCommentsWorker(node, compilerOptions.removeComments);
+ return emitLeadingCommentsWorker(node, true);
}
- function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) {
- var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments);
+ function emitLeadingCommentsWorker(node, isEmittedNode) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var leadingComments;
+ if (isEmittedNode) {
+ leadingComments = getLeadingCommentsToEmit(node);
+ }
+ else {
+ if (node.pos === 0) {
+ leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment);
+ }
+ }
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment);
}
function emitTrailingComments(node) {
- var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments);
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var trailingComments = getTrailingCommentsToEmit(node);
ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment);
}
function emitTrailingCommentsOfPosition(pos) {
- var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), compilerOptions.removeComments);
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos);
ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment);
}
- function emitLeadingCommentsOfPosition(pos) {
+ function emitLeadingCommentsOfPositionWorker(pos) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
var leadingComments;
if (hasDetachedComments(pos)) {
leadingComments = getLeadingCommentsWithoutDetachedComments();
@@ -29003,12 +29126,19 @@ var ts;
else {
leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos);
}
- leadingComments = filterComments(leadingComments, compilerOptions.removeComments);
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment);
}
function emitDetachedComments(node) {
- var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ var leadingComments;
+ if (compilerOptions.removeComments) {
+ if (node.pos === 0) {
+ leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments);
+ }
+ }
+ else {
+ leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ }
if (leadingComments) {
var detachedComments = [];
var lastComment;
@@ -29046,17 +29176,6 @@ var ts;
write(shebang);
}
}
- function isPinnedOrTripleSlashComment(comment) {
- if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) {
- return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33;
- }
- else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 &&
- comment.pos + 2 < comment.end &&
- currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 &&
- currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) {
- return true;
- }
- }
}
function emitFile(jsFilePath, sourceFile) {
emitJavaScript(jsFilePath, sourceFile);
@@ -29332,7 +29451,7 @@ var ts;
ts.ioReadTime = 0;
ts.ioWriteTime = 0;
var emptyArray = [];
- ts.version = "1.6.0";
+ ts.version = "1.7.0";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@@ -29372,10 +29491,12 @@ var ts;
var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host);
if (resolvedFileName) {
- return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations };
}
resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host);
- return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
+ return resolvedFileName
+ ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }
+ : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
}
else {
return loadModuleFromNodeModules(moduleName, containingDirectory, host);
@@ -29433,11 +29554,11 @@ var ts;
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName));
var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host);
if (result) {
- return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations };
}
result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host);
if (result) {
- return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations };
}
}
var parentPath = ts.getDirectoryPath(directory);
@@ -29446,36 +29567,15 @@ var ts;
}
directory = parentPath;
}
- return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
}
- function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) {
- ts.Debug.assert(baseUrl !== undefined);
- var normalizedModuleName = ts.normalizeSlashes(moduleName);
- var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile);
- var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName));
- var failedLookupLocations = [];
- return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
- function tryLoadFile(location) {
- if (host.fileExists(location)) {
- return { resolvedFileName: location, failedLookupLocations: failedLookupLocations };
- }
- else {
- failedLookupLocations.push(location);
- return undefined;
- }
- }
- }
- ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver;
function nameStartsWithDotSlashOrDotDotSlash(name) {
var i = name.lastIndexOf("./", 1);
return i === 0 || (i === 1 && name.charCodeAt(0) === 46);
}
- function useBaseUrl(moduleName) {
- return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName);
- }
function classicNameResolver(moduleName, containingFile, compilerOptions, host) {
if (moduleName.indexOf('!') != -1) {
- return { resolvedFileName: undefined, failedLookupLocations: [] };
+ return { resolvedModule: undefined, failedLookupLocations: [] };
}
var searchPath = ts.getDirectoryPath(containingFile);
var searchName;
@@ -29504,7 +29604,9 @@ var ts;
}
searchPath = parentPath;
}
- return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations };
+ return referencedSourceFile
+ ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations }
+ : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
}
ts.classicNameResolver = classicNameResolver;
ts.defaultInitCompilerOptions = {
@@ -29617,7 +29719,8 @@ var ts;
function createProgram(rootNames, options, host, oldProgram) {
var program;
var files = [];
- var diagnostics = ts.createDiagnosticCollection();
+ var fileProcessingDiagnostics = ts.createDiagnosticCollection();
+ var programDiagnostics = ts.createDiagnosticCollection();
var commonSourceDirectory;
var diagnosticsProducingTypeChecker;
var noDiagnosticsTypeChecker;
@@ -29625,8 +29728,9 @@ var ts;
var skipDefaultLib = options.noLib;
var start = new Date().getTime();
host = host || createCompilerHost(options);
- var resolveModuleNamesWorker = host.resolveModuleNames ||
- (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedFileName; }); });
+ var resolveModuleNamesWorker = host.resolveModuleNames
+ ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); })
+ : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); });
var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); });
if (oldProgram) {
var oldOptions = oldProgram.getCompilerOptions();
@@ -29666,7 +29770,8 @@ var ts;
getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
- getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }
+ getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
+ getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }
};
return program;
function getClassifiableNames() {
@@ -29690,6 +29795,7 @@ var ts;
return false;
}
var newSourceFiles = [];
+ var modifiedSourceFiles = [];
for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) {
var oldSourceFile = _a[_i];
var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target);
@@ -29711,13 +29817,20 @@ var ts;
var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; });
var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName);
for (var i = 0; i < moduleNames.length; ++i) {
- var oldResolution = ts.getResolvedModuleFileName(oldSourceFile, moduleNames[i]);
- if (oldResolution !== resolutions[i]) {
+ var newResolution = resolutions[i];
+ var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]);
+ var resolutionChanged = oldResolution
+ ? !newResolution ||
+ oldResolution.resolvedFileName !== newResolution.resolvedFileName ||
+ !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport
+ : newResolution;
+ if (resolutionChanged) {
return false;
}
}
}
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
+ modifiedSourceFiles.push(newSourceFile);
}
else {
newSourceFile = oldSourceFile;
@@ -29729,6 +29842,11 @@ var ts;
filesByName.set(file.fileName, file);
}
files = newSourceFiles;
+ fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
+ for (var _c = 0; _c < modifiedSourceFiles.length; _c++) {
+ var modifiedFile = modifiedSourceFiles[_c];
+ fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile);
+ }
oldProgram.structureIsReused = true;
return true;
}
@@ -29810,8 +29928,9 @@ var ts;
ts.Debug.assert(!!sourceFile.bindDiagnostics);
var bindDiagnostics = sourceFile.bindDiagnostics;
var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken);
- var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
- return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics);
+ var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
+ var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
+ return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile);
});
}
function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) {
@@ -29825,7 +29944,8 @@ var ts;
}
function getOptionsDiagnostics() {
var allDiagnostics = [];
- ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
+ ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics());
+ ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics());
return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
}
function getGlobalDiagnostics() {
@@ -29915,10 +30035,10 @@ var ts;
}
if (diagnostic) {
if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) {
- diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument)));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument)));
}
else {
- diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument)));
+ fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument)));
}
}
}
@@ -29935,10 +30055,10 @@ var ts;
}
var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) {
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
- diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
}
else {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
+ fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
}
});
filesByName.set(canonicalName, file);
@@ -29966,10 +30086,10 @@ var ts;
var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName;
if (canonicalName !== sourceFileName) {
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
- diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
}
else {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
+ fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
}
}
}
@@ -29990,9 +30110,23 @@ var ts;
var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName);
for (var i = 0; i < file.imports.length; ++i) {
var resolution = resolutions[i];
- ts.setResolvedModuleName(file, moduleNames[i], resolution);
+ ts.setResolvedModule(file, moduleNames[i], resolution);
if (resolution && !options.noResolve) {
- findModuleSourceFile(resolution, file.imports[i]);
+ var importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]);
+ if (importedFile && resolution.isExternalLibraryImport) {
+ if (!ts.isExternalModule(importedFile)) {
+ var start_2 = ts.getTokenPosOfNode(file.imports[i], file);
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
+ }
+ else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) {
+ var start_3 = ts.getTokenPosOfNode(file.imports[i], file);
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_3, file.imports[i].end - start_3, ts.Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition));
+ }
+ else if (importedFile.referencedFiles.length) {
+ var firstRef = importedFile.referencedFiles[0];
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition));
+ }
+ }
}
}
}
@@ -30001,7 +30135,7 @@ var ts;
}
return;
function findModuleSourceFile(fileName, nameLiteral) {
- return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end);
+ return findSourceFile(fileName, false, file, ts.skipTrivia(file.text, nameLiteral.pos), nameLiteral.end);
}
}
function computeCommonSourceDirectory(sourceFiles) {
@@ -30020,7 +30154,7 @@ var ts;
for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) {
if (commonPathComponents[i] !== sourcePathComponents[i]) {
if (i === 0) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
return;
}
commonPathComponents.length = i;
@@ -30043,7 +30177,7 @@ var ts;
if (!ts.isDeclarationFile(sourceFile)) {
var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
allFilesBelongToPath = false;
}
}
@@ -30054,43 +30188,43 @@ var ts;
function verifyCompilerOptions() {
if (options.isolatedModules) {
if (options.declaration) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules"));
}
if (options.noEmitOnError) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules"));
}
if (options.out) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"));
}
if (options.outFile) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules"));
}
}
if (options.inlineSourceMap) {
if (options.sourceMap) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap"));
}
if (options.mapRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
}
if (options.sourceRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
}
}
if (options.inlineSources) {
if (!options.sourceMap && !options.inlineSourceMap) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
}
}
if (options.out && options.outFile) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
}
if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) {
if (options.mapRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
}
if (options.sourceRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
}
return;
}
@@ -30099,20 +30233,20 @@ var ts;
var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; });
if (options.isolatedModules) {
if (!options.module && languageVersion < 2) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
}
var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; });
if (firstNonExternalModuleSourceFile) {
var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
- diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) {
var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
- diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
}
if (options.module && languageVersion >= 2) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
}
if (options.outDir ||
options.sourceRoot ||
@@ -30130,25 +30264,25 @@ var ts;
}
if (options.noEmit) {
if (options.out) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));
}
if (options.outFile) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile"));
}
if (options.outDir) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir"));
}
if (options.declaration) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
}
}
if (options.emitDecoratorMetadata &&
!options.experimentalDecorators) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
}
if (options.experimentalAsyncFunctions &&
options.target !== 2) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
}
}
}
@@ -30397,8 +30531,8 @@ var ts;
"node": 2,
"classic": 1
},
- experimental: true,
- description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
+ description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
+ error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic
}
];
var optionNameMapCache;
@@ -30512,10 +30646,10 @@ var ts;
}
}
ts.parseCommandLine = parseCommandLine;
- function readConfigFile(fileName) {
+ function readConfigFile(fileName, readFile) {
var text = "";
try {
- text = ts.sys.readFile(fileName);
+ text = readFile(fileName);
}
catch (e) {
return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
@@ -30784,7 +30918,7 @@ var ts;
function performCompilation() {
if (!cachedProgram) {
if (configFileName) {
- var result = ts.readConfigFile(configFileName);
+ var result = ts.readConfigFile(configFileName, ts.sys.readFile);
if (result.error) {
reportDiagnostic(result.error);
return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
diff --git a/lib/tsserver.js b/lib/tsserver.js
index 78836160678..875e63028b2 100644
--- a/lib/tsserver.js
+++ b/lib/tsserver.js
@@ -47,7 +47,6 @@ var ts;
})(ts.DiagnosticCategory || (ts.DiagnosticCategory = {}));
var DiagnosticCategory = ts.DiagnosticCategory;
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
function createFileMap(getCanonicalFileName) {
@@ -569,9 +568,6 @@ var ts;
}
ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents;
function getNormalizedPathComponentsOfUrl(url) {
- // Get root length of http://www.website.com/folder1/foler2/
- // In this example the root is: http://www.website.com/
- // normalized path components should be ["http://www.website.com/", "folder1", "folder2"]
var urlLength = url.length;
var rootLength = url.indexOf("://") + "://".length;
while (rootLength < urlLength) {
@@ -731,7 +727,6 @@ var ts;
Debug.fail = fail;
})(Debug = ts.Debug || (ts.Debug = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
ts.sys = (function () {
@@ -1003,7 +998,6 @@ var ts;
}
})();
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
ts.Diagnostics = {
@@ -1248,7 +1242,7 @@ var ts;
Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.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: ts.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: ts.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: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
+ An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.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: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." },
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." },
@@ -1419,6 +1413,7 @@ var ts;
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.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: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." },
await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." },
+ Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." },
JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.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: ts.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: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." },
@@ -1431,6 +1426,10 @@ var ts;
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
+ Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." },
+ Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." },
+ Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." },
+ Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.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: ts.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: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -1564,13 +1563,14 @@ var ts;
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" },
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
+ Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." },
Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" },
Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." },
Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." },
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.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: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
- Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
+ Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." },
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
@@ -1618,10 +1618,12 @@ var ts;
A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }
};
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
+ function tokenIsIdentifierOrKeyword(token) {
+ return token >= 67;
+ }
+ ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
var textToToken = {
"abstract": 113,
"any": 115,
@@ -1869,16 +1871,6 @@ var ts;
}
ts.isWhiteSpace = isWhiteSpace;
function isLineBreak(ch) {
- // ES5 7.3:
- // The ECMAScript line terminator characters are listed in Table 3.
- // Table 3: Line Terminator Characters
- // Code Unit Value Name Formal Name
- // \u000A Line Feed
- // \u000D Carriage Return
- // \u2028 Line separator
- // \u2029 Paragraph separator
- // Only the characters in Table 3 are treated as line terminators. Other new line or line
- // breaking characters are treated as white space but not as line terminators.
return ch === 10 ||
ch === 13 ||
ch === 8232 ||
@@ -2913,7 +2905,7 @@ var ts;
return token = 234;
}
function scanJsxIdentifier() {
- if (token === 67) {
+ if (tokenIsIdentifierOrKeyword(token)) {
var firstCharPosition = pos;
while (pos < end) {
var ch = text.charCodeAt(pos);
@@ -2980,10 +2972,6 @@ var ts;
}
ts.createScanner = createScanner;
})(ts || (ts = {}));
-///
-///
-///
-///
var ts;
(function (ts) {
ts.optionDeclarations = [
@@ -3223,8 +3211,8 @@ var ts;
"node": 2,
"classic": 1
},
- experimental: true,
- description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
+ description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
+ error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic
}
];
var optionNameMapCache;
@@ -3338,10 +3326,10 @@ var ts;
}
}
ts.parseCommandLine = parseCommandLine;
- function readConfigFile(fileName) {
+ function readConfigFile(fileName, readFile) {
var text = "";
try {
- text = ts.sys.readFile(fileName);
+ text = readFile(fileName);
}
catch (e) {
return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
@@ -3442,7 +3430,6 @@ var ts;
}
ts.parseConfigFile = parseConfigFile;
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
function getDeclarationOfKind(symbol, kind) {
@@ -3507,21 +3494,21 @@ var ts;
return true;
}
ts.arrayIsEqualTo = arrayIsEqualTo;
- function hasResolvedModuleName(sourceFile, moduleNameText) {
+ function hasResolvedModule(sourceFile, moduleNameText) {
return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText);
}
- ts.hasResolvedModuleName = hasResolvedModuleName;
- function getResolvedModuleFileName(sourceFile, moduleNameText) {
- return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined;
+ ts.hasResolvedModule = hasResolvedModule;
+ function getResolvedModule(sourceFile, moduleNameText) {
+ return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined;
}
- ts.getResolvedModuleFileName = getResolvedModuleFileName;
- function setResolvedModuleName(sourceFile, moduleNameText, resolvedFileName) {
+ ts.getResolvedModule = getResolvedModule;
+ function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
if (!sourceFile.resolvedModules) {
sourceFile.resolvedModules = {};
}
- sourceFile.resolvedModules[moduleNameText] = resolvedFileName;
+ sourceFile.resolvedModules[moduleNameText] = resolvedModule;
}
- ts.setResolvedModuleName = setResolvedModuleName;
+ ts.setResolvedModule = setResolvedModule;
function containsParseError(node) {
aggregateChildData(node);
return (node.parserContextFlags & 64) !== 0;
@@ -3777,6 +3764,7 @@ var ts;
}
ts.getJsDocComments = getJsDocComments;
ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/;
+ ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/;
function isTypeNode(node) {
if (149 <= node.kind && node.kind <= 158) {
return true;
@@ -4723,11 +4711,21 @@ var ts;
add: add,
getGlobalDiagnostics: getGlobalDiagnostics,
getDiagnostics: getDiagnostics,
- getModificationCount: getModificationCount
+ getModificationCount: getModificationCount,
+ reattachFileDiagnostics: reattachFileDiagnostics
};
function getModificationCount() {
return modificationCount;
}
+ function reattachFileDiagnostics(newFile) {
+ if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) {
+ return;
+ }
+ for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) {
+ var diagnostic = _a[_i];
+ diagnostic.file = newFile;
+ }
+ }
function add(diagnostic) {
var diagnostics;
if (diagnostic.file) {
@@ -5380,8 +5378,6 @@ var ts;
}
ts.getTypeParameterOwner = getTypeParameterOwner;
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
var nodeConstructors = new Array(270);
@@ -5872,10 +5868,6 @@ var ts;
}
}
function fixupParentReferences(sourceFile) {
- // normally parent references are set during binding. However, for clients that only need
- // a syntax tree, and no semantic features, then the binding process is an unnecessary
- // overhead. This functions allows us to set all the parents, without all the expense of
- // binding.
var parent = sourceFile;
forEachChild(sourceFile, visitNode);
return;
@@ -6169,10 +6161,10 @@ var ts;
return createIdentifier(isIdentifier(), diagnosticMessage);
}
function parseIdentifierName() {
- return createIdentifier(isIdentifierOrKeyword());
+ return createIdentifier(ts.tokenIsIdentifierOrKeyword(token));
}
function isLiteralPropertyName() {
- return isIdentifierOrKeyword() ||
+ return ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 ||
token === 8;
}
@@ -6192,7 +6184,7 @@ var ts;
return parsePropertyNameWorker(false);
}
function isSimplePropertyName() {
- return token === 9 || token === 8 || isIdentifierOrKeyword();
+ return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token);
}
function parseComputedPropertyName() {
var node = createNode(134);
@@ -6283,9 +6275,9 @@ var ts;
case 20:
return isHeritageClause();
case 21:
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
case 13:
- return isIdentifierOrKeyword() || token === 15;
+ return ts.tokenIsIdentifierOrKeyword(token) || token === 15;
case 14:
return true;
case 22:
@@ -6311,7 +6303,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeyword() {
nextToken();
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
function isHeritageClauseExtendsOrImplementsKeyword() {
if (token === 104 ||
@@ -6679,7 +6671,7 @@ var ts;
return entity;
}
function parseRightSideOfDot(allowIdentifierNames) {
- if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) {
+ if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) {
var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
if (matchesPattern) {
return createMissingNode(67, true, ts.Diagnostics.Identifier_expected);
@@ -6969,7 +6961,7 @@ var ts;
return result;
}
}
- if (isIdentifierOrKeyword()) {
+ if (ts.tokenIsIdentifierOrKeyword(token)) {
return parsePropertyOrMethodSignature();
}
}
@@ -7207,9 +7199,6 @@ var ts;
return allowInAnd(parseExpression);
}
function parseExpression() {
- // Expression[in]:
- // AssignmentExpression[in]
- // Expression[in] , AssignmentExpression[in]
var saveDecoratorContext = inDecoratorContext();
if (saveDecoratorContext) {
setDecoratorContext(false);
@@ -7234,15 +7223,6 @@ var ts;
return parseAssignmentExpressionOrHigher();
}
function parseAssignmentExpressionOrHigher() {
- // AssignmentExpression[in,yield]:
- // 1) ConditionalExpression[?in,?yield]
- // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
- // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield]
- // 4) ArrowFunctionExpression[?in,?yield]
- // 5) [+Yield] YieldExpression[?In]
- //
- // Note: for ease of implementation we treat productions '2' and '3' as the same thing.
- // (i.e. they're both BinaryExpressions with an assignment operator in it).
if (isYieldExpression()) {
return parseYieldExpression();
}
@@ -8211,8 +8191,6 @@ var ts;
return finishNode(node);
}
function parseThrowStatement() {
- // ThrowStatement[Yield] :
- // throw [no LineTerminator here]Expression[In, ?Yield];
var node = createNode(206);
parseExpected(96);
node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression);
@@ -8262,12 +8240,9 @@ var ts;
return finishNode(expressionStatement);
}
}
- function isIdentifierOrKeyword() {
- return token >= 67;
- }
function nextTokenIsIdentifierOrKeywordOnSameLine() {
nextToken();
- return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak();
+ return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak();
}
function nextTokenIsFunctionKeywordOnSameLine() {
nextToken();
@@ -8275,7 +8250,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() {
nextToken();
- return (isIdentifierOrKeyword() || token === 8) && !scanner.hasPrecedingLineBreak();
+ return (ts.tokenIsIdentifierOrKeyword(token) || token === 8) && !scanner.hasPrecedingLineBreak();
}
function isDeclaration() {
while (true) {
@@ -8303,7 +8278,7 @@ var ts;
case 87:
nextToken();
return token === 9 || token === 37 ||
- token === 15 || isIdentifierOrKeyword();
+ token === 15 || ts.tokenIsIdentifierOrKeyword(token);
case 80:
nextToken();
if (token === 55 || token === 37 ||
@@ -8790,7 +8765,7 @@ var ts;
if (isIndexSignature()) {
return parseIndexSignatureDeclaration(fullStart, decorators, modifiers);
}
- if (isIdentifierOrKeyword() ||
+ if (ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 ||
token === 8 ||
token === 37 ||
@@ -8827,8 +8802,6 @@ var ts;
return finishNode(node);
}
function parseHeritageClauses(isClassHeritageClause) {
- // ClassTail[Yield,Await] : (Modified) See 14.5
- // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
if (isHeritageClause()) {
return parseList(20, parseHeritageClause);
}
@@ -8918,12 +8891,13 @@ var ts;
}
function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) {
var node = createNode(216, fullStart);
+ var namespaceFlag = flags & 131072;
node.decorators = decorators;
setModifiers(node, modifiers);
node.flags |= flags;
node.name = parseIdentifier();
node.body = parseOptional(21)
- ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1)
+ ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag)
: parseModuleBlock();
return finishNode(node);
}
@@ -8994,12 +8968,6 @@ var ts;
return finishNode(importDeclaration);
}
function parseImportClause(identifier, fullStart) {
- // ImportClause:
- // ImportedDefaultBinding
- // NameSpaceImport
- // NamedImports
- // ImportedDefaultBinding, NameSpaceImport
- // ImportedDefaultBinding, NamedImports
var importClause = createNode(221, fullStart);
if (identifier) {
importClause.name = identifier;
@@ -9183,7 +9151,7 @@ var ts;
case 95:
return true;
}
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
JSDocParser.isJSDocType = isJSDocType;
function parseJSDocTypeExpressionForTests(content, start, length) {
@@ -9956,7 +9924,6 @@ var ts;
}
})(IncrementalParser || (IncrementalParser = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
ts.bindTime = 0;
@@ -10670,7 +10637,6 @@ var ts;
}
}
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var nextSymbolId = 1;
@@ -11417,7 +11383,7 @@ var ts;
var moduleReferenceLiteral = moduleReferenceExpression;
var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName);
var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text);
- if (!moduleName) {
+ if (moduleName === undefined) {
return;
}
var isRelative = isExternalModuleNameRelative(moduleName);
@@ -11427,8 +11393,8 @@ var ts;
return symbol;
}
}
- var fileName = ts.getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text);
- var sourceFile = fileName && host.getSourceFile(fileName);
+ var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text);
+ var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName);
if (sourceFile) {
if (sourceFile.symbol) {
return sourceFile.symbol;
@@ -12548,52 +12514,52 @@ var ts;
return checkIdentifier(declaration.name);
}
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, false);
}
return undefined;
}
- function getTypeFromBindingElement(element) {
+ function getTypeFromBindingElement(element, includePatternInType) {
if (element.initializer) {
return getWidenedType(checkExpressionCached(element.initializer));
}
if (ts.isBindingPattern(element.name)) {
- return getTypeFromBindingPattern(element.name);
+ return getTypeFromBindingPattern(element.name, includePatternInType);
}
return anyType;
}
- function getTypeFromObjectBindingPattern(pattern) {
+ function getTypeFromObjectBindingPattern(pattern, includePatternInType) {
var members = {};
ts.forEach(pattern.elements, function (e) {
var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0);
var name = e.propertyName || e.name;
var symbol = createSymbol(flags, name.text);
- symbol.type = getTypeFromBindingElement(e);
+ symbol.type = getTypeFromBindingElement(e, includePatternInType);
+ symbol.bindingElement = e;
members[symbol.name] = symbol;
});
- return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ if (includePatternInType) {
+ result.pattern = pattern;
+ }
+ return result;
}
- function getTypeFromArrayBindingPattern(pattern) {
- var hasSpreadElement = false;
- var elementTypes = [];
- ts.forEach(pattern.elements, function (e) {
- elementTypes.push(e.kind === 185 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e));
- if (e.dotDotDotToken) {
- hasSpreadElement = true;
- }
- });
- if (!elementTypes.length) {
+ function getTypeFromArrayBindingPattern(pattern, includePatternInType) {
+ var elements = pattern.elements;
+ if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) {
return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType;
}
- else if (hasSpreadElement) {
- var unionOfElements = getUnionType(elementTypes);
- return languageVersion >= 2 ? createIterableType(unionOfElements) : createArrayType(unionOfElements);
+ var elementTypes = ts.map(elements, function (e) { return e.kind === 185 ? anyType : getTypeFromBindingElement(e, includePatternInType); });
+ if (includePatternInType) {
+ var result = createNewTupleType(elementTypes);
+ result.pattern = pattern;
+ return result;
}
return createTupleType(elementTypes);
}
- function getTypeFromBindingPattern(pattern) {
+ function getTypeFromBindingPattern(pattern, includePatternInType) {
return pattern.kind === 159
- ? getTypeFromObjectBindingPattern(pattern)
- : getTypeFromArrayBindingPattern(pattern);
+ ? getTypeFromObjectBindingPattern(pattern, includePatternInType)
+ : getTypeFromArrayBindingPattern(pattern, includePatternInType);
}
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
var type = getTypeForVariableLikeDeclaration(declaration);
@@ -13915,11 +13881,11 @@ var ts;
}
function createTupleType(elementTypes) {
var id = getTypeListId(elementTypes);
- var type = tupleTypes[id];
- if (!type) {
- type = tupleTypes[id] = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes));
- type.elementTypes = elementTypes;
- }
+ return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes));
+ }
+ function createNewTupleType(elementTypes) {
+ var type = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes));
+ type.elementTypes = elementTypes;
return type;
}
function getTypeFromTupleTypeNode(node) {
@@ -14407,7 +14373,9 @@ var ts;
}
return 0;
}
- source = getRegularTypeOfObjectLiteral(source);
+ if (target.flags & 49152) {
+ source = getRegularTypeOfObjectLiteral(source);
+ }
}
var saveErrorInfo = errorInfo;
if (source.flags & 16384) {
@@ -14511,6 +14479,7 @@ var ts;
var prop = _a[_i];
if (!isKnownProperty(target, prop.name)) {
if (reportErrors) {
+ errorNode = prop.valueDeclaration;
reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target));
}
return true;
@@ -14805,8 +14774,8 @@ var ts;
return result;
function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) {
if (sourceSig && targetSig) {
- var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212);
- var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212);
+ var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol);
+ var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol);
if (!sourceDecl) {
return -1;
}
@@ -14814,8 +14783,8 @@ var ts;
var targetErasedSignature = getErasedSignature(targetSig);
var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
- var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212);
- var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212);
+ var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol);
+ var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol);
var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256;
var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256;
if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) {
@@ -15138,6 +15107,7 @@ var ts;
regularType.constructSignatures = type.constructSignatures;
regularType.stringIndexType = type.stringIndexType;
regularType.numberIndexType = type.numberIndexType;
+ type.regularType = regularType;
}
return regularType;
}
@@ -16034,7 +16004,7 @@ var ts;
}
}
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, true);
}
}
return undefined;
@@ -16326,11 +16296,12 @@ var ts;
var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false);
}
+ function hasDefaultValue(node) {
+ return (node.kind === 161 && !!node.initializer) ||
+ (node.kind === 179 && node.operatorToken.kind === 55);
+ }
function checkArrayLiteral(node, contextualMapper) {
var elements = node.elements;
- if (!elements.length) {
- return createArrayType(undefinedType);
- }
var hasSpreadElement = false;
var elementTypes = [];
var inDestructuringPattern = isAssignmentTarget(node);
@@ -16351,12 +16322,35 @@ var ts;
hasSpreadElement = hasSpreadElement || e.kind === 183;
}
if (!hasSpreadElement) {
+ if (inDestructuringPattern && elementTypes.length) {
+ var type = createNewTupleType(elementTypes);
+ type.pattern = node;
+ return type;
+ }
var contextualType = getContextualType(node);
- if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) {
- return createTupleType(elementTypes);
+ if (contextualType && contextualTypeIsTupleLikeType(contextualType)) {
+ var pattern = contextualType.pattern;
+ if (pattern && (pattern.kind === 160 || pattern.kind === 162)) {
+ var patternElements = pattern.elements;
+ for (var i = elementTypes.length; i < patternElements.length; i++) {
+ var patternElement = patternElements[i];
+ if (hasDefaultValue(patternElement)) {
+ elementTypes.push(contextualType.elementTypes[i]);
+ }
+ else {
+ if (patternElement.kind !== 185) {
+ error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ elementTypes.push(unknownType);
+ }
+ }
+ }
+ if (elementTypes.length) {
+ return createTupleType(elementTypes);
+ }
}
}
- return createArrayType(getUnionType(elementTypes));
+ return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType);
}
function isNumericName(name) {
return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text);
@@ -16388,6 +16382,9 @@ var ts;
var propertiesTable = {};
var propertiesArray = [];
var contextualType = getContextualType(node);
+ var contextualTypeHasPattern = contextualType && contextualType.pattern &&
+ (contextualType.pattern.kind === 159 || contextualType.pattern.kind === 163);
+ var inDestructuringPattern = isAssignmentTarget(node);
var typeFlags = 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var memberDecl = _a[_i];
@@ -16408,6 +16405,20 @@ var ts;
}
typeFlags |= type.flags;
var prop = createSymbol(4 | 67108864 | member.flags, member.name);
+ if (inDestructuringPattern) {
+ if (memberDecl.kind === 243 && hasDefaultValue(memberDecl.initializer)) {
+ prop.flags |= 536870912;
+ }
+ }
+ else if (contextualTypeHasPattern) {
+ var impliedProp = getPropertyOfType(contextualType, member.name);
+ if (impliedProp) {
+ prop.flags |= impliedProp.flags & 536870912;
+ }
+ else if (!compilerOptions.suppressExcessPropertyErrors) {
+ error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
+ }
+ }
prop.declarations = member.declarations;
prop.parent = member.parent;
if (member.valueDeclaration) {
@@ -16426,11 +16437,26 @@ var ts;
}
propertiesArray.push(member);
}
+ if (contextualTypeHasPattern) {
+ for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) {
+ var prop = _c[_b];
+ if (!ts.hasProperty(propertiesTable, prop.name)) {
+ if (!(prop.flags & 536870912)) {
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ propertiesTable[prop.name] = prop;
+ propertiesArray.push(prop);
+ }
+ }
+ }
var stringIndexType = getIndexType(0);
var numberIndexType = getIndexType(1);
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576;
result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064);
+ if (inDestructuringPattern) {
+ result.pattern = node;
+ }
return result;
function getIndexType(kind) {
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
@@ -17514,7 +17540,7 @@ var ts;
if (expressionType === unknownType) {
return resolveErrorCall(node);
}
- var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212);
+ var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol);
if (valueDecl && valueDecl.flags & 256) {
error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name));
return resolveErrorCall(node);
@@ -18509,10 +18535,6 @@ var ts;
}
}
function checkParameter(node) {
- // Grammar checking
- // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the
- // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code
- // or if its FunctionBody is strict code(11.1.5).
checkGrammarDecorators(node) || checkGrammarModifiers(node);
checkVariableLikeDeclaration(node);
var func = ts.getContainingFunction(node);
@@ -19155,15 +19177,6 @@ var ts;
return type;
}
function getPromisedType(promise) {
- //
- // { // promise
- // then( // thenFunction
- // onfulfilled: ( // onfulfilledParameterType
- // value: T // valueParameterType
- // ) => any
- // ): any;
- // }
- //
if (promise.flags & 1) {
return undefined;
}
@@ -19506,9 +19519,6 @@ var ts;
}
}
function checkVarDeclaredNamesNotShadowed(node) {
- // - ScriptBody : StatementList
- // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList
- // also occurs in the VarDeclaredNames of StatementList.
if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) {
return;
}
@@ -20180,20 +20190,10 @@ var ts;
function getTargetSymbol(s) {
return s.flags & 16777216 ? getSymbolLinks(s).target : s;
}
+ function getClassLikeDeclarationOfSymbol(symbol) {
+ return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; });
+ }
function checkKindsOfPropertyMemberOverrides(type, baseType) {
- // TypeScript 1.0 spec (April 2014): 8.2.3
- // A derived class inherits all members from its base class it doesn't override.
- // Inheritance means that a derived class implicitly contains all non - overridden members of the base class.
- // Both public and private property members are inherited, but only public property members can be overridden.
- // A property member in a derived class is said to override a property member in a base class
- // when the derived class property member has the same name and kind(instance or static)
- // as the base class property member.
- // The type of an overriding property member must be assignable(section 3.8.4)
- // to the type of the overridden property member, or otherwise a compile - time error occurs.
- // Base class instance member functions can be overridden by derived class instance member functions,
- // but not by other kinds of members.
- // Base class instance member variables and accessors can be overridden by
- // derived class instance member variables and accessors, but not by other kinds of members.
var baseProperties = getPropertiesOfObjectType(baseType);
for (var _i = 0; _i < baseProperties.length; _i++) {
var baseProperty = baseProperties[_i];
@@ -20206,9 +20206,14 @@ var ts;
ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
if (derived) {
if (derived === base) {
- var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212);
+ var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol);
if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) {
- error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ if (derivedClassDecl.kind === 184) {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
+ }
+ else {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ }
}
}
else {
@@ -21432,7 +21437,10 @@ var ts;
var symbols = [];
var name_16 = symbol.name;
ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) {
- symbols.push(getPropertyOfType(t, name_16));
+ var symbol = getPropertyOfType(t, name_16);
+ if (symbol) {
+ symbols.push(symbol);
+ }
});
return symbols;
}
@@ -22719,7 +22727,6 @@ var ts;
}
ts.createTypeChecker = createTypeChecker;
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
function getDeclarationDiagnostics(host, resolver, targetSourceFile) {
@@ -24047,8 +24054,6 @@ var ts;
}
ts.writeDeclarationFile = writeDeclarationFile;
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
function isExternalModuleOrDeclarationFile(sourceFile) {
@@ -24141,6 +24146,7 @@ var ts;
var scopeEmitStart = function (scopeDeclaration, scopeName) { };
var scopeEmitEnd = function () { };
var sourceMapData;
+ var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker;
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
initializeEmitterWithSourceMaps();
}
@@ -24787,19 +24793,6 @@ var ts;
write(")");
}
function shouldEmitTemplateHead() {
- // If this expression has an empty head literal and the first template span has a non-empty
- // literal, then emitting the empty head literal is not necessary.
- // `${ foo } and ${ bar }`
- // can be emitted as
- // foo + " and " + bar
- // This is because it is only required that one of the first two operands in the emit
- // output must be a string literal, so that the other operand and all following operands
- // are forced into strings.
- //
- // If the first template span has an empty literal, then the head must still be emitted.
- // `${ foo }${ bar }`
- // must still be emitted as
- // "" + foo + bar
ts.Debug.assert(node.templateSpans.length !== 0);
return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0;
}
@@ -24967,8 +24960,10 @@ var ts;
function jsxEmitPreserve(node) {
function emitJsxAttribute(node) {
emit(node.name);
- write("=");
- emit(node.initializer);
+ if (node.initializer) {
+ write("=");
+ emit(node.initializer);
+ }
}
function emitJsxSpreadAttribute(node) {
write("{...");
@@ -25807,7 +25802,8 @@ var ts;
operand.kind !== 178 &&
operand.kind !== 167 &&
!(operand.kind === 166 && node.parent.kind === 167) &&
- !(operand.kind === 171 && node.parent.kind === 166)) {
+ !(operand.kind === 171 && node.parent.kind === 166) &&
+ !(operand.kind === 8 && node.parent.kind === 164)) {
emit(operand);
return;
}
@@ -26137,26 +26133,6 @@ var ts;
emitEmbeddedStatement(node.statement);
}
function emitDownLevelForOfStatement(node) {
- // The following ES6 code:
- //
- // for (let v of expr) { }
- //
- // should be emitted as
- //
- // for (let _i = 0, _a = expr; _i < _a.length; _i++) {
- // let v = _a[_i];
- // }
- //
- // where _a and _i are temps emitted to capture the RHS and the counter,
- // respectively.
- // When the left hand side is an expression instead of a let declaration,
- // the "let v" is not emitted.
- // When the left hand side is a let/const, the v is renamed if there is
- // another v in scope.
- // Note that all assignments to the LHS are emitted in the body, including
- // all destructuring.
- // Note also that because an extra statement is needed to assign to the LHS,
- // for-of bodies are always emitted as blocks.
var endPos = emitToken(84, node.pos);
write(" ");
endPos = emitToken(17, endPos);
@@ -26440,6 +26416,9 @@ var ts;
}
function emitExportSpecifierInSystemModule(specifier) {
ts.Debug.assert(compilerOptions.module === 4);
+ if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) {
+ return;
+ }
writeLine();
emitStart(specifier.name);
write(exportFunctionForFile + "(\"");
@@ -26491,19 +26470,19 @@ var ts;
write(")");
}
}
- function ensureIdentifier(expr) {
- if (expr.kind !== 67) {
- var identifier = createTempVariable(0);
- if (!canDefineTempVariablesInPlace) {
- recordTempDeclaration(identifier);
- }
- emitAssignment(identifier, expr);
- expr = identifier;
+ function ensureIdentifier(expr, reuseIdentifierExpressions) {
+ if (expr.kind === 67 && reuseIdentifierExpressions) {
+ return expr;
}
- return expr;
+ var identifier = createTempVariable(0);
+ if (!canDefineTempVariablesInPlace) {
+ recordTempDeclaration(identifier);
+ }
+ emitAssignment(identifier, expr);
+ return identifier;
}
function createDefaultValueCheck(value, defaultValue) {
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, true);
var equals = ts.createSynthesizedNode(179);
equals.left = value;
equals.operatorToken = ts.createSynthesizedNode(32);
@@ -26544,7 +26523,7 @@ var ts;
function emitObjectLiteralAssignment(target, value) {
var properties = target.properties;
if (properties.length !== 1) {
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, true);
}
for (var _a = 0; _a < properties.length; _a++) {
var p = properties[_a];
@@ -26557,7 +26536,7 @@ var ts;
function emitArrayLiteralAssignment(target, value) {
var elements = target.elements;
if (elements.length !== 1) {
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, true);
}
for (var i = 0; i < elements.length; i++) {
var e = elements[i];
@@ -26599,7 +26578,7 @@ var ts;
if (root.parent.kind !== 170) {
write("(");
}
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, true);
emitDestructuringAssignment(target, value);
write(", ");
emit(value);
@@ -26618,10 +26597,11 @@ var ts;
if (ts.isBindingPattern(target.name)) {
var pattern = target.name;
var elements = pattern.elements;
- if (elements.length !== 1) {
- value = ensureIdentifier(value);
+ var numElements = elements.length;
+ if (numElements !== 1) {
+ value = ensureIdentifier(value, numElements !== 0);
}
- for (var i = 0; i < elements.length; i++) {
+ for (var i = 0; i < numElements; i++) {
var element = elements[i];
if (pattern.kind === 159) {
var propName = element.propertyName || element.name;
@@ -26631,7 +26611,7 @@ var ts;
if (!element.dotDotDotToken) {
emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i)));
}
- else if (i === elements.length - 1) {
+ else if (i === numElements - 1) {
emitBindingElement(element, createSliceCall(value, i));
}
}
@@ -26871,7 +26851,7 @@ var ts;
}
function emitFunctionDeclaration(node) {
if (ts.nodeIsMissing(node.body)) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
if (node.kind !== 141 && node.kind !== 140 &&
node.parent && node.parent.kind !== 243 &&
@@ -27189,7 +27169,7 @@ var ts;
}
else if (member.kind === 141 || node.kind === 140) {
if (!member.body) {
- return emitOnlyPinnedOrTripleSlashComments(member);
+ return emitCommentsOnNotEmittedNode(member);
}
writeLine();
emitLeadingComments(member);
@@ -27255,7 +27235,7 @@ var ts;
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
if ((member.kind === 141 || node.kind === 140) && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
else if (member.kind === 141 ||
member.kind === 143 ||
@@ -27302,7 +27282,7 @@ var ts;
var hasInstancePropertyWithInitializer = false;
ts.forEach(node.members, function (member) {
if (member.kind === 142 && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) {
hasInstancePropertyWithInitializer = true;
@@ -27751,50 +27731,49 @@ var ts;
write("void 0");
}
function emitSerializedTypeNode(node) {
- if (!node) {
- return;
- }
- switch (node.kind) {
- case 101:
- write("void 0");
- return;
- case 158:
- emitSerializedTypeNode(node.type);
- return;
- case 150:
- case 151:
- write("Function");
- return;
- case 154:
- case 155:
- write("Array");
- return;
- case 148:
- case 118:
- write("Boolean");
- return;
- case 128:
- case 9:
- write("String");
- return;
- case 126:
- write("Number");
- return;
- case 129:
- write("Symbol");
- return;
- case 149:
- emitSerializedTypeReferenceNode(node);
- return;
- case 152:
- case 153:
- case 156:
- case 157:
- case 115:
- break;
- default:
- ts.Debug.fail("Cannot serialize unexpected type node.");
- break;
+ if (node) {
+ switch (node.kind) {
+ case 101:
+ write("void 0");
+ return;
+ case 158:
+ emitSerializedTypeNode(node.type);
+ return;
+ case 150:
+ case 151:
+ write("Function");
+ return;
+ case 154:
+ case 155:
+ write("Array");
+ return;
+ case 148:
+ case 118:
+ write("Boolean");
+ return;
+ case 128:
+ case 9:
+ write("String");
+ return;
+ case 126:
+ write("Number");
+ return;
+ case 129:
+ write("Symbol");
+ return;
+ case 149:
+ emitSerializedTypeReferenceNode(node);
+ return;
+ case 152:
+ case 153:
+ case 156:
+ case 157:
+ case 115:
+ break;
+ default:
+ ts.Debug.fail("Cannot serialize unexpected type node.");
+ break;
+ }
}
write("Object");
}
@@ -27933,7 +27912,7 @@ var ts;
return argumentsWritten;
}
function emitInterfaceDeclaration(node) {
- emitOnlyPinnedOrTripleSlashComments(node);
+ emitCommentsOnNotEmittedNode(node);
}
function shouldEmitEnumDeclaration(node) {
var isConstEnum = ts.isConst(node);
@@ -28040,7 +28019,7 @@ var ts;
function emitModuleDeclaration(node) {
var shouldEmit = shouldEmitModuleDeclaration(node);
if (!shouldEmit) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node);
var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node);
@@ -28708,7 +28687,7 @@ var ts;
}
return;
}
- if (ts.isInternalModuleImportEqualsDeclaration(node)) {
+ if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) {
if (!hoistedVars) {
hoistedVars = [];
}
@@ -28884,17 +28863,6 @@ var ts;
write("});");
}
function emitAMDDependencies(node, includeNonAmdDependencies) {
- // An AMD define function has the following shape:
- // define(id?, dependencies?, factory);
- //
- // This has the shape of
- // define(name, ["module1", "module2"], function (module1Alias) {
- // The location of the alias in the parameter list in the factory function needs to
- // match the position of the module name in the dependency list.
- //
- // To ensure this is true in cases of modules with no aliases, e.g.:
- // `import "module"` or ``
- // we need to add modules without alias names to the end of the dependencies list
var aliasedModuleNames = [];
var unaliasedModuleNames = [];
var importAliasNames = [];
@@ -29178,7 +29146,7 @@ var ts;
function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) {
if (node) {
if (node.flags & 2) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
if (isSpecializedCommentHandling(node)) {
return emitNodeWithoutSourceMap(node);
@@ -29410,14 +29378,20 @@ var ts;
}
return leadingComments;
}
- function filterComments(ranges, onlyPinnedOrTripleSlashComments) {
- if (ranges && onlyPinnedOrTripleSlashComments) {
- ranges = ts.filter(ranges, isPinnedOrTripleSlashComment);
- if (ranges.length === 0) {
- return undefined;
- }
+ function isPinnedComments(comment) {
+ return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 33;
+ }
+ function isTripleSlashComment(comment) {
+ if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 &&
+ comment.pos + 2 < comment.end &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) {
+ var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end);
+ return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
+ textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ?
+ true : false;
}
- return ranges;
+ return false;
}
function getLeadingCommentsToEmit(node) {
if (node.parent) {
@@ -29438,26 +29412,46 @@ var ts;
}
}
}
- function emitOnlyPinnedOrTripleSlashComments(node) {
- emitLeadingCommentsWorker(node, true);
+ function emitCommentsOnNotEmittedNode(node) {
+ emitLeadingCommentsWorker(node, false);
}
function emitLeadingComments(node) {
- return emitLeadingCommentsWorker(node, compilerOptions.removeComments);
+ return emitLeadingCommentsWorker(node, true);
}
- function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) {
- var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments);
+ function emitLeadingCommentsWorker(node, isEmittedNode) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var leadingComments;
+ if (isEmittedNode) {
+ leadingComments = getLeadingCommentsToEmit(node);
+ }
+ else {
+ if (node.pos === 0) {
+ leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment);
+ }
+ }
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment);
}
function emitTrailingComments(node) {
- var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments);
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var trailingComments = getTrailingCommentsToEmit(node);
ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment);
}
function emitTrailingCommentsOfPosition(pos) {
- var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), compilerOptions.removeComments);
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos);
ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment);
}
- function emitLeadingCommentsOfPosition(pos) {
+ function emitLeadingCommentsOfPositionWorker(pos) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
var leadingComments;
if (hasDetachedComments(pos)) {
leadingComments = getLeadingCommentsWithoutDetachedComments();
@@ -29465,12 +29459,19 @@ var ts;
else {
leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos);
}
- leadingComments = filterComments(leadingComments, compilerOptions.removeComments);
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment);
}
function emitDetachedComments(node) {
- var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ var leadingComments;
+ if (compilerOptions.removeComments) {
+ if (node.pos === 0) {
+ leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments);
+ }
+ }
+ else {
+ leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ }
if (leadingComments) {
var detachedComments = [];
var lastComment;
@@ -29508,17 +29509,6 @@ var ts;
write(shebang);
}
}
- function isPinnedOrTripleSlashComment(comment) {
- if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) {
- return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33;
- }
- else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 &&
- comment.pos + 2 < comment.end &&
- currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 &&
- currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) {
- return true;
- }
- }
}
function emitFile(jsFilePath, sourceFile) {
emitJavaScript(jsFilePath, sourceFile);
@@ -29784,9 +29774,6 @@ var ts;
"diams": 0x2666
};
})(ts || (ts = {}));
-///
-///
-///
var ts;
(function (ts) {
ts.programTime = 0;
@@ -29794,7 +29781,7 @@ var ts;
ts.ioReadTime = 0;
ts.ioWriteTime = 0;
var emptyArray = [];
- ts.version = "1.6.0";
+ ts.version = "1.7.0";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@@ -29834,10 +29821,12 @@ var ts;
var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host);
if (resolvedFileName) {
- return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations };
}
resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host);
- return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
+ return resolvedFileName
+ ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }
+ : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
}
else {
return loadModuleFromNodeModules(moduleName, containingDirectory, host);
@@ -29895,11 +29884,11 @@ var ts;
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName));
var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host);
if (result) {
- return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations };
}
result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host);
if (result) {
- return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations };
}
}
var parentPath = ts.getDirectoryPath(directory);
@@ -29908,36 +29897,15 @@ var ts;
}
directory = parentPath;
}
- return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
}
- function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) {
- ts.Debug.assert(baseUrl !== undefined);
- var normalizedModuleName = ts.normalizeSlashes(moduleName);
- var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile);
- var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName));
- var failedLookupLocations = [];
- return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
- function tryLoadFile(location) {
- if (host.fileExists(location)) {
- return { resolvedFileName: location, failedLookupLocations: failedLookupLocations };
- }
- else {
- failedLookupLocations.push(location);
- return undefined;
- }
- }
- }
- ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver;
function nameStartsWithDotSlashOrDotDotSlash(name) {
var i = name.lastIndexOf("./", 1);
return i === 0 || (i === 1 && name.charCodeAt(0) === 46);
}
- function useBaseUrl(moduleName) {
- return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName);
- }
function classicNameResolver(moduleName, containingFile, compilerOptions, host) {
if (moduleName.indexOf('!') != -1) {
- return { resolvedFileName: undefined, failedLookupLocations: [] };
+ return { resolvedModule: undefined, failedLookupLocations: [] };
}
var searchPath = ts.getDirectoryPath(containingFile);
var searchName;
@@ -29966,7 +29934,9 @@ var ts;
}
searchPath = parentPath;
}
- return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations };
+ return referencedSourceFile
+ ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations }
+ : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
}
ts.classicNameResolver = classicNameResolver;
ts.defaultInitCompilerOptions = {
@@ -30079,7 +30049,8 @@ var ts;
function createProgram(rootNames, options, host, oldProgram) {
var program;
var files = [];
- var diagnostics = ts.createDiagnosticCollection();
+ var fileProcessingDiagnostics = ts.createDiagnosticCollection();
+ var programDiagnostics = ts.createDiagnosticCollection();
var commonSourceDirectory;
var diagnosticsProducingTypeChecker;
var noDiagnosticsTypeChecker;
@@ -30087,8 +30058,9 @@ var ts;
var skipDefaultLib = options.noLib;
var start = new Date().getTime();
host = host || createCompilerHost(options);
- var resolveModuleNamesWorker = host.resolveModuleNames ||
- (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedFileName; }); });
+ var resolveModuleNamesWorker = host.resolveModuleNames
+ ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); })
+ : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); });
var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); });
if (oldProgram) {
var oldOptions = oldProgram.getCompilerOptions();
@@ -30128,7 +30100,8 @@ var ts;
getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
- getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }
+ getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
+ getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }
};
return program;
function getClassifiableNames() {
@@ -30152,6 +30125,7 @@ var ts;
return false;
}
var newSourceFiles = [];
+ var modifiedSourceFiles = [];
for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) {
var oldSourceFile = _a[_i];
var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target);
@@ -30173,13 +30147,20 @@ var ts;
var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; });
var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName);
for (var i = 0; i < moduleNames.length; ++i) {
- var oldResolution = ts.getResolvedModuleFileName(oldSourceFile, moduleNames[i]);
- if (oldResolution !== resolutions[i]) {
+ var newResolution = resolutions[i];
+ var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]);
+ var resolutionChanged = oldResolution
+ ? !newResolution ||
+ oldResolution.resolvedFileName !== newResolution.resolvedFileName ||
+ !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport
+ : newResolution;
+ if (resolutionChanged) {
return false;
}
}
}
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
+ modifiedSourceFiles.push(newSourceFile);
}
else {
newSourceFile = oldSourceFile;
@@ -30191,6 +30172,11 @@ var ts;
filesByName.set(file.fileName, file);
}
files = newSourceFiles;
+ fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
+ for (var _c = 0; _c < modifiedSourceFiles.length; _c++) {
+ var modifiedFile = modifiedSourceFiles[_c];
+ fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile);
+ }
oldProgram.structureIsReused = true;
return true;
}
@@ -30272,8 +30258,9 @@ var ts;
ts.Debug.assert(!!sourceFile.bindDiagnostics);
var bindDiagnostics = sourceFile.bindDiagnostics;
var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken);
- var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
- return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics);
+ var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
+ var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
+ return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile);
});
}
function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) {
@@ -30287,7 +30274,8 @@ var ts;
}
function getOptionsDiagnostics() {
var allDiagnostics = [];
- ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
+ ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics());
+ ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics());
return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
}
function getGlobalDiagnostics() {
@@ -30377,10 +30365,10 @@ var ts;
}
if (diagnostic) {
if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) {
- diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument)));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument)));
}
else {
- diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument)));
+ fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument)));
}
}
}
@@ -30397,10 +30385,10 @@ var ts;
}
var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) {
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
- diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
}
else {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
+ fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
}
});
filesByName.set(canonicalName, file);
@@ -30428,10 +30416,10 @@ var ts;
var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName;
if (canonicalName !== sourceFileName) {
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
- diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
}
else {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
+ fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
}
}
}
@@ -30452,9 +30440,23 @@ var ts;
var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName);
for (var i = 0; i < file.imports.length; ++i) {
var resolution = resolutions[i];
- ts.setResolvedModuleName(file, moduleNames[i], resolution);
+ ts.setResolvedModule(file, moduleNames[i], resolution);
if (resolution && !options.noResolve) {
- findModuleSourceFile(resolution, file.imports[i]);
+ var importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]);
+ if (importedFile && resolution.isExternalLibraryImport) {
+ if (!ts.isExternalModule(importedFile)) {
+ var start_2 = ts.getTokenPosOfNode(file.imports[i], file);
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
+ }
+ else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) {
+ var start_3 = ts.getTokenPosOfNode(file.imports[i], file);
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_3, file.imports[i].end - start_3, ts.Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition));
+ }
+ else if (importedFile.referencedFiles.length) {
+ var firstRef = importedFile.referencedFiles[0];
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition));
+ }
+ }
}
}
}
@@ -30463,7 +30465,7 @@ var ts;
}
return;
function findModuleSourceFile(fileName, nameLiteral) {
- return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end);
+ return findSourceFile(fileName, false, file, ts.skipTrivia(file.text, nameLiteral.pos), nameLiteral.end);
}
}
function computeCommonSourceDirectory(sourceFiles) {
@@ -30482,7 +30484,7 @@ var ts;
for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) {
if (commonPathComponents[i] !== sourcePathComponents[i]) {
if (i === 0) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
return;
}
commonPathComponents.length = i;
@@ -30505,7 +30507,7 @@ var ts;
if (!ts.isDeclarationFile(sourceFile)) {
var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
allFilesBelongToPath = false;
}
}
@@ -30516,43 +30518,43 @@ var ts;
function verifyCompilerOptions() {
if (options.isolatedModules) {
if (options.declaration) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules"));
}
if (options.noEmitOnError) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules"));
}
if (options.out) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"));
}
if (options.outFile) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules"));
}
}
if (options.inlineSourceMap) {
if (options.sourceMap) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap"));
}
if (options.mapRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
}
if (options.sourceRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
}
}
if (options.inlineSources) {
if (!options.sourceMap && !options.inlineSourceMap) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
}
}
if (options.out && options.outFile) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
}
if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) {
if (options.mapRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
}
if (options.sourceRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
}
return;
}
@@ -30561,20 +30563,20 @@ var ts;
var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; });
if (options.isolatedModules) {
if (!options.module && languageVersion < 2) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
}
var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; });
if (firstNonExternalModuleSourceFile) {
var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
- diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) {
var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
- diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
}
if (options.module && languageVersion >= 2) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
}
if (options.outDir ||
options.sourceRoot ||
@@ -30592,33 +30594,30 @@ var ts;
}
if (options.noEmit) {
if (options.out) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));
}
if (options.outFile) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile"));
}
if (options.outDir) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir"));
}
if (options.declaration) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
}
}
if (options.emitDecoratorMetadata &&
!options.experimentalDecorators) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
}
if (options.experimentalAsyncFunctions &&
options.target !== 2) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
}
}
}
ts.createProgram = createProgram;
})(ts || (ts = {}));
-// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0.
-// See LICENSE.txt in the project root for complete license information.
-///
var ts;
(function (ts) {
var BreakpointResolver;
@@ -31278,7 +31277,6 @@ var ts;
NavigateTo.getNavigateToItems = getNavigateToItems;
})(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var NavigationBar;
@@ -32099,7 +32097,6 @@ var ts;
return transition;
}
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var SignatureHelp;
@@ -32681,7 +32678,7 @@ var ts;
function findPrecedingToken(position, sourceFile, startNode) {
return find(startNode || sourceFile);
function findRightmostToken(n) {
- if (isToken(n)) {
+ if (isToken(n) || n.kind === 234) {
return n;
}
var children = n.getChildren();
@@ -32689,21 +32686,22 @@ var ts;
return candidate && findRightmostToken(candidate);
}
function find(n) {
- if (isToken(n)) {
+ if (isToken(n) || n.kind === 234) {
return n;
}
var children = n.getChildren();
for (var i = 0, len = children.length; i < len; i++) {
var child = children[i];
- if (nodeHasTokens(child)) {
- if (position <= child.end) {
- if (child.getStart(sourceFile) >= position) {
- var candidate = findRightmostChildNodeWithTokens(children, i);
- return candidate && findRightmostToken(candidate);
- }
- else {
- return find(child);
- }
+ if (position < child.end && (nodeHasTokens(child) || child.kind === 234)) {
+ var start = child.getStart(sourceFile);
+ var lookInPreviousChild = (start >= position) ||
+ (child.kind === 234 && start === child.end);
+ if (lookInPreviousChild) {
+ var candidate = findRightmostChildNodeWithTokens(children, i);
+ return candidate && findRightmostToken(candidate);
+ }
+ else {
+ return find(child);
}
}
}
@@ -33066,8 +33064,6 @@ var ts;
}
ts.stripQuotes = stripQuotes;
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
var formatting;
@@ -33143,6 +33139,18 @@ var ts;
}
return false;
}
+ function shouldRescanJsxIdentifier(node) {
+ if (node.parent) {
+ switch (node.parent.kind) {
+ case 236:
+ case 233:
+ case 235:
+ case 232:
+ return node.kind === 67;
+ }
+ }
+ return false;
+ }
function shouldRescanSlashToken(container) {
return container.kind === 10;
}
@@ -33167,7 +33175,9 @@ var ts;
? 2
: shouldRescanTemplateToken(n)
? 3
- : 0;
+ : shouldRescanJsxIdentifier(n)
+ ? 4
+ : 0;
if (lastTokenInfo && expectedScanAction === lastScanAction) {
return fixTokenKind(lastTokenInfo, n);
}
@@ -33191,6 +33201,10 @@ var ts;
currentToken = scanner.reScanTemplateToken();
lastScanAction = 3;
}
+ else if (expectedScanAction === 4 && currentToken === 67) {
+ currentToken = scanner.scanJsxIdentifier();
+ lastScanAction = 4;
+ }
else {
lastScanAction = 0;
}
@@ -33243,7 +33257,6 @@ var ts;
formatting.getFormattingScanner = getFormattingScanner;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var formatting;
@@ -33322,8 +33335,6 @@ var ts;
formatting.FormattingContext = FormattingContext;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
var formatting;
@@ -33345,8 +33356,6 @@ var ts;
formatting.Rule = Rule;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
var formatting;
@@ -33377,8 +33386,6 @@ var ts;
formatting.RuleDescriptor = RuleDescriptor;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
var formatting;
@@ -33406,7 +33413,6 @@ var ts;
formatting.RuleOperation = RuleOperation;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var formatting;
@@ -33440,16 +33446,12 @@ var ts;
formatting.RuleOperationContext = RuleOperationContext;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var formatting;
(function (formatting) {
var Rules = (function () {
function Rules() {
- ///
- /// Common Rules
- ///
this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1));
this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1));
this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
@@ -33469,7 +33471,7 @@ var ts;
this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8));
this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments;
this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1);
- this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67, 3]);
+ this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67, 3, 71]);
this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1);
this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 77, 98, 83, 78]);
this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1);
@@ -33490,7 +33492,7 @@ var ts;
this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2));
this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2));
this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100, 96, 90, 76, 92, 99]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
+ this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100, 96, 90, 76, 92, 99, 117]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2));
this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8));
this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2));
@@ -33504,7 +33506,7 @@ var ts;
this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2));
this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 125]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113, 71, 120, 75, 79, 80, 81, 121, 104, 87, 105, 123, 124, 108, 110, 109, 127, 111]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
+ this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113, 71, 120, 75, 79, 80, 81, 121, 104, 87, 105, 123, 124, 108, 110, 109, 127, 111, 130]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81, 104])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2));
this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
@@ -33525,17 +33527,7 @@ var ts;
this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8));
this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2));
this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.HighPriorityCommonRules =
[
this.IgnoreBeforeComment, this.IgnoreAfterLineComment,
@@ -33561,11 +33553,8 @@ var ts;
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
- this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
- this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
- this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
- this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
- this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
+ this.SpaceBetweenAsyncAndFunctionKeyword,
+ this.SpaceBetweenTagAndTemplateString,
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
this.SpaceAfterModuleName,
@@ -33641,6 +33630,8 @@ var ts;
case 180:
case 187:
case 148:
+ case 156:
+ case 157:
return true;
case 161:
case 214:
@@ -33665,22 +33656,6 @@ var ts;
return context.contextNode.kind === 180;
};
Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) {
- //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction.
- ////
- //// Ex:
- //// if (1) { ....
- //// * ) and { are on the same line so apply the rule. Here we don't care whether it's same or multi block context
- ////
- //// Ex:
- //// if (1)
- //// { ... }
- //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we don't format.
- ////
- //// Ex:
- //// if (1)
- //// { ...
- //// }
- //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we format.
return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context);
};
Rules.IsBeforeMultilineBlockContext = function (context) {
@@ -33736,6 +33711,7 @@ var ts;
Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) {
switch (node.kind) {
case 212:
+ case 184:
case 213:
case 215:
case 153:
@@ -33863,7 +33839,6 @@ var ts;
formatting.Rules = Rules;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var formatting;
@@ -34000,7 +33975,6 @@ var ts;
formatting.RulesBucket = RulesBucket;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var formatting;
@@ -34115,19 +34089,6 @@ var ts;
})(Shared = formatting.Shared || (formatting.Shared = {}));
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
var ts;
(function (ts) {
var formatting;
@@ -34223,10 +34184,6 @@ var ts;
formatting.RulesProvider = RulesProvider;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
-///
-///
-///
var ts;
(function (ts) {
var formatting;
@@ -34483,13 +34440,14 @@ var ts;
}
function getDynamicIndentation(node, nodeStartLine, indentation, delta) {
return {
- getIndentationForComment: function (kind) {
+ getIndentationForComment: function (kind, tokenIndentation) {
switch (kind) {
case 16:
case 20:
+ case 18:
return indentation + delta;
}
- return indentation;
+ return tokenIndentation !== -1 ? tokenIndentation : indentation;
},
getIndentationForToken: function (line, kind) {
if (nodeStartLine !== line && node.decorators) {
@@ -34658,8 +34616,12 @@ var ts;
processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation);
}
if (indentToken) {
- var indentNextTokenOrTrivia = true;
+ var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
+ dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) :
+ -1;
if (currentTokenInfo.leadingTrivia) {
+ var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation);
+ var indentNextTokenOrTrivia = true;
for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) {
var triviaItem = _a[_i];
if (!ts.rangeContainsRange(originalRange, triviaItem)) {
@@ -34667,14 +34629,12 @@ var ts;
}
switch (triviaItem.kind) {
case 3:
- var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia);
indentNextTokenOrTrivia = false;
break;
case 2:
if (indentNextTokenOrTrivia) {
- var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
- insertIndentation(triviaItem.pos, commentIndentation_1, false);
+ insertIndentation(triviaItem.pos, commentIndentation, false);
indentNextTokenOrTrivia = false;
}
break;
@@ -34684,8 +34644,7 @@ var ts;
}
}
}
- if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
- var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
+ if (tokenIndentation !== -1) {
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
lastIndentedLine = tokenStart.line;
indentationOnLastIndentedLine = tokenIndentation;
@@ -34973,7 +34932,6 @@ var ts;
formatting.getIndentationString = getIndentationString;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var formatting;
@@ -35266,6 +35224,7 @@ var ts;
function nodeContentIsAlwaysIndented(kind) {
switch (kind) {
case 212:
+ case 184:
case 213:
case 215:
case 214:
@@ -35290,13 +35249,13 @@ var ts;
case 160:
case 159:
case 231:
+ case 232:
case 140:
case 145:
case 146:
case 136:
case 150:
case 151:
- case 156:
case 158:
case 168:
case 176:
@@ -35331,21 +35290,11 @@ var ts;
})(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {}));
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
-///
-///
-///
-///
-///
-///
-///
-///
-///
var ts;
(function (ts) {
ts.servicesVersion = "0.4";
@@ -36267,7 +36216,7 @@ var ts;
var outputText;
var sourceMapText;
var compilerHost = {
- getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; },
+ getSourceFile: function (fileName, target) { return fileName === ts.normalizeSlashes(inputFileName) ? sourceFile : undefined; },
writeFile: function (name, text, writeByteOrderMark) {
if (ts.fileExtensionIs(name, ".map")) {
ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'");
@@ -36581,6 +36530,24 @@ var ts;
}
}
}
+ else if (token === 87) {
+ token = scanner.scan();
+ if (token === 67 || ts.isKeyword(token)) {
+ token = scanner.scan();
+ if (token === 55) {
+ token = scanner.scan();
+ if (token === 125) {
+ token = scanner.scan();
+ if (token === 17) {
+ token = scanner.scan();
+ if (token === 9) {
+ recordModuleName();
+ }
+ }
+ }
+ }
+ }
+ }
}
token = scanner.scan();
}
@@ -37164,9 +37131,9 @@ var ts;
log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start));
var contextToken = previousToken;
if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) {
- var start_2 = new Date().getTime();
+ var start_4 = new Date().getTime();
contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile);
- log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_2));
+ log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_4));
}
var node = currentToken;
var isRightOfDot = false;
@@ -37361,9 +37328,9 @@ var ts;
if (contextToken.kind === 9
|| contextToken.kind === 10
|| ts.isTemplateLiteralKind(contextToken.kind)) {
- var start_3 = contextToken.getStart();
+ var start_5 = contextToken.getStart();
var end = contextToken.getEnd();
- if (start_3 < position && position < end) {
+ if (start_5 < position && position < end) {
return true;
}
if (position === end) {
@@ -39278,6 +39245,7 @@ var ts;
result.push(getReferenceEntryFromNode(node));
}
break;
+ case 184:
case 212:
if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) {
result.push(getReferenceEntryFromNode(node));
@@ -40161,8 +40129,6 @@ var ts;
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}
function getTodoCommentsRegExp() {
- // NOTE: ?: means 'non-capture group'. It allows us to have groups without having to
- // filter them out later in the final result array.
var singleLineCommentStart = /(?:\/\/+\s*)/.source;
var multiLineCommentStart = /(?:\/\*+\s*)/.source;
var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source;
@@ -40665,10 +40631,6 @@ var ts;
}
initializeServices();
})(ts || (ts = {}));
-///
-///
-///
-///
var ts;
(function (ts) {
var server;
@@ -41631,10 +41593,6 @@ var ts;
server.Session = Session;
})(server = ts.server || (ts.server = {}));
})(ts || (ts = {}));
-///
-///
-///
-///
var ts;
(function (ts) {
var server;
@@ -41711,7 +41669,7 @@ var ts;
LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) {
var currentResolutionsInFile = this.resolvedModuleNames.get(containingFile);
var newResolutions = {};
- var resolvedFileNames = [];
+ var resolvedModules = [];
var compilerOptions = this.getCompilationSettings();
for (var _i = 0; _i < moduleNames.length; _i++) {
var moduleName = moduleNames[_i];
@@ -41728,15 +41686,15 @@ var ts;
}
}
ts.Debug.assert(resolution !== undefined);
- resolvedFileNames.push(resolution.resolvedFileName);
+ resolvedModules.push(resolution.resolvedModule);
}
this.resolvedModuleNames.set(containingFile, newResolutions);
- return resolvedFileNames;
+ return resolvedModules;
function moduleResolutionIsValid(resolution) {
if (!resolution) {
return false;
}
- if (resolution.resolvedFileName) {
+ if (resolution.resolvedModule) {
return true;
}
return resolution.failedLookupLocations.length === 0;
@@ -43417,8 +43375,6 @@ var ts;
server.LineLeaf = LineLeaf;
})(server = ts.server || (ts.server = {}));
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
var server;
@@ -43641,21 +43597,6 @@ var ts;
ioSession.listen();
})(server = ts.server || (ts.server = {}));
})(ts || (ts = {}));
-//
-// Copyright (c) Microsoft Corporation. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-///
var debugObjectHost = this;
var ts;
(function (ts) {
@@ -43700,7 +43641,10 @@ var ts;
if ("getModuleResolutionsForFile" in this.shimHost) {
this.resolveModuleNames = function (moduleNames, containingFile) {
var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile));
- return ts.map(moduleNames, function (name) { return ts.lookUp(resolutionsInFile, name); });
+ return ts.map(moduleNames, function (name) {
+ var result = ts.lookUp(resolutionsInFile, name);
+ return result ? { resolvedFileName: result } : undefined;
+ });
};
}
}
@@ -44175,7 +44119,11 @@ var ts;
var _this = this;
return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () {
var compilerOptions = JSON.parse(compilerOptionsJson);
- return ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host);
+ var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host);
+ return {
+ resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined,
+ failedLookupLocations: result.failedLookupLocations
+ };
});
};
CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) {
diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts
index bf0510cf1c8..2cd3a663fce 100644
--- a/lib/typescript.d.ts
+++ b/lib/typescript.d.ts
@@ -13,7 +13,7 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
-declare module "typescript" {
+declare namespace ts {
interface Map {
[index: string]: T;
}
@@ -1208,9 +1208,11 @@ declare module "typescript" {
UnionOrIntersection = 49152,
StructuredType = 130048,
}
+ type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
interface Type {
flags: TypeFlags;
symbol?: Symbol;
+ pattern?: DestructuringPattern;
}
interface StringLiteralType extends Type {
text: string;
@@ -1237,7 +1239,6 @@ declare module "typescript" {
}
interface TupleType extends ObjectType {
elementTypes: Type[];
- baseArrayType: TypeReference;
}
interface UnionOrIntersectionType extends Type {
types: Type[];
@@ -1382,9 +1383,12 @@ declare module "typescript" {
}
interface ResolvedModule {
resolvedFileName: string;
+ isExternalLibraryImport?: boolean;
+ }
+ interface ResolvedModuleWithFailedLookupLocations {
+ resolvedModule: ResolvedModule;
failedLookupLocations: string[];
}
- type ModuleNameResolver = (moduleName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost) => ResolvedModule;
interface CompilerHost extends ModuleResolutionHost {
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
getCancellationToken?(): CancellationToken;
@@ -1394,7 +1398,7 @@ declare module "typescript" {
getCanonicalFileName(fileName: string): string;
useCaseSensitiveFileNames(): boolean;
getNewLine(): string;
- resolveModuleNames?(moduleNames: string[], containingFile: string): string[];
+ resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
}
interface TextSpan {
start: number;
@@ -1405,7 +1409,7 @@ declare module "typescript" {
newLength: number;
}
}
-declare module "typescript" {
+declare namespace ts {
interface System {
args: string[];
newLine: string;
@@ -1429,7 +1433,7 @@ declare module "typescript" {
}
var sys: System;
}
-declare module "typescript" {
+declare namespace ts {
interface ErrorCallback {
(message: DiagnosticMessage, length: number): void;
}
@@ -1474,7 +1478,7 @@ declare module "typescript" {
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
}
-declare module "typescript" {
+declare namespace ts {
function getDefaultLibFileName(options: CompilerOptions): string;
function textSpanEnd(span: TextSpan): number;
function textSpanIsEmpty(span: TextSpan): boolean;
@@ -1504,33 +1508,32 @@ declare module "typescript" {
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
function getTypeParameterOwner(d: Declaration): Declaration;
}
-declare module "typescript" {
+declare namespace ts {
function getNodeConstructor(kind: SyntaxKind): new () => Node;
function createNode(kind: SyntaxKind): Node;
function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
}
-declare module "typescript" {
+declare namespace ts {
const version: string;
function findConfigFile(searchPath: string): string;
function resolveTripleslashReference(moduleName: string, containingFile: string): string;
- function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule;
- function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule;
- function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule;
- function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule;
+ function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations;
+ function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations;
+ function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations;
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
}
-declare module "typescript" {
+declare namespace ts {
function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine;
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
- function readConfigFile(fileName: string): {
+ function readConfigFile(fileName: string, readFile: (path: string) => string): {
config?: any;
error?: Diagnostic;
};
@@ -1551,7 +1554,7 @@ declare module "typescript" {
*/
function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine;
}
-declare module "typescript" {
+declare namespace ts {
/** The version of the language service API */
let servicesVersion: string;
interface Node {
@@ -1649,7 +1652,7 @@ declare module "typescript" {
trace?(s: string): void;
error?(s: string): void;
useCaseSensitiveFileNames?(): boolean;
- resolveModuleNames?(moduleNames: string[], containingFile: string): string[];
+ resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
}
interface LanguageService {
cleanupSemanticCache(): void;
@@ -2139,3 +2142,5 @@ declare module "typescript" {
*/
function getDefaultLibFilePath(options: CompilerOptions): string;
}
+
+export = ts;
\ No newline at end of file
diff --git a/lib/typescript.js b/lib/typescript.js
index b4d21639d3b..2c70f56d0a6 100644
--- a/lib/typescript.js
+++ b/lib/typescript.js
@@ -2117,7 +2117,7 @@ var ts;
Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.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: ts.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: ts.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: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
+ An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.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: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." },
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." },
@@ -2288,6 +2288,7 @@ var ts;
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.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: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." },
await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." },
+ Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." },
JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.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: ts.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: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." },
@@ -2300,6 +2301,10 @@ var ts;
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
+ Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." },
+ Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." },
+ Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." },
+ Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.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: ts.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: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -2433,13 +2438,14 @@ var ts;
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" },
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
+ Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." },
Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" },
Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." },
Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." },
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.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: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
- Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
+ Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." },
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
@@ -2491,6 +2497,11 @@ var ts;
///
var ts;
(function (ts) {
+ /* @internal */
+ function tokenIsIdentifierOrKeyword(token) {
+ return token >= 67 /* Identifier */;
+ }
+ ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
var textToToken = {
"abstract": 113 /* AbstractKeyword */,
"any": 115 /* AnyKeyword */,
@@ -3926,7 +3937,7 @@ var ts;
// Scans a JSX identifier; these differ from normal identifiers in that
// they allow dashes
function scanJsxIdentifier() {
- if (token === 67 /* Identifier */) {
+ if (tokenIsIdentifierOrKeyword(token)) {
var firstCharPosition = pos;
while (pos < end) {
var ch = text.charCodeAt(pos);
@@ -5011,21 +5022,21 @@ var ts;
return true;
}
ts.arrayIsEqualTo = arrayIsEqualTo;
- function hasResolvedModuleName(sourceFile, moduleNameText) {
+ function hasResolvedModule(sourceFile, moduleNameText) {
return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText);
}
- ts.hasResolvedModuleName = hasResolvedModuleName;
- function getResolvedModuleFileName(sourceFile, moduleNameText) {
- return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined;
+ ts.hasResolvedModule = hasResolvedModule;
+ function getResolvedModule(sourceFile, moduleNameText) {
+ return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined;
}
- ts.getResolvedModuleFileName = getResolvedModuleFileName;
- function setResolvedModuleName(sourceFile, moduleNameText, resolvedFileName) {
+ ts.getResolvedModule = getResolvedModule;
+ function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
if (!sourceFile.resolvedModules) {
sourceFile.resolvedModules = {};
}
- sourceFile.resolvedModules[moduleNameText] = resolvedFileName;
+ sourceFile.resolvedModules[moduleNameText] = resolvedModule;
}
- ts.setResolvedModuleName = setResolvedModuleName;
+ ts.setResolvedModule = setResolvedModule;
// Returns true if this node contains a parse error anywhere underneath it.
function containsParseError(node) {
aggregateChildData(node);
@@ -5328,6 +5339,7 @@ var ts;
}
ts.getJsDocComments = getJsDocComments;
ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/;
+ ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/;
function isTypeNode(node) {
if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) {
return true;
@@ -6362,11 +6374,21 @@ var ts;
add: add,
getGlobalDiagnostics: getGlobalDiagnostics,
getDiagnostics: getDiagnostics,
- getModificationCount: getModificationCount
+ getModificationCount: getModificationCount,
+ reattachFileDiagnostics: reattachFileDiagnostics
};
function getModificationCount() {
return modificationCount;
}
+ function reattachFileDiagnostics(newFile) {
+ if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) {
+ return;
+ }
+ for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) {
+ var diagnostic = _a[_i];
+ diagnostic.file = newFile;
+ }
+ }
function add(diagnostic) {
var diagnostics;
if (diagnostic.file) {
@@ -8118,10 +8140,10 @@ var ts;
return createIdentifier(isIdentifier(), diagnosticMessage);
}
function parseIdentifierName() {
- return createIdentifier(isIdentifierOrKeyword());
+ return createIdentifier(ts.tokenIsIdentifierOrKeyword(token));
}
function isLiteralPropertyName() {
- return isIdentifierOrKeyword() ||
+ return ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 /* StringLiteral */ ||
token === 8 /* NumericLiteral */;
}
@@ -8141,7 +8163,7 @@ var ts;
return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false);
}
function isSimplePropertyName() {
- return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || isIdentifierOrKeyword();
+ return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || ts.tokenIsIdentifierOrKeyword(token);
}
function parseComputedPropertyName() {
// PropertyName [Yield]:
@@ -8257,9 +8279,9 @@ var ts;
case 20 /* HeritageClauses */:
return isHeritageClause();
case 21 /* ImportOrExportSpecifiers */:
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
case 13 /* JsxAttributes */:
- return isIdentifierOrKeyword() || token === 15 /* OpenBraceToken */;
+ return ts.tokenIsIdentifierOrKeyword(token) || token === 15 /* OpenBraceToken */;
case 14 /* JsxChildren */:
return true;
case 22 /* JSDocFunctionParameters */:
@@ -8292,7 +8314,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeyword() {
nextToken();
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
function isHeritageClauseExtendsOrImplementsKeyword() {
if (token === 104 /* ImplementsKeyword */ ||
@@ -8786,7 +8808,7 @@ var ts;
// the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword".
// In the first case though, ASI will not take effect because there is not a
// line terminator after the identifier or keyword.
- if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) {
+ if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) {
var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
if (matchesPattern) {
// Report that we need an identifier. However, report it right after the dot,
@@ -9170,7 +9192,7 @@ var ts;
return result;
}
}
- if (isIdentifierOrKeyword()) {
+ if (ts.tokenIsIdentifierOrKeyword(token)) {
return parsePropertyOrMethodSignature();
}
}
@@ -10763,12 +10785,9 @@ var ts;
return finishNode(expressionStatement);
}
}
- function isIdentifierOrKeyword() {
- return token >= 67 /* Identifier */;
- }
function nextTokenIsIdentifierOrKeywordOnSameLine() {
nextToken();
- return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak();
+ return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak();
}
function nextTokenIsFunctionKeywordOnSameLine() {
nextToken();
@@ -10776,7 +10795,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() {
nextToken();
- return (isIdentifierOrKeyword() || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak();
+ return (ts.tokenIsIdentifierOrKeyword(token) || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak();
}
function isDeclaration() {
while (true) {
@@ -10826,7 +10845,7 @@ var ts;
case 87 /* ImportKeyword */:
nextToken();
return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ ||
- token === 15 /* OpenBraceToken */ || isIdentifierOrKeyword();
+ token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token);
case 80 /* ExportKeyword */:
nextToken();
if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ ||
@@ -11366,7 +11385,7 @@ var ts;
}
// It is very important that we check this *after* checking indexers because
// the [ token can start an index signature or a computed property name
- if (isIdentifierOrKeyword() ||
+ if (ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 /* StringLiteral */ ||
token === 8 /* NumericLiteral */ ||
token === 37 /* AsteriskToken */ ||
@@ -11505,12 +11524,15 @@ var ts;
}
function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) {
var node = createNode(216 /* ModuleDeclaration */, fullStart);
+ // If we are parsing a dotted namespace name, we want to
+ // propagate the 'Namespace' flag across the names if set.
+ var namespaceFlag = flags & 131072 /* Namespace */;
node.decorators = decorators;
setModifiers(node, modifiers);
node.flags |= flags;
node.name = parseIdentifier();
node.body = parseOptional(21 /* DotToken */)
- ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */)
+ ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag)
: parseModuleBlock();
return finishNode(node);
}
@@ -11844,7 +11866,7 @@ var ts;
case 95 /* ThisKeyword */:
return true;
}
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
JSDocParser.isJSDocType = isJSDocType;
function parseJSDocTypeExpressionForTests(content, start, length) {
@@ -13734,7 +13756,7 @@ var ts;
// Module names are escaped in our symbol table. However, string literal values aren't.
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text);
- if (!moduleName) {
+ if (moduleName === undefined) {
return;
}
var isRelative = isExternalModuleNameRelative(moduleName);
@@ -13744,8 +13766,8 @@ var ts;
return symbol;
}
}
- var fileName = ts.getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text);
- var sourceFile = fileName && host.getSourceFile(fileName);
+ var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text);
+ var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName);
if (sourceFile) {
if (sourceFile.symbol) {
return sourceFile.symbol;
@@ -15038,7 +15060,7 @@ var ts;
}
// If the declaration specifies a binding pattern, use the type implied by the binding pattern
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false);
}
// No type specified and nothing can be inferred
return undefined;
@@ -15046,45 +15068,45 @@ var ts;
// Return the type implied by a binding pattern element. This is the type of the initializer of the element if
// one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding
// pattern. Otherwise, it is the type any.
- function getTypeFromBindingElement(element) {
+ function getTypeFromBindingElement(element, includePatternInType) {
if (element.initializer) {
return getWidenedType(checkExpressionCached(element.initializer));
}
if (ts.isBindingPattern(element.name)) {
- return getTypeFromBindingPattern(element.name);
+ return getTypeFromBindingPattern(element.name, includePatternInType);
}
return anyType;
}
// Return the type implied by an object binding pattern
- function getTypeFromObjectBindingPattern(pattern) {
+ function getTypeFromObjectBindingPattern(pattern, includePatternInType) {
var members = {};
ts.forEach(pattern.elements, function (e) {
var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0);
var name = e.propertyName || e.name;
var symbol = createSymbol(flags, name.text);
- symbol.type = getTypeFromBindingElement(e);
+ symbol.type = getTypeFromBindingElement(e, includePatternInType);
+ symbol.bindingElement = e;
members[symbol.name] = symbol;
});
- return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ if (includePatternInType) {
+ result.pattern = pattern;
+ }
+ return result;
}
// Return the type implied by an array binding pattern
- function getTypeFromArrayBindingPattern(pattern) {
- var hasSpreadElement = false;
- var elementTypes = [];
- ts.forEach(pattern.elements, function (e) {
- elementTypes.push(e.kind === 185 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e));
- if (e.dotDotDotToken) {
- hasSpreadElement = true;
- }
- });
- if (!elementTypes.length) {
+ function getTypeFromArrayBindingPattern(pattern, includePatternInType) {
+ var elements = pattern.elements;
+ if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) {
return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType;
}
- else if (hasSpreadElement) {
- var unionOfElements = getUnionType(elementTypes);
- return languageVersion >= 2 /* ES6 */ ? createIterableType(unionOfElements) : createArrayType(unionOfElements);
- }
// If the pattern has at least one element, and no rest element, then it should imply a tuple type.
+ var elementTypes = ts.map(elements, function (e) { return e.kind === 185 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); });
+ if (includePatternInType) {
+ var result = createNewTupleType(elementTypes);
+ result.pattern = pattern;
+ return result;
+ }
return createTupleType(elementTypes);
}
// Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself
@@ -15094,10 +15116,10 @@ var ts;
// used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring
// parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of
// the parameter.
- function getTypeFromBindingPattern(pattern) {
+ function getTypeFromBindingPattern(pattern, includePatternInType) {
return pattern.kind === 159 /* ObjectBindingPattern */
- ? getTypeFromObjectBindingPattern(pattern)
- : getTypeFromArrayBindingPattern(pattern);
+ ? getTypeFromObjectBindingPattern(pattern, includePatternInType)
+ : getTypeFromArrayBindingPattern(pattern, includePatternInType);
}
// Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type
// specified in a type annotation or inferred from an initializer. However, in the case of a destructuring declaration it
@@ -16565,11 +16587,11 @@ var ts;
}
function createTupleType(elementTypes) {
var id = getTypeListId(elementTypes);
- var type = tupleTypes[id];
- if (!type) {
- type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes));
- type.elementTypes = elementTypes;
- }
+ return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes));
+ }
+ function createNewTupleType(elementTypes) {
+ var type = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes));
+ type.elementTypes = elementTypes;
return type;
}
function getTypeFromTupleTypeNode(node) {
@@ -17021,7 +17043,7 @@ var ts;
* @param target The right-hand-side of the relation.
* @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'.
* Used as both to determine which checks are performed and as a cache of previously computed results.
- * @param errorNode The node upon which all errors will be reported, if defined.
+ * @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used.
* @param headMessage If the error chain should be prepended by a head message, then headMessage will be used.
* @param containingMessageChain A chain of errors to prepend any new errors found.
*/
@@ -17106,7 +17128,9 @@ var ts;
// and intersection types are further deconstructed on the target side, we don't want to
// make the check again (as it might fail for a partial target type). Therefore we obtain
// the regular source type and proceed with that.
- source = getRegularTypeOfObjectLiteral(source);
+ if (target.flags & 49152 /* UnionOrIntersection */) {
+ source = getRegularTypeOfObjectLiteral(source);
+ }
}
var saveErrorInfo = errorInfo;
// Note that the "each" checks must precede the "some" checks to produce the correct results
@@ -17228,6 +17252,10 @@ var ts;
var prop = _a[_i];
if (!isKnownProperty(target, prop.name)) {
if (reportErrors) {
+ // We know *exactly* where things went wrong when comparing the types.
+ // Use this property as the error node as this will be more helpful in
+ // reasoning about what went wrong.
+ errorNode = prop.valueDeclaration;
reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target));
}
return true;
@@ -17550,8 +17578,8 @@ var ts;
return result;
function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) {
if (sourceSig && targetSig) {
- var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212 /* ClassDeclaration */);
- var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212 /* ClassDeclaration */);
+ var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol);
+ var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol);
if (!sourceDecl) {
// If the source object isn't itself a class declaration, it can be freely assigned, regardless
// of whether the constructed object is abstract or not.
@@ -17561,8 +17589,8 @@ var ts;
var targetErasedSignature = getErasedSignature(targetSig);
var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
- var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212 /* ClassDeclaration */);
- var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212 /* ClassDeclaration */);
+ var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol);
+ var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol);
var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */;
var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */;
if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) {
@@ -17911,6 +17939,7 @@ var ts;
regularType.constructSignatures = type.constructSignatures;
regularType.stringIndexType = type.stringIndexType;
regularType.numberIndexType = type.numberIndexType;
+ type.regularType = regularType;
}
return regularType;
}
@@ -18932,7 +18961,7 @@ var ts;
}
}
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true);
}
}
return undefined;
@@ -19290,11 +19319,12 @@ var ts;
var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false);
}
+ function hasDefaultValue(node) {
+ return (node.kind === 161 /* BindingElement */ && !!node.initializer) ||
+ (node.kind === 179 /* BinaryExpression */ && node.operatorToken.kind === 55 /* EqualsToken */);
+ }
function checkArrayLiteral(node, contextualMapper) {
var elements = node.elements;
- if (!elements.length) {
- return createArrayType(undefinedType);
- }
var hasSpreadElement = false;
var elementTypes = [];
var inDestructuringPattern = isAssignmentTarget(node);
@@ -19327,12 +19357,39 @@ var ts;
hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */;
}
if (!hasSpreadElement) {
+ // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such
+ // that we get the same behavior for "var [x, y] = []" and "[x, y] = []".
+ if (inDestructuringPattern && elementTypes.length) {
+ var type = createNewTupleType(elementTypes);
+ type.pattern = node;
+ return type;
+ }
var contextualType = getContextualType(node);
- if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) {
- return createTupleType(elementTypes);
+ if (contextualType && contextualTypeIsTupleLikeType(contextualType)) {
+ var pattern = contextualType.pattern;
+ // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting
+ // tuple type with the corresponding binding or assignment element types to make the lengths equal.
+ if (pattern && (pattern.kind === 160 /* ArrayBindingPattern */ || pattern.kind === 162 /* ArrayLiteralExpression */)) {
+ var patternElements = pattern.elements;
+ for (var i = elementTypes.length; i < patternElements.length; i++) {
+ var patternElement = patternElements[i];
+ if (hasDefaultValue(patternElement)) {
+ elementTypes.push(contextualType.elementTypes[i]);
+ }
+ else {
+ if (patternElement.kind !== 185 /* OmittedExpression */) {
+ error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ elementTypes.push(unknownType);
+ }
+ }
+ }
+ if (elementTypes.length) {
+ return createTupleType(elementTypes);
+ }
}
}
- return createArrayType(getUnionType(elementTypes));
+ return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType);
}
function isNumericName(name) {
return name.kind === 134 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text);
@@ -19390,6 +19447,9 @@ var ts;
var propertiesTable = {};
var propertiesArray = [];
var contextualType = getContextualType(node);
+ var contextualTypeHasPattern = contextualType && contextualType.pattern &&
+ (contextualType.pattern.kind === 159 /* ObjectBindingPattern */ || contextualType.pattern.kind === 163 /* ObjectLiteralExpression */);
+ var inDestructuringPattern = isAssignmentTarget(node);
var typeFlags = 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var memberDecl = _a[_i];
@@ -19410,6 +19470,24 @@ var ts;
}
typeFlags |= type.flags;
var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name);
+ if (inDestructuringPattern) {
+ // If object literal is an assignment pattern and if the assignment pattern specifies a default value
+ // for the property, make the property optional.
+ if (memberDecl.kind === 243 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) {
+ prop.flags |= 536870912 /* Optional */;
+ }
+ }
+ else if (contextualTypeHasPattern) {
+ // If object literal is contextually typed by the implied type of a binding pattern, and if the
+ // binding pattern specifies a default value for the property, make the property optional.
+ var impliedProp = getPropertyOfType(contextualType, member.name);
+ if (impliedProp) {
+ prop.flags |= impliedProp.flags & 536870912 /* Optional */;
+ }
+ else if (!compilerOptions.suppressExcessPropertyErrors) {
+ error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
+ }
+ }
prop.declarations = member.declarations;
prop.parent = member.parent;
if (member.valueDeclaration) {
@@ -19433,11 +19511,28 @@ var ts;
}
propertiesArray.push(member);
}
+ // If object literal is contextually typed by the implied type of a binding pattern, augment the result
+ // type with those properties for which the binding pattern specifies a default value.
+ if (contextualTypeHasPattern) {
+ for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) {
+ var prop = _c[_b];
+ if (!ts.hasProperty(propertiesTable, prop.name)) {
+ if (!(prop.flags & 536870912 /* Optional */)) {
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ propertiesTable[prop.name] = prop;
+ propertiesArray.push(prop);
+ }
+ }
+ }
var stringIndexType = getIndexType(0 /* String */);
var numberIndexType = getIndexType(1 /* Number */);
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */;
result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */);
+ if (inDestructuringPattern) {
+ result.pattern = node;
+ }
return result;
function getIndexType(kind) {
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
@@ -20946,7 +21041,7 @@ var ts;
// Note, only class declarations can be declared abstract.
// In the case of a merged class-module or class-interface declaration,
// only the class declaration node will have the Abstract flag set.
- var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212 /* ClassDeclaration */);
+ var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol);
if (valueDecl && valueDecl.flags & 256 /* Abstract */) {
error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name));
return resolveErrorCall(node);
@@ -24257,6 +24352,9 @@ var ts;
// so we'll need to get back original 'target' symbol to work with correct set of flags
return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s;
}
+ function getClassLikeDeclarationOfSymbol(symbol) {
+ return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; });
+ }
function checkKindsOfPropertyMemberOverrides(type, baseType) {
// TypeScript 1.0 spec (April 2014): 8.2.3
// A derived class inherits all members from its base class it doesn't override.
@@ -24288,12 +24386,17 @@ var ts;
// type declaration, derived and base resolve to the same symbol even in the case of generic classes.
if (derived === base) {
// derived class inherits base without override/redeclaration
- var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212 /* ClassDeclaration */);
+ var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol);
// It is an error to inherit an abstract member without implementing it or being declared abstract.
// If there is no declaration for the derived class (as in the case of class expressions),
// then the class cannot be declared abstract.
if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) {
- error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ if (derivedClassDecl.kind === 184 /* ClassExpression */) {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
+ }
+ else {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ }
}
}
else {
@@ -25637,7 +25740,10 @@ var ts;
var symbols = [];
var name_15 = symbol.name;
ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) {
- symbols.push(getPropertyOfType(t, name_15));
+ var symbol = getPropertyOfType(t, name_15);
+ if (symbol) {
+ symbols.push(symbol);
+ }
});
return symbols;
}
@@ -28602,6 +28708,8 @@ var ts;
var scopeEmitEnd = function () { };
/** Sourcemap data that will get encoded */
var sourceMapData;
+ /** If removeComments is true, no leading-comments needed to be emitted **/
+ var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker;
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
initializeEmitterWithSourceMaps();
}
@@ -29561,8 +29669,10 @@ var ts;
function jsxEmitPreserve(node) {
function emitJsxAttribute(node) {
emit(node.name);
- write("=");
- emit(node.initializer);
+ if (node.initializer) {
+ write("=");
+ emit(node.initializer);
+ }
}
function emitJsxSpreadAttribute(node) {
write("{...");
@@ -30510,7 +30620,8 @@ var ts;
operand.kind !== 178 /* PostfixUnaryExpression */ &&
operand.kind !== 167 /* NewExpression */ &&
!(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) &&
- !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */)) {
+ !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */) &&
+ !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 164 /* PropertyAccessExpression */)) {
emit(operand);
return;
}
@@ -31215,6 +31326,9 @@ var ts;
}
function emitExportSpecifierInSystemModule(specifier) {
ts.Debug.assert(compilerOptions.module === 4 /* System */);
+ if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) {
+ return;
+ }
writeLine();
emitStart(specifier.name);
write(exportFunctionForFile + "(\"");
@@ -31270,21 +31384,30 @@ var ts;
write(")");
}
}
- function ensureIdentifier(expr) {
- if (expr.kind !== 67 /* Identifier */) {
- var identifier = createTempVariable(0 /* Auto */);
- if (!canDefineTempVariablesInPlace) {
- recordTempDeclaration(identifier);
- }
- emitAssignment(identifier, expr);
- expr = identifier;
+ /**
+ * Ensures that there exists a declared identifier whose value holds the given expression.
+ * This function is useful to ensure that the expression's value can be read from in subsequent expressions.
+ * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier.
+ *
+ * @param expr the expression whose value needs to be bound.
+ * @param reuseIdentifierExpressions true if identifier expressions can simply be returned;
+ * false if it is necessary to always emit an identifier.
+ */
+ function ensureIdentifier(expr, reuseIdentifierExpressions) {
+ if (expr.kind === 67 /* Identifier */ && reuseIdentifierExpressions) {
+ return expr;
}
- return expr;
+ var identifier = createTempVariable(0 /* Auto */);
+ if (!canDefineTempVariablesInPlace) {
+ recordTempDeclaration(identifier);
+ }
+ emitAssignment(identifier, expr);
+ return identifier;
}
function createDefaultValueCheck(value, defaultValue) {
// The value expression will be evaluated twice, so for anything but a simple identifier
// we need to generate a temporary variable
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
// Return the expression 'value === void 0 ? defaultValue : value'
var equals = ts.createSynthesizedNode(179 /* BinaryExpression */);
equals.left = value;
@@ -31330,7 +31453,7 @@ var ts;
if (properties.length !== 1) {
// For anything but a single element destructuring we need to generate a temporary
// to ensure value is evaluated exactly once.
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
}
for (var _a = 0; _a < properties.length; _a++) {
var p = properties[_a];
@@ -31345,7 +31468,7 @@ var ts;
if (elements.length !== 1) {
// For anything but a single element destructuring we need to generate a temporary
// to ensure value is evaluated exactly once.
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
}
for (var i = 0; i < elements.length; i++) {
var e = elements[i];
@@ -31387,7 +31510,7 @@ var ts;
if (root.parent.kind !== 170 /* ParenthesizedExpression */) {
write("(");
}
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
emitDestructuringAssignment(target, value);
write(", ");
emit(value);
@@ -31408,12 +31531,15 @@ var ts;
if (ts.isBindingPattern(target.name)) {
var pattern = target.name;
var elements = pattern.elements;
- if (elements.length !== 1) {
- // For anything but a single element destructuring we need to generate a temporary
- // to ensure value is evaluated exactly once.
- value = ensureIdentifier(value);
+ var numElements = elements.length;
+ if (numElements !== 1) {
+ // For anything other than a single-element destructuring we need to generate a temporary
+ // to ensure value is evaluated exactly once. Additionally, if we have zero elements
+ // we need to emit *something* to ensure that in case a 'var' keyword was already emitted,
+ // so in that case, we'll intentionally create that temporary.
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0);
}
- for (var i = 0; i < elements.length; i++) {
+ for (var i = 0; i < numElements; i++) {
var element = elements[i];
if (pattern.kind === 159 /* ObjectBindingPattern */) {
// Rewrite element to a declaration with an initializer that fetches property
@@ -31425,7 +31551,7 @@ var ts;
// Rewrite element to a declaration that accesses array element at index i
emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i)));
}
- else if (i === elements.length - 1) {
+ else if (i === numElements - 1) {
emitBindingElement(element, createSliceCall(value, i));
}
}
@@ -31686,7 +31812,7 @@ var ts;
}
function emitFunctionDeclaration(node) {
if (ts.nodeIsMissing(node.body)) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
// TODO (yuisu) : we should not have special cases to condition emitting comments
// but have one place to fix check for these conditions.
@@ -32112,7 +32238,7 @@ var ts;
}
else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) {
if (!member.body) {
- return emitOnlyPinnedOrTripleSlashComments(member);
+ return emitCommentsOnNotEmittedNode(member);
}
writeLine();
emitLeadingComments(member);
@@ -32178,7 +32304,7 @@ var ts;
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
else if (member.kind === 141 /* MethodDeclaration */ ||
member.kind === 143 /* GetAccessor */ ||
@@ -32229,7 +32355,7 @@ var ts;
// Emit the constructor overload pinned comments
ts.forEach(node.members, function (member) {
if (member.kind === 142 /* Constructor */ && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
// Check if there is any non-static property assignment
if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) {
@@ -32840,50 +32966,49 @@ var ts;
write("void 0");
}
function emitSerializedTypeNode(node) {
- if (!node) {
- return;
- }
- switch (node.kind) {
- case 101 /* VoidKeyword */:
- write("void 0");
- return;
- case 158 /* ParenthesizedType */:
- emitSerializedTypeNode(node.type);
- return;
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
- write("Function");
- return;
- case 154 /* ArrayType */:
- case 155 /* TupleType */:
- write("Array");
- return;
- case 148 /* TypePredicate */:
- case 118 /* BooleanKeyword */:
- write("Boolean");
- return;
- case 128 /* StringKeyword */:
- case 9 /* StringLiteral */:
- write("String");
- return;
- case 126 /* NumberKeyword */:
- write("Number");
- return;
- case 129 /* SymbolKeyword */:
- write("Symbol");
- return;
- case 149 /* TypeReference */:
- emitSerializedTypeReferenceNode(node);
- return;
- case 152 /* TypeQuery */:
- case 153 /* TypeLiteral */:
- case 156 /* UnionType */:
- case 157 /* IntersectionType */:
- case 115 /* AnyKeyword */:
- break;
- default:
- ts.Debug.fail("Cannot serialize unexpected type node.");
- break;
+ if (node) {
+ switch (node.kind) {
+ case 101 /* VoidKeyword */:
+ write("void 0");
+ return;
+ case 158 /* ParenthesizedType */:
+ emitSerializedTypeNode(node.type);
+ return;
+ case 150 /* FunctionType */:
+ case 151 /* ConstructorType */:
+ write("Function");
+ return;
+ case 154 /* ArrayType */:
+ case 155 /* TupleType */:
+ write("Array");
+ return;
+ case 148 /* TypePredicate */:
+ case 118 /* BooleanKeyword */:
+ write("Boolean");
+ return;
+ case 128 /* StringKeyword */:
+ case 9 /* StringLiteral */:
+ write("String");
+ return;
+ case 126 /* NumberKeyword */:
+ write("Number");
+ return;
+ case 129 /* SymbolKeyword */:
+ write("Symbol");
+ return;
+ case 149 /* TypeReference */:
+ emitSerializedTypeReferenceNode(node);
+ return;
+ case 152 /* TypeQuery */:
+ case 153 /* TypeLiteral */:
+ case 156 /* UnionType */:
+ case 157 /* IntersectionType */:
+ case 115 /* AnyKeyword */:
+ break;
+ default:
+ ts.Debug.fail("Cannot serialize unexpected type node.");
+ break;
+ }
}
write("Object");
}
@@ -33034,7 +33159,7 @@ var ts;
return argumentsWritten;
}
function emitInterfaceDeclaration(node) {
- emitOnlyPinnedOrTripleSlashComments(node);
+ emitCommentsOnNotEmittedNode(node);
}
function shouldEmitEnumDeclaration(node) {
var isConstEnum = ts.isConst(node);
@@ -33146,7 +33271,7 @@ var ts;
// Emit only if this module is non-ambient.
var shouldEmit = shouldEmitModuleDeclaration(node);
if (!shouldEmit) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node);
var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node);
@@ -33875,7 +34000,7 @@ var ts;
}
return;
}
- if (ts.isInternalModuleImportEqualsDeclaration(node)) {
+ if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) {
if (!hoistedVars) {
hoistedVars = [];
}
@@ -34438,7 +34563,7 @@ var ts;
function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) {
if (node) {
if (node.flags & 2 /* Ambient */) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
if (isSpecializedCommentHandling(node)) {
// This is the node that will handle its own comments and sourcemap
@@ -34686,21 +34811,27 @@ var ts;
}
return leadingComments;
}
+ function isPinnedComments(comment) {
+ return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
+ }
/**
- * Removes all but the pinned or triple slash comments.
- * @param ranges The array to be filtered
- * @param onlyPinnedOrTripleSlashComments whether the filtering should be performed.
- */
- function filterComments(ranges, onlyPinnedOrTripleSlashComments) {
- // If we're removing comments, then we want to strip out all but the pinned or
- // triple slash comments.
- if (ranges && onlyPinnedOrTripleSlashComments) {
- ranges = ts.filter(ranges, isPinnedOrTripleSlashComment);
- if (ranges.length === 0) {
- return undefined;
- }
+ * Determine if the given comment is a triple-slash
+ *
+ * @return true if the comment is a triple-slash comment else false
+ **/
+ function isTripleSlashComment(comment) {
+ // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
+ // so that we don't end up computing comment string and doing match for all // comments
+ if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ &&
+ comment.pos + 2 < comment.end &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) {
+ var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end);
+ return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
+ textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ?
+ true : false;
}
- return ranges;
+ return false;
}
function getLeadingCommentsToEmit(node) {
// Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments
@@ -34725,23 +34856,46 @@ var ts;
}
}
}
- function emitOnlyPinnedOrTripleSlashComments(node) {
- emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true);
+ /**
+ * Emit comments associated with node that will not be emitted into JS file
+ */
+ function emitCommentsOnNotEmittedNode(node) {
+ emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false);
}
function emitLeadingComments(node) {
- return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true);
}
- function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) {
- // If the caller only wants pinned or triple slash comments, then always filter
- // down to that set. Otherwise, filter based on the current compiler options.
- var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments);
+ function emitLeadingCommentsWorker(node, isEmittedNode) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var leadingComments;
+ if (isEmittedNode) {
+ leadingComments = getLeadingCommentsToEmit(node);
+ }
+ else {
+ // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node,
+ // unless it is a triple slash comment at the top of the file.
+ // For Example:
+ // ///
+ // declare var x;
+ // ///
+ // interface F {}
+ // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted
+ if (node.pos === 0) {
+ leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment);
+ }
+ }
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
- ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
+ ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment);
}
function emitTrailingComments(node) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
// Emit the trailing comments only if the parent's end doesn't match
- var trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ var trailingComments = getTrailingCommentsToEmit(node);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment);
}
@@ -34751,11 +34905,17 @@ var ts;
* ^ => pos; the function will emit "comment1" in the emitJS
*/
function emitTrailingCommentsOfPosition(pos) {
- var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment);
}
- function emitLeadingCommentsOfPosition(pos) {
+ function emitLeadingCommentsOfPositionWorker(pos) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
var leadingComments;
if (hasDetachedComments(pos)) {
// get comments without detached comments
@@ -34765,13 +34925,26 @@ var ts;
// get the leading comments from the node
leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos);
}
- leadingComments = filterComments(leadingComments, compilerOptions.removeComments);
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
}
function emitDetachedComments(node) {
- var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ var leadingComments;
+ if (compilerOptions.removeComments) {
+ // removeComments is true, only reserve pinned comment at the top of file
+ // For example:
+ // /*! Pinned Comment */
+ //
+ // var x = 10;
+ if (node.pos === 0) {
+ leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments);
+ }
+ }
+ else {
+ // removeComments is false, just get detached as normal and bypass the process to filter comment
+ leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ }
if (leadingComments) {
var detachedComments = [];
var lastComment;
@@ -34816,17 +34989,6 @@ var ts;
write(shebang);
}
}
- function isPinnedOrTripleSlashComment(comment) {
- if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) {
- return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
- }
- else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ &&
- comment.pos + 2 < comment.end &&
- currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */ &&
- currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) {
- return true;
- }
- }
}
function emitFile(jsFilePath, sourceFile) {
emitJavaScript(jsFilePath, sourceFile);
@@ -35103,7 +35265,7 @@ var ts;
/* @internal */ ts.ioWriteTime = 0;
/** The version of the TypeScript compiler release */
var emptyArray = [];
- ts.version = "1.6.0";
+ ts.version = "1.7.0";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@@ -35143,10 +35305,12 @@ var ts;
var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
if (resolvedFileName) {
- return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations };
}
resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
- return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
+ return resolvedFileName
+ ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }
+ : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
}
else {
return loadModuleFromNodeModules(moduleName, containingDirectory, host);
@@ -35206,11 +35370,11 @@ var ts;
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName));
var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
if (result) {
- return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations };
}
result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
if (result) {
- return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations };
}
}
var parentPath = ts.getDirectoryPath(directory);
@@ -35219,39 +35383,16 @@ var ts;
}
directory = parentPath;
}
- return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
}
- function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) {
- ts.Debug.assert(baseUrl !== undefined);
- var normalizedModuleName = ts.normalizeSlashes(moduleName);
- var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile);
- var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName));
- var failedLookupLocations = [];
- return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
- function tryLoadFile(location) {
- if (host.fileExists(location)) {
- return { resolvedFileName: location, failedLookupLocations: failedLookupLocations };
- }
- else {
- failedLookupLocations.push(location);
- return undefined;
- }
- }
- }
- ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver;
function nameStartsWithDotSlashOrDotDotSlash(name) {
var i = name.lastIndexOf("./", 1);
return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */);
}
- function useBaseUrl(moduleName) {
- // path is not rooted
- // module name does not start with './' or '../'
- return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName);
- }
function classicNameResolver(moduleName, containingFile, compilerOptions, host) {
// module names that contain '!' are used to reference resources and are not resolved to actual files on disk
if (moduleName.indexOf('!') != -1) {
- return { resolvedFileName: undefined, failedLookupLocations: [] };
+ return { resolvedModule: undefined, failedLookupLocations: [] };
}
var searchPath = ts.getDirectoryPath(containingFile);
var searchName;
@@ -35282,7 +35423,9 @@ var ts;
}
searchPath = parentPath;
}
- return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations };
+ return referencedSourceFile
+ ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations }
+ : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
}
ts.classicNameResolver = classicNameResolver;
/* @internal */
@@ -35399,7 +35542,8 @@ var ts;
function createProgram(rootNames, options, host, oldProgram) {
var program;
var files = [];
- var diagnostics = ts.createDiagnosticCollection();
+ var fileProcessingDiagnostics = ts.createDiagnosticCollection();
+ var programDiagnostics = ts.createDiagnosticCollection();
var commonSourceDirectory;
var diagnosticsProducingTypeChecker;
var noDiagnosticsTypeChecker;
@@ -35407,8 +35551,9 @@ var ts;
var skipDefaultLib = options.noLib;
var start = new Date().getTime();
host = host || createCompilerHost(options);
- var resolveModuleNamesWorker = host.resolveModuleNames ||
- (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedFileName; }); });
+ var resolveModuleNamesWorker = host.resolveModuleNames
+ ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); })
+ : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); });
var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); });
if (oldProgram) {
// check properties that can affect structure of the program or module resolution strategy
@@ -35455,7 +35600,8 @@ var ts;
getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
- getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }
+ getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
+ getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }
};
return program;
function getClassifiableNames() {
@@ -35482,6 +35628,7 @@ var ts;
}
// check if program source files has changed in the way that can affect structure of the program
var newSourceFiles = [];
+ var modifiedSourceFiles = [];
for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) {
var oldSourceFile = _a[_i];
var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target);
@@ -35510,14 +35657,21 @@ var ts;
var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName);
// ensure that module resolution results are still correct
for (var i = 0; i < moduleNames.length; ++i) {
- var oldResolution = ts.getResolvedModuleFileName(oldSourceFile, moduleNames[i]);
- if (oldResolution !== resolutions[i]) {
+ var newResolution = resolutions[i];
+ var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]);
+ var resolutionChanged = oldResolution
+ ? !newResolution ||
+ oldResolution.resolvedFileName !== newResolution.resolvedFileName ||
+ !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport
+ : newResolution;
+ if (resolutionChanged) {
return false;
}
}
}
// pass the cache of module resolutions from the old source file
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
+ modifiedSourceFiles.push(newSourceFile);
}
else {
// file has no changes - use it as is
@@ -35532,6 +35686,11 @@ var ts;
filesByName.set(file.fileName, file);
}
files = newSourceFiles;
+ fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
+ for (var _c = 0; _c < modifiedSourceFiles.length; _c++) {
+ var modifiedFile = modifiedSourceFiles[_c];
+ fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile);
+ }
oldProgram.structureIsReused = true;
return true;
}
@@ -35633,8 +35792,9 @@ var ts;
ts.Debug.assert(!!sourceFile.bindDiagnostics);
var bindDiagnostics = sourceFile.bindDiagnostics;
var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken);
- var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
- return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics);
+ var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
+ var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
+ return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile);
});
}
function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) {
@@ -35649,7 +35809,8 @@ var ts;
}
function getOptionsDiagnostics() {
var allDiagnostics = [];
- ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
+ ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics());
+ ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics());
return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
}
function getGlobalDiagnostics() {
@@ -35747,10 +35908,10 @@ var ts;
}
if (diagnostic) {
if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) {
- diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument)));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument)));
}
else {
- diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument)));
+ fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument)));
}
}
}
@@ -35770,10 +35931,10 @@ var ts;
// We haven't looked for this file, do so now and cache result
var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) {
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
- diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
}
else {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
+ fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
}
});
filesByName.set(canonicalName, file);
@@ -35803,10 +35964,10 @@ var ts;
var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName;
if (canonicalName !== sourceFileName) {
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
- diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
}
else {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
+ fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
}
}
}
@@ -35827,9 +35988,23 @@ var ts;
var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName);
for (var i = 0; i < file.imports.length; ++i) {
var resolution = resolutions[i];
- ts.setResolvedModuleName(file, moduleNames[i], resolution);
+ ts.setResolvedModule(file, moduleNames[i], resolution);
if (resolution && !options.noResolve) {
- findModuleSourceFile(resolution, file.imports[i]);
+ var importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]);
+ if (importedFile && resolution.isExternalLibraryImport) {
+ if (!ts.isExternalModule(importedFile)) {
+ var start_2 = ts.getTokenPosOfNode(file.imports[i], file);
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
+ }
+ else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) {
+ var start_3 = ts.getTokenPosOfNode(file.imports[i], file);
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_3, file.imports[i].end - start_3, ts.Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition));
+ }
+ else if (importedFile.referencedFiles.length) {
+ var firstRef = importedFile.referencedFiles[0];
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition));
+ }
+ }
}
}
}
@@ -35839,7 +36014,7 @@ var ts;
}
return;
function findModuleSourceFile(fileName, nameLiteral) {
- return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end);
+ return findSourceFile(fileName, /* isDefaultLib */ false, file, ts.skipTrivia(file.text, nameLiteral.pos), nameLiteral.end);
}
}
function computeCommonSourceDirectory(sourceFiles) {
@@ -35860,7 +36035,7 @@ var ts;
for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) {
if (commonPathComponents[i] !== sourcePathComponents[i]) {
if (i === 0) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
return;
}
// New common path found that is 0 -> i-1
@@ -35885,7 +36060,7 @@ var ts;
if (!ts.isDeclarationFile(sourceFile)) {
var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
allFilesBelongToPath = false;
}
}
@@ -35896,44 +36071,44 @@ var ts;
function verifyCompilerOptions() {
if (options.isolatedModules) {
if (options.declaration) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules"));
}
if (options.noEmitOnError) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules"));
}
if (options.out) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"));
}
if (options.outFile) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules"));
}
}
if (options.inlineSourceMap) {
if (options.sourceMap) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap"));
}
if (options.mapRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
}
if (options.sourceRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
}
}
if (options.inlineSources) {
if (!options.sourceMap && !options.inlineSourceMap) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
}
}
if (options.out && options.outFile) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
}
if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) {
// Error to specify --mapRoot or --sourceRoot without mapSourceFiles
if (options.mapRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
}
if (options.sourceRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
}
return;
}
@@ -35942,22 +36117,22 @@ var ts;
var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; });
if (options.isolatedModules) {
if (!options.module && languageVersion < 2 /* ES6 */) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
}
var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; });
if (firstNonExternalModuleSourceFile) {
var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
- diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) {
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
- diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
}
// Cannot specify module gen target when in es6 or above
if (options.module && languageVersion >= 2 /* ES6 */) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
}
// there has to be common source directory if user specified --outdir || --sourceRoot
// if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted
@@ -35982,25 +36157,25 @@ var ts;
}
if (options.noEmit) {
if (options.out) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));
}
if (options.outFile) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile"));
}
if (options.outDir) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir"));
}
if (options.declaration) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
}
}
if (options.emitDecoratorMetadata &&
!options.experimentalDecorators) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
}
if (options.experimentalAsyncFunctions &&
options.target !== 2 /* ES6 */) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
}
}
}
@@ -36251,8 +36426,8 @@ var ts;
"node": 2 /* NodeJs */,
"classic": 1 /* Classic */
},
- experimental: true,
- description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
+ description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
+ error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic
}
];
var optionNameMapCache;
@@ -36374,10 +36549,10 @@ var ts;
* Read tsconfig.json file
* @param fileName The path to the config file
*/
- function readConfigFile(fileName) {
+ function readConfigFile(fileName, readFile) {
var text = "";
try {
- text = ts.sys.readFile(fileName);
+ text = readFile(fileName);
}
catch (e) {
return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
@@ -38721,7 +38896,7 @@ var ts;
function findPrecedingToken(position, sourceFile, startNode) {
return find(startNode || sourceFile);
function findRightmostToken(n) {
- if (isToken(n)) {
+ if (isToken(n) || n.kind === 234 /* JsxText */) {
return n;
}
var children = n.getChildren();
@@ -38729,23 +38904,32 @@ var ts;
return candidate && findRightmostToken(candidate);
}
function find(n) {
- if (isToken(n)) {
+ if (isToken(n) || n.kind === 234 /* JsxText */) {
return n;
}
var children = n.getChildren();
for (var i = 0, len = children.length; i < len; i++) {
var child = children[i];
- if (nodeHasTokens(child)) {
- if (position <= child.end) {
- if (child.getStart(sourceFile) >= position) {
- // actual start of the node is past the position - previous token should be at the end of previous child
- var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i);
- return candidate && findRightmostToken(candidate);
- }
- else {
- // candidate should be in this node
- return find(child);
- }
+ // condition 'position < child.end' checks if child node end after the position
+ // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc'
+ // aaaa___bbbb___$__ccc
+ // after we found child node with end after the position we check if start of the node is after the position.
+ // if yes - then position is in the trivia and we need to look into the previous child to find the token in question.
+ // if no - position is in the node itself so we should recurse in it.
+ // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia).
+ // if this is the case - then we should assume that token in question is located in previous child.
+ if (position < child.end && (nodeHasTokens(child) || child.kind === 234 /* JsxText */)) {
+ var start = child.getStart(sourceFile);
+ var lookInPreviousChild = (start >= position) ||
+ (child.kind === 234 /* JsxText */ && start === child.end); // whitespace only JsxText
+ if (lookInPreviousChild) {
+ // actual start of the node is past the position - previous token should be at the end of previous child
+ var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i);
+ return candidate && findRightmostToken(candidate);
+ }
+ else {
+ // candidate should be in this node
+ return find(child);
}
}
}
@@ -39162,6 +39346,7 @@ var ts;
ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken";
ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken";
ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken";
+ ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier";
})(ScanAction || (ScanAction = {}));
function getFormattingScanner(sourceFile, startPos, endPos) {
scanner.setText(sourceFile.text);
@@ -39235,6 +39420,18 @@ var ts;
}
return false;
}
+ function shouldRescanJsxIdentifier(node) {
+ if (node.parent) {
+ switch (node.parent.kind) {
+ case 236 /* JsxAttribute */:
+ case 233 /* JsxOpeningElement */:
+ case 235 /* JsxClosingElement */:
+ case 232 /* JsxSelfClosingElement */:
+ return node.kind === 67 /* Identifier */;
+ }
+ }
+ return false;
+ }
function shouldRescanSlashToken(container) {
return container.kind === 10 /* RegularExpressionLiteral */;
}
@@ -39262,7 +39459,9 @@ var ts;
? 2 /* RescanSlashToken */
: shouldRescanTemplateToken(n)
? 3 /* RescanTemplateToken */
- : 0 /* Scan */;
+ : shouldRescanJsxIdentifier(n)
+ ? 4 /* RescanJsxIdentifier */
+ : 0 /* Scan */;
if (lastTokenInfo && expectedScanAction === lastScanAction) {
// readTokenInfo was called before with the same expected scan action.
// No need to re-scan text, return existing 'lastTokenInfo'
@@ -39293,6 +39492,10 @@ var ts;
currentToken = scanner.reScanTemplateToken();
lastScanAction = 3 /* RescanTemplateToken */;
}
+ else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 67 /* Identifier */) {
+ currentToken = scanner.scanJsxIdentifier();
+ lastScanAction = 4 /* RescanJsxIdentifier */;
+ }
else {
lastScanAction = 0 /* Scan */;
}
@@ -39633,7 +39836,7 @@ var ts;
this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments;
this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */);
// Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc)
- this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */]);
+ this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */, 71 /* ClassKeyword */]);
this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */);
// Place a space before open brace in a control flow construct
this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 77 /* DoKeyword */, 98 /* TryKeyword */, 83 /* FinallyKeyword */, 78 /* ElseKeyword */]);
@@ -39666,7 +39869,7 @@ var ts;
this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */, 117 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */));
this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */));
this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */));
@@ -39690,7 +39893,7 @@ var ts;
// Use of module as a function call. e.g.: import m2 = module("m2");
this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Add a space around certain TypeScript keywords
- this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */, 130 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81 /* ExtendsKeyword */, 104 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */));
@@ -39718,20 +39921,8 @@ var ts;
this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */));
// Async-await
this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- // Type alias declaration
- this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// template string
this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- // union type
- this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -39758,11 +39949,8 @@ var ts;
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
- this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
- this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
- this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
- this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
- this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
+ this.SpaceBetweenAsyncAndFunctionKeyword,
+ this.SpaceBetweenTagAndTemplateString,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
@@ -39857,6 +40045,8 @@ var ts;
case 180 /* ConditionalExpression */:
case 187 /* AsExpression */:
case 148 /* TypePredicate */:
+ case 156 /* UnionType */:
+ case 157 /* IntersectionType */:
return true;
// equals in binding elements: function foo([[x, y] = [1, 2]])
case 161 /* BindingElement */:
@@ -39967,6 +40157,7 @@ var ts;
Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) {
switch (node.kind) {
case 212 /* ClassDeclaration */:
+ case 184 /* ClassExpression */:
case 213 /* InterfaceDeclaration */:
case 215 /* EnumDeclaration */:
case 153 /* TypeLiteral */:
@@ -40813,7 +41004,7 @@ var ts;
}
function getDynamicIndentation(node, nodeStartLine, indentation, delta) {
return {
- getIndentationForComment: function (kind) {
+ getIndentationForComment: function (kind, tokenIndentation) {
switch (kind) {
// preceding comment to the token that closes the indentation scope inherits the indentation from the scope
// .. {
@@ -40821,9 +41012,10 @@ var ts;
// }
case 16 /* CloseBraceToken */:
case 20 /* CloseBracketToken */:
+ case 18 /* CloseParenToken */:
return indentation + delta;
}
- return indentation;
+ return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation;
},
getIndentationForToken: function (line, kind) {
if (nodeStartLine !== line && node.decorators) {
@@ -41025,8 +41217,12 @@ var ts;
processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation);
}
if (indentToken) {
- var indentNextTokenOrTrivia = true;
+ var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
+ dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) :
+ -1 /* Unknown */;
if (currentTokenInfo.leadingTrivia) {
+ var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation);
+ var indentNextTokenOrTrivia = true;
for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) {
var triviaItem = _a[_i];
if (!ts.rangeContainsRange(originalRange, triviaItem)) {
@@ -41034,14 +41230,12 @@ var ts;
}
switch (triviaItem.kind) {
case 3 /* MultiLineCommentTrivia */:
- var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia);
indentNextTokenOrTrivia = false;
break;
case 2 /* SingleLineCommentTrivia */:
if (indentNextTokenOrTrivia) {
- var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
- insertIndentation(triviaItem.pos, commentIndentation_1, /*lineAdded*/ false);
+ insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false);
indentNextTokenOrTrivia = false;
}
break;
@@ -41052,8 +41246,7 @@ var ts;
}
}
// indent token only if is it is in target range and does not overlap with any error ranges
- if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
- var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
+ if (tokenIndentation !== -1 /* Unknown */) {
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
lastIndentedLine = tokenStart.line;
indentationOnLastIndentedLine = tokenIndentation;
@@ -41704,6 +41897,7 @@ var ts;
function nodeContentIsAlwaysIndented(kind) {
switch (kind) {
case 212 /* ClassDeclaration */:
+ case 184 /* ClassExpression */:
case 213 /* InterfaceDeclaration */:
case 215 /* EnumDeclaration */:
case 214 /* TypeAliasDeclaration */:
@@ -41728,13 +41922,13 @@ var ts;
case 160 /* ArrayBindingPattern */:
case 159 /* ObjectBindingPattern */:
case 231 /* JsxElement */:
+ case 232 /* JsxSelfClosingElement */:
case 140 /* MethodSignature */:
case 145 /* CallSignature */:
case 146 /* ConstructSignature */:
case 136 /* Parameter */:
case 150 /* FunctionType */:
case 151 /* ConstructorType */:
- case 156 /* UnionType */:
case 158 /* ParenthesizedType */:
case 168 /* TaggedTemplateExpression */:
case 176 /* AwaitExpression */:
@@ -42858,7 +43052,7 @@ var ts;
var sourceMapText;
// Create a compilerHost object to allow the compiler to read and write files
var compilerHost = {
- getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; },
+ getSourceFile: function (fileName, target) { return fileName === ts.normalizeSlashes(inputFileName) ? sourceFile : undefined; },
writeFile: function (name, text, writeByteOrderMark) {
if (ts.fileExtensionIs(name, ".map")) {
ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'");
@@ -43106,6 +43300,7 @@ var ts;
//
// export * from "mod"
// export {a as b} from "mod"
+ // export import i = require("mod")
while (token !== 1 /* EndOfFileToken */) {
if (token === 120 /* DeclareKeyword */) {
// declare module "mod"
@@ -43226,6 +43421,25 @@ var ts;
}
}
}
+ else if (token === 87 /* ImportKeyword */) {
+ token = scanner.scan();
+ if (token === 67 /* Identifier */ || ts.isKeyword(token)) {
+ token = scanner.scan();
+ if (token === 55 /* EqualsToken */) {
+ token = scanner.scan();
+ if (token === 125 /* RequireKeyword */) {
+ token = scanner.scan();
+ if (token === 17 /* OpenParenToken */) {
+ token = scanner.scan();
+ if (token === 9 /* StringLiteral */) {
+ // export import i = require("mod");
+ recordModuleName();
+ }
+ }
+ }
+ }
+ }
+ }
}
token = scanner.scan();
}
@@ -43929,9 +44143,9 @@ var ts;
// Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS|
// Skip this partial identifier and adjust the contextToken to the token that precedes it.
if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) {
- var start_2 = new Date().getTime();
+ var start_4 = new Date().getTime();
contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile);
- log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_2));
+ log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_4));
}
// Find the node where completion is requested on.
// Also determine whether we are trying to complete with members of that node
@@ -44179,13 +44393,13 @@ var ts;
if (contextToken.kind === 9 /* StringLiteral */
|| contextToken.kind === 10 /* RegularExpressionLiteral */
|| ts.isTemplateLiteralKind(contextToken.kind)) {
- var start_3 = contextToken.getStart();
+ var start_5 = contextToken.getStart();
var end = contextToken.getEnd();
// To be "in" one of these literals, the position has to be:
// 1. entirely within the token text.
// 2. at the end position of an unterminated token.
// 3. at the end of a regular expression (due to trailing flags like '/foo/g').
- if (start_3 < position && position < end) {
+ if (start_5 < position && position < end) {
return true;
}
if (position === end) {
@@ -46349,6 +46563,7 @@ var ts;
result.push(getReferenceEntryFromNode(node));
}
break;
+ case 184 /* ClassExpression */:
case 212 /* ClassDeclaration */:
// Make sure the container belongs to the same class
// and has the appropriate static modifier from the original container.
@@ -48557,7 +48772,10 @@ var ts;
if ("getModuleResolutionsForFile" in this.shimHost) {
this.resolveModuleNames = function (moduleNames, containingFile) {
var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile));
- return ts.map(moduleNames, function (name) { return ts.lookUp(resolutionsInFile, name); });
+ return ts.map(moduleNames, function (name) {
+ var result = ts.lookUp(resolutionsInFile, name);
+ return result ? { resolvedFileName: result } : undefined;
+ });
};
}
}
@@ -49104,7 +49322,11 @@ var ts;
var _this = this;
return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () {
var compilerOptions = JSON.parse(compilerOptionsJson);
- return ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host);
+ var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host);
+ return {
+ resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined,
+ failedLookupLocations: result.failedLookupLocations
+ };
});
};
CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) {
diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts
index 3d4418a9750..761ce39d418 100644
--- a/lib/typescriptServices.d.ts
+++ b/lib/typescriptServices.d.ts
@@ -1208,9 +1208,11 @@ declare namespace ts {
UnionOrIntersection = 49152,
StructuredType = 130048,
}
+ type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
interface Type {
flags: TypeFlags;
symbol?: Symbol;
+ pattern?: DestructuringPattern;
}
interface StringLiteralType extends Type {
text: string;
@@ -1237,7 +1239,6 @@ declare namespace ts {
}
interface TupleType extends ObjectType {
elementTypes: Type[];
- baseArrayType: TypeReference;
}
interface UnionOrIntersectionType extends Type {
types: Type[];
@@ -1382,9 +1383,12 @@ declare namespace ts {
}
interface ResolvedModule {
resolvedFileName: string;
+ isExternalLibraryImport?: boolean;
+ }
+ interface ResolvedModuleWithFailedLookupLocations {
+ resolvedModule: ResolvedModule;
failedLookupLocations: string[];
}
- type ModuleNameResolver = (moduleName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost) => ResolvedModule;
interface CompilerHost extends ModuleResolutionHost {
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
getCancellationToken?(): CancellationToken;
@@ -1394,7 +1398,7 @@ declare namespace ts {
getCanonicalFileName(fileName: string): string;
useCaseSensitiveFileNames(): boolean;
getNewLine(): string;
- resolveModuleNames?(moduleNames: string[], containingFile: string): string[];
+ resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
}
interface TextSpan {
start: number;
@@ -1515,10 +1519,9 @@ declare namespace ts {
const version: string;
function findConfigFile(searchPath: string): string;
function resolveTripleslashReference(moduleName: string, containingFile: string): string;
- function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule;
- function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule;
- function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule;
- function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule;
+ function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations;
+ function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations;
+ function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations;
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
@@ -1530,7 +1533,7 @@ declare namespace ts {
* Read tsconfig.json file
* @param fileName The path to the config file
*/
- function readConfigFile(fileName: string): {
+ function readConfigFile(fileName: string, readFile: (path: string) => string): {
config?: any;
error?: Diagnostic;
};
@@ -1649,7 +1652,7 @@ declare namespace ts {
trace?(s: string): void;
error?(s: string): void;
useCaseSensitiveFileNames?(): boolean;
- resolveModuleNames?(moduleNames: string[], containingFile: string): string[];
+ resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
}
interface LanguageService {
cleanupSemanticCache(): void;
diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js
index b4d21639d3b..2c70f56d0a6 100644
--- a/lib/typescriptServices.js
+++ b/lib/typescriptServices.js
@@ -2117,7 +2117,7 @@ var ts;
Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.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: ts.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: ts.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: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
+ An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.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: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." },
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." },
@@ -2288,6 +2288,7 @@ var ts;
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.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: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." },
await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." },
+ Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." },
JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.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: ts.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: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." },
@@ -2300,6 +2301,10 @@ var ts;
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
+ Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." },
+ Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." },
+ Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." },
+ Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.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: ts.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: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -2433,13 +2438,14 @@ var ts;
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" },
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
+ Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." },
Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" },
Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." },
Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." },
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.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: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
- Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
+ Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." },
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
@@ -2491,6 +2497,11 @@ var ts;
///
var ts;
(function (ts) {
+ /* @internal */
+ function tokenIsIdentifierOrKeyword(token) {
+ return token >= 67 /* Identifier */;
+ }
+ ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
var textToToken = {
"abstract": 113 /* AbstractKeyword */,
"any": 115 /* AnyKeyword */,
@@ -3926,7 +3937,7 @@ var ts;
// Scans a JSX identifier; these differ from normal identifiers in that
// they allow dashes
function scanJsxIdentifier() {
- if (token === 67 /* Identifier */) {
+ if (tokenIsIdentifierOrKeyword(token)) {
var firstCharPosition = pos;
while (pos < end) {
var ch = text.charCodeAt(pos);
@@ -5011,21 +5022,21 @@ var ts;
return true;
}
ts.arrayIsEqualTo = arrayIsEqualTo;
- function hasResolvedModuleName(sourceFile, moduleNameText) {
+ function hasResolvedModule(sourceFile, moduleNameText) {
return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText);
}
- ts.hasResolvedModuleName = hasResolvedModuleName;
- function getResolvedModuleFileName(sourceFile, moduleNameText) {
- return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined;
+ ts.hasResolvedModule = hasResolvedModule;
+ function getResolvedModule(sourceFile, moduleNameText) {
+ return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined;
}
- ts.getResolvedModuleFileName = getResolvedModuleFileName;
- function setResolvedModuleName(sourceFile, moduleNameText, resolvedFileName) {
+ ts.getResolvedModule = getResolvedModule;
+ function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
if (!sourceFile.resolvedModules) {
sourceFile.resolvedModules = {};
}
- sourceFile.resolvedModules[moduleNameText] = resolvedFileName;
+ sourceFile.resolvedModules[moduleNameText] = resolvedModule;
}
- ts.setResolvedModuleName = setResolvedModuleName;
+ ts.setResolvedModule = setResolvedModule;
// Returns true if this node contains a parse error anywhere underneath it.
function containsParseError(node) {
aggregateChildData(node);
@@ -5328,6 +5339,7 @@ var ts;
}
ts.getJsDocComments = getJsDocComments;
ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/;
+ ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/;
function isTypeNode(node) {
if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) {
return true;
@@ -6362,11 +6374,21 @@ var ts;
add: add,
getGlobalDiagnostics: getGlobalDiagnostics,
getDiagnostics: getDiagnostics,
- getModificationCount: getModificationCount
+ getModificationCount: getModificationCount,
+ reattachFileDiagnostics: reattachFileDiagnostics
};
function getModificationCount() {
return modificationCount;
}
+ function reattachFileDiagnostics(newFile) {
+ if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) {
+ return;
+ }
+ for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) {
+ var diagnostic = _a[_i];
+ diagnostic.file = newFile;
+ }
+ }
function add(diagnostic) {
var diagnostics;
if (diagnostic.file) {
@@ -8118,10 +8140,10 @@ var ts;
return createIdentifier(isIdentifier(), diagnosticMessage);
}
function parseIdentifierName() {
- return createIdentifier(isIdentifierOrKeyword());
+ return createIdentifier(ts.tokenIsIdentifierOrKeyword(token));
}
function isLiteralPropertyName() {
- return isIdentifierOrKeyword() ||
+ return ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 /* StringLiteral */ ||
token === 8 /* NumericLiteral */;
}
@@ -8141,7 +8163,7 @@ var ts;
return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false);
}
function isSimplePropertyName() {
- return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || isIdentifierOrKeyword();
+ return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || ts.tokenIsIdentifierOrKeyword(token);
}
function parseComputedPropertyName() {
// PropertyName [Yield]:
@@ -8257,9 +8279,9 @@ var ts;
case 20 /* HeritageClauses */:
return isHeritageClause();
case 21 /* ImportOrExportSpecifiers */:
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
case 13 /* JsxAttributes */:
- return isIdentifierOrKeyword() || token === 15 /* OpenBraceToken */;
+ return ts.tokenIsIdentifierOrKeyword(token) || token === 15 /* OpenBraceToken */;
case 14 /* JsxChildren */:
return true;
case 22 /* JSDocFunctionParameters */:
@@ -8292,7 +8314,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeyword() {
nextToken();
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
function isHeritageClauseExtendsOrImplementsKeyword() {
if (token === 104 /* ImplementsKeyword */ ||
@@ -8786,7 +8808,7 @@ var ts;
// the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword".
// In the first case though, ASI will not take effect because there is not a
// line terminator after the identifier or keyword.
- if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) {
+ if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) {
var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
if (matchesPattern) {
// Report that we need an identifier. However, report it right after the dot,
@@ -9170,7 +9192,7 @@ var ts;
return result;
}
}
- if (isIdentifierOrKeyword()) {
+ if (ts.tokenIsIdentifierOrKeyword(token)) {
return parsePropertyOrMethodSignature();
}
}
@@ -10763,12 +10785,9 @@ var ts;
return finishNode(expressionStatement);
}
}
- function isIdentifierOrKeyword() {
- return token >= 67 /* Identifier */;
- }
function nextTokenIsIdentifierOrKeywordOnSameLine() {
nextToken();
- return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak();
+ return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak();
}
function nextTokenIsFunctionKeywordOnSameLine() {
nextToken();
@@ -10776,7 +10795,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() {
nextToken();
- return (isIdentifierOrKeyword() || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak();
+ return (ts.tokenIsIdentifierOrKeyword(token) || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak();
}
function isDeclaration() {
while (true) {
@@ -10826,7 +10845,7 @@ var ts;
case 87 /* ImportKeyword */:
nextToken();
return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ ||
- token === 15 /* OpenBraceToken */ || isIdentifierOrKeyword();
+ token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token);
case 80 /* ExportKeyword */:
nextToken();
if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ ||
@@ -11366,7 +11385,7 @@ var ts;
}
// It is very important that we check this *after* checking indexers because
// the [ token can start an index signature or a computed property name
- if (isIdentifierOrKeyword() ||
+ if (ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 /* StringLiteral */ ||
token === 8 /* NumericLiteral */ ||
token === 37 /* AsteriskToken */ ||
@@ -11505,12 +11524,15 @@ var ts;
}
function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) {
var node = createNode(216 /* ModuleDeclaration */, fullStart);
+ // If we are parsing a dotted namespace name, we want to
+ // propagate the 'Namespace' flag across the names if set.
+ var namespaceFlag = flags & 131072 /* Namespace */;
node.decorators = decorators;
setModifiers(node, modifiers);
node.flags |= flags;
node.name = parseIdentifier();
node.body = parseOptional(21 /* DotToken */)
- ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */)
+ ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag)
: parseModuleBlock();
return finishNode(node);
}
@@ -11844,7 +11866,7 @@ var ts;
case 95 /* ThisKeyword */:
return true;
}
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
JSDocParser.isJSDocType = isJSDocType;
function parseJSDocTypeExpressionForTests(content, start, length) {
@@ -13734,7 +13756,7 @@ var ts;
// Module names are escaped in our symbol table. However, string literal values aren't.
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text);
- if (!moduleName) {
+ if (moduleName === undefined) {
return;
}
var isRelative = isExternalModuleNameRelative(moduleName);
@@ -13744,8 +13766,8 @@ var ts;
return symbol;
}
}
- var fileName = ts.getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text);
- var sourceFile = fileName && host.getSourceFile(fileName);
+ var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text);
+ var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName);
if (sourceFile) {
if (sourceFile.symbol) {
return sourceFile.symbol;
@@ -15038,7 +15060,7 @@ var ts;
}
// If the declaration specifies a binding pattern, use the type implied by the binding pattern
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false);
}
// No type specified and nothing can be inferred
return undefined;
@@ -15046,45 +15068,45 @@ var ts;
// Return the type implied by a binding pattern element. This is the type of the initializer of the element if
// one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding
// pattern. Otherwise, it is the type any.
- function getTypeFromBindingElement(element) {
+ function getTypeFromBindingElement(element, includePatternInType) {
if (element.initializer) {
return getWidenedType(checkExpressionCached(element.initializer));
}
if (ts.isBindingPattern(element.name)) {
- return getTypeFromBindingPattern(element.name);
+ return getTypeFromBindingPattern(element.name, includePatternInType);
}
return anyType;
}
// Return the type implied by an object binding pattern
- function getTypeFromObjectBindingPattern(pattern) {
+ function getTypeFromObjectBindingPattern(pattern, includePatternInType) {
var members = {};
ts.forEach(pattern.elements, function (e) {
var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0);
var name = e.propertyName || e.name;
var symbol = createSymbol(flags, name.text);
- symbol.type = getTypeFromBindingElement(e);
+ symbol.type = getTypeFromBindingElement(e, includePatternInType);
+ symbol.bindingElement = e;
members[symbol.name] = symbol;
});
- return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ if (includePatternInType) {
+ result.pattern = pattern;
+ }
+ return result;
}
// Return the type implied by an array binding pattern
- function getTypeFromArrayBindingPattern(pattern) {
- var hasSpreadElement = false;
- var elementTypes = [];
- ts.forEach(pattern.elements, function (e) {
- elementTypes.push(e.kind === 185 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e));
- if (e.dotDotDotToken) {
- hasSpreadElement = true;
- }
- });
- if (!elementTypes.length) {
+ function getTypeFromArrayBindingPattern(pattern, includePatternInType) {
+ var elements = pattern.elements;
+ if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) {
return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType;
}
- else if (hasSpreadElement) {
- var unionOfElements = getUnionType(elementTypes);
- return languageVersion >= 2 /* ES6 */ ? createIterableType(unionOfElements) : createArrayType(unionOfElements);
- }
// If the pattern has at least one element, and no rest element, then it should imply a tuple type.
+ var elementTypes = ts.map(elements, function (e) { return e.kind === 185 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); });
+ if (includePatternInType) {
+ var result = createNewTupleType(elementTypes);
+ result.pattern = pattern;
+ return result;
+ }
return createTupleType(elementTypes);
}
// Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself
@@ -15094,10 +15116,10 @@ var ts;
// used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring
// parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of
// the parameter.
- function getTypeFromBindingPattern(pattern) {
+ function getTypeFromBindingPattern(pattern, includePatternInType) {
return pattern.kind === 159 /* ObjectBindingPattern */
- ? getTypeFromObjectBindingPattern(pattern)
- : getTypeFromArrayBindingPattern(pattern);
+ ? getTypeFromObjectBindingPattern(pattern, includePatternInType)
+ : getTypeFromArrayBindingPattern(pattern, includePatternInType);
}
// Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type
// specified in a type annotation or inferred from an initializer. However, in the case of a destructuring declaration it
@@ -16565,11 +16587,11 @@ var ts;
}
function createTupleType(elementTypes) {
var id = getTypeListId(elementTypes);
- var type = tupleTypes[id];
- if (!type) {
- type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes));
- type.elementTypes = elementTypes;
- }
+ return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes));
+ }
+ function createNewTupleType(elementTypes) {
+ var type = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes));
+ type.elementTypes = elementTypes;
return type;
}
function getTypeFromTupleTypeNode(node) {
@@ -17021,7 +17043,7 @@ var ts;
* @param target The right-hand-side of the relation.
* @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'.
* Used as both to determine which checks are performed and as a cache of previously computed results.
- * @param errorNode The node upon which all errors will be reported, if defined.
+ * @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used.
* @param headMessage If the error chain should be prepended by a head message, then headMessage will be used.
* @param containingMessageChain A chain of errors to prepend any new errors found.
*/
@@ -17106,7 +17128,9 @@ var ts;
// and intersection types are further deconstructed on the target side, we don't want to
// make the check again (as it might fail for a partial target type). Therefore we obtain
// the regular source type and proceed with that.
- source = getRegularTypeOfObjectLiteral(source);
+ if (target.flags & 49152 /* UnionOrIntersection */) {
+ source = getRegularTypeOfObjectLiteral(source);
+ }
}
var saveErrorInfo = errorInfo;
// Note that the "each" checks must precede the "some" checks to produce the correct results
@@ -17228,6 +17252,10 @@ var ts;
var prop = _a[_i];
if (!isKnownProperty(target, prop.name)) {
if (reportErrors) {
+ // We know *exactly* where things went wrong when comparing the types.
+ // Use this property as the error node as this will be more helpful in
+ // reasoning about what went wrong.
+ errorNode = prop.valueDeclaration;
reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target));
}
return true;
@@ -17550,8 +17578,8 @@ var ts;
return result;
function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) {
if (sourceSig && targetSig) {
- var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212 /* ClassDeclaration */);
- var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212 /* ClassDeclaration */);
+ var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol);
+ var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol);
if (!sourceDecl) {
// If the source object isn't itself a class declaration, it can be freely assigned, regardless
// of whether the constructed object is abstract or not.
@@ -17561,8 +17589,8 @@ var ts;
var targetErasedSignature = getErasedSignature(targetSig);
var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
- var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212 /* ClassDeclaration */);
- var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212 /* ClassDeclaration */);
+ var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol);
+ var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol);
var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */;
var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */;
if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) {
@@ -17911,6 +17939,7 @@ var ts;
regularType.constructSignatures = type.constructSignatures;
regularType.stringIndexType = type.stringIndexType;
regularType.numberIndexType = type.numberIndexType;
+ type.regularType = regularType;
}
return regularType;
}
@@ -18932,7 +18961,7 @@ var ts;
}
}
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true);
}
}
return undefined;
@@ -19290,11 +19319,12 @@ var ts;
var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false);
}
+ function hasDefaultValue(node) {
+ return (node.kind === 161 /* BindingElement */ && !!node.initializer) ||
+ (node.kind === 179 /* BinaryExpression */ && node.operatorToken.kind === 55 /* EqualsToken */);
+ }
function checkArrayLiteral(node, contextualMapper) {
var elements = node.elements;
- if (!elements.length) {
- return createArrayType(undefinedType);
- }
var hasSpreadElement = false;
var elementTypes = [];
var inDestructuringPattern = isAssignmentTarget(node);
@@ -19327,12 +19357,39 @@ var ts;
hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */;
}
if (!hasSpreadElement) {
+ // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such
+ // that we get the same behavior for "var [x, y] = []" and "[x, y] = []".
+ if (inDestructuringPattern && elementTypes.length) {
+ var type = createNewTupleType(elementTypes);
+ type.pattern = node;
+ return type;
+ }
var contextualType = getContextualType(node);
- if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) {
- return createTupleType(elementTypes);
+ if (contextualType && contextualTypeIsTupleLikeType(contextualType)) {
+ var pattern = contextualType.pattern;
+ // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting
+ // tuple type with the corresponding binding or assignment element types to make the lengths equal.
+ if (pattern && (pattern.kind === 160 /* ArrayBindingPattern */ || pattern.kind === 162 /* ArrayLiteralExpression */)) {
+ var patternElements = pattern.elements;
+ for (var i = elementTypes.length; i < patternElements.length; i++) {
+ var patternElement = patternElements[i];
+ if (hasDefaultValue(patternElement)) {
+ elementTypes.push(contextualType.elementTypes[i]);
+ }
+ else {
+ if (patternElement.kind !== 185 /* OmittedExpression */) {
+ error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ elementTypes.push(unknownType);
+ }
+ }
+ }
+ if (elementTypes.length) {
+ return createTupleType(elementTypes);
+ }
}
}
- return createArrayType(getUnionType(elementTypes));
+ return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType);
}
function isNumericName(name) {
return name.kind === 134 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text);
@@ -19390,6 +19447,9 @@ var ts;
var propertiesTable = {};
var propertiesArray = [];
var contextualType = getContextualType(node);
+ var contextualTypeHasPattern = contextualType && contextualType.pattern &&
+ (contextualType.pattern.kind === 159 /* ObjectBindingPattern */ || contextualType.pattern.kind === 163 /* ObjectLiteralExpression */);
+ var inDestructuringPattern = isAssignmentTarget(node);
var typeFlags = 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var memberDecl = _a[_i];
@@ -19410,6 +19470,24 @@ var ts;
}
typeFlags |= type.flags;
var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name);
+ if (inDestructuringPattern) {
+ // If object literal is an assignment pattern and if the assignment pattern specifies a default value
+ // for the property, make the property optional.
+ if (memberDecl.kind === 243 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) {
+ prop.flags |= 536870912 /* Optional */;
+ }
+ }
+ else if (contextualTypeHasPattern) {
+ // If object literal is contextually typed by the implied type of a binding pattern, and if the
+ // binding pattern specifies a default value for the property, make the property optional.
+ var impliedProp = getPropertyOfType(contextualType, member.name);
+ if (impliedProp) {
+ prop.flags |= impliedProp.flags & 536870912 /* Optional */;
+ }
+ else if (!compilerOptions.suppressExcessPropertyErrors) {
+ error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
+ }
+ }
prop.declarations = member.declarations;
prop.parent = member.parent;
if (member.valueDeclaration) {
@@ -19433,11 +19511,28 @@ var ts;
}
propertiesArray.push(member);
}
+ // If object literal is contextually typed by the implied type of a binding pattern, augment the result
+ // type with those properties for which the binding pattern specifies a default value.
+ if (contextualTypeHasPattern) {
+ for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) {
+ var prop = _c[_b];
+ if (!ts.hasProperty(propertiesTable, prop.name)) {
+ if (!(prop.flags & 536870912 /* Optional */)) {
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ propertiesTable[prop.name] = prop;
+ propertiesArray.push(prop);
+ }
+ }
+ }
var stringIndexType = getIndexType(0 /* String */);
var numberIndexType = getIndexType(1 /* Number */);
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */;
result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */);
+ if (inDestructuringPattern) {
+ result.pattern = node;
+ }
return result;
function getIndexType(kind) {
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
@@ -20946,7 +21041,7 @@ var ts;
// Note, only class declarations can be declared abstract.
// In the case of a merged class-module or class-interface declaration,
// only the class declaration node will have the Abstract flag set.
- var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212 /* ClassDeclaration */);
+ var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol);
if (valueDecl && valueDecl.flags & 256 /* Abstract */) {
error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name));
return resolveErrorCall(node);
@@ -24257,6 +24352,9 @@ var ts;
// so we'll need to get back original 'target' symbol to work with correct set of flags
return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s;
}
+ function getClassLikeDeclarationOfSymbol(symbol) {
+ return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; });
+ }
function checkKindsOfPropertyMemberOverrides(type, baseType) {
// TypeScript 1.0 spec (April 2014): 8.2.3
// A derived class inherits all members from its base class it doesn't override.
@@ -24288,12 +24386,17 @@ var ts;
// type declaration, derived and base resolve to the same symbol even in the case of generic classes.
if (derived === base) {
// derived class inherits base without override/redeclaration
- var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212 /* ClassDeclaration */);
+ var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol);
// It is an error to inherit an abstract member without implementing it or being declared abstract.
// If there is no declaration for the derived class (as in the case of class expressions),
// then the class cannot be declared abstract.
if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) {
- error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ if (derivedClassDecl.kind === 184 /* ClassExpression */) {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
+ }
+ else {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ }
}
}
else {
@@ -25637,7 +25740,10 @@ var ts;
var symbols = [];
var name_15 = symbol.name;
ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) {
- symbols.push(getPropertyOfType(t, name_15));
+ var symbol = getPropertyOfType(t, name_15);
+ if (symbol) {
+ symbols.push(symbol);
+ }
});
return symbols;
}
@@ -28602,6 +28708,8 @@ var ts;
var scopeEmitEnd = function () { };
/** Sourcemap data that will get encoded */
var sourceMapData;
+ /** If removeComments is true, no leading-comments needed to be emitted **/
+ var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker;
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
initializeEmitterWithSourceMaps();
}
@@ -29561,8 +29669,10 @@ var ts;
function jsxEmitPreserve(node) {
function emitJsxAttribute(node) {
emit(node.name);
- write("=");
- emit(node.initializer);
+ if (node.initializer) {
+ write("=");
+ emit(node.initializer);
+ }
}
function emitJsxSpreadAttribute(node) {
write("{...");
@@ -30510,7 +30620,8 @@ var ts;
operand.kind !== 178 /* PostfixUnaryExpression */ &&
operand.kind !== 167 /* NewExpression */ &&
!(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) &&
- !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */)) {
+ !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */) &&
+ !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 164 /* PropertyAccessExpression */)) {
emit(operand);
return;
}
@@ -31215,6 +31326,9 @@ var ts;
}
function emitExportSpecifierInSystemModule(specifier) {
ts.Debug.assert(compilerOptions.module === 4 /* System */);
+ if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) {
+ return;
+ }
writeLine();
emitStart(specifier.name);
write(exportFunctionForFile + "(\"");
@@ -31270,21 +31384,30 @@ var ts;
write(")");
}
}
- function ensureIdentifier(expr) {
- if (expr.kind !== 67 /* Identifier */) {
- var identifier = createTempVariable(0 /* Auto */);
- if (!canDefineTempVariablesInPlace) {
- recordTempDeclaration(identifier);
- }
- emitAssignment(identifier, expr);
- expr = identifier;
+ /**
+ * Ensures that there exists a declared identifier whose value holds the given expression.
+ * This function is useful to ensure that the expression's value can be read from in subsequent expressions.
+ * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier.
+ *
+ * @param expr the expression whose value needs to be bound.
+ * @param reuseIdentifierExpressions true if identifier expressions can simply be returned;
+ * false if it is necessary to always emit an identifier.
+ */
+ function ensureIdentifier(expr, reuseIdentifierExpressions) {
+ if (expr.kind === 67 /* Identifier */ && reuseIdentifierExpressions) {
+ return expr;
}
- return expr;
+ var identifier = createTempVariable(0 /* Auto */);
+ if (!canDefineTempVariablesInPlace) {
+ recordTempDeclaration(identifier);
+ }
+ emitAssignment(identifier, expr);
+ return identifier;
}
function createDefaultValueCheck(value, defaultValue) {
// The value expression will be evaluated twice, so for anything but a simple identifier
// we need to generate a temporary variable
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
// Return the expression 'value === void 0 ? defaultValue : value'
var equals = ts.createSynthesizedNode(179 /* BinaryExpression */);
equals.left = value;
@@ -31330,7 +31453,7 @@ var ts;
if (properties.length !== 1) {
// For anything but a single element destructuring we need to generate a temporary
// to ensure value is evaluated exactly once.
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
}
for (var _a = 0; _a < properties.length; _a++) {
var p = properties[_a];
@@ -31345,7 +31468,7 @@ var ts;
if (elements.length !== 1) {
// For anything but a single element destructuring we need to generate a temporary
// to ensure value is evaluated exactly once.
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
}
for (var i = 0; i < elements.length; i++) {
var e = elements[i];
@@ -31387,7 +31510,7 @@ var ts;
if (root.parent.kind !== 170 /* ParenthesizedExpression */) {
write("(");
}
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
emitDestructuringAssignment(target, value);
write(", ");
emit(value);
@@ -31408,12 +31531,15 @@ var ts;
if (ts.isBindingPattern(target.name)) {
var pattern = target.name;
var elements = pattern.elements;
- if (elements.length !== 1) {
- // For anything but a single element destructuring we need to generate a temporary
- // to ensure value is evaluated exactly once.
- value = ensureIdentifier(value);
+ var numElements = elements.length;
+ if (numElements !== 1) {
+ // For anything other than a single-element destructuring we need to generate a temporary
+ // to ensure value is evaluated exactly once. Additionally, if we have zero elements
+ // we need to emit *something* to ensure that in case a 'var' keyword was already emitted,
+ // so in that case, we'll intentionally create that temporary.
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0);
}
- for (var i = 0; i < elements.length; i++) {
+ for (var i = 0; i < numElements; i++) {
var element = elements[i];
if (pattern.kind === 159 /* ObjectBindingPattern */) {
// Rewrite element to a declaration with an initializer that fetches property
@@ -31425,7 +31551,7 @@ var ts;
// Rewrite element to a declaration that accesses array element at index i
emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i)));
}
- else if (i === elements.length - 1) {
+ else if (i === numElements - 1) {
emitBindingElement(element, createSliceCall(value, i));
}
}
@@ -31686,7 +31812,7 @@ var ts;
}
function emitFunctionDeclaration(node) {
if (ts.nodeIsMissing(node.body)) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
// TODO (yuisu) : we should not have special cases to condition emitting comments
// but have one place to fix check for these conditions.
@@ -32112,7 +32238,7 @@ var ts;
}
else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) {
if (!member.body) {
- return emitOnlyPinnedOrTripleSlashComments(member);
+ return emitCommentsOnNotEmittedNode(member);
}
writeLine();
emitLeadingComments(member);
@@ -32178,7 +32304,7 @@ var ts;
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
else if (member.kind === 141 /* MethodDeclaration */ ||
member.kind === 143 /* GetAccessor */ ||
@@ -32229,7 +32355,7 @@ var ts;
// Emit the constructor overload pinned comments
ts.forEach(node.members, function (member) {
if (member.kind === 142 /* Constructor */ && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
// Check if there is any non-static property assignment
if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) {
@@ -32840,50 +32966,49 @@ var ts;
write("void 0");
}
function emitSerializedTypeNode(node) {
- if (!node) {
- return;
- }
- switch (node.kind) {
- case 101 /* VoidKeyword */:
- write("void 0");
- return;
- case 158 /* ParenthesizedType */:
- emitSerializedTypeNode(node.type);
- return;
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
- write("Function");
- return;
- case 154 /* ArrayType */:
- case 155 /* TupleType */:
- write("Array");
- return;
- case 148 /* TypePredicate */:
- case 118 /* BooleanKeyword */:
- write("Boolean");
- return;
- case 128 /* StringKeyword */:
- case 9 /* StringLiteral */:
- write("String");
- return;
- case 126 /* NumberKeyword */:
- write("Number");
- return;
- case 129 /* SymbolKeyword */:
- write("Symbol");
- return;
- case 149 /* TypeReference */:
- emitSerializedTypeReferenceNode(node);
- return;
- case 152 /* TypeQuery */:
- case 153 /* TypeLiteral */:
- case 156 /* UnionType */:
- case 157 /* IntersectionType */:
- case 115 /* AnyKeyword */:
- break;
- default:
- ts.Debug.fail("Cannot serialize unexpected type node.");
- break;
+ if (node) {
+ switch (node.kind) {
+ case 101 /* VoidKeyword */:
+ write("void 0");
+ return;
+ case 158 /* ParenthesizedType */:
+ emitSerializedTypeNode(node.type);
+ return;
+ case 150 /* FunctionType */:
+ case 151 /* ConstructorType */:
+ write("Function");
+ return;
+ case 154 /* ArrayType */:
+ case 155 /* TupleType */:
+ write("Array");
+ return;
+ case 148 /* TypePredicate */:
+ case 118 /* BooleanKeyword */:
+ write("Boolean");
+ return;
+ case 128 /* StringKeyword */:
+ case 9 /* StringLiteral */:
+ write("String");
+ return;
+ case 126 /* NumberKeyword */:
+ write("Number");
+ return;
+ case 129 /* SymbolKeyword */:
+ write("Symbol");
+ return;
+ case 149 /* TypeReference */:
+ emitSerializedTypeReferenceNode(node);
+ return;
+ case 152 /* TypeQuery */:
+ case 153 /* TypeLiteral */:
+ case 156 /* UnionType */:
+ case 157 /* IntersectionType */:
+ case 115 /* AnyKeyword */:
+ break;
+ default:
+ ts.Debug.fail("Cannot serialize unexpected type node.");
+ break;
+ }
}
write("Object");
}
@@ -33034,7 +33159,7 @@ var ts;
return argumentsWritten;
}
function emitInterfaceDeclaration(node) {
- emitOnlyPinnedOrTripleSlashComments(node);
+ emitCommentsOnNotEmittedNode(node);
}
function shouldEmitEnumDeclaration(node) {
var isConstEnum = ts.isConst(node);
@@ -33146,7 +33271,7 @@ var ts;
// Emit only if this module is non-ambient.
var shouldEmit = shouldEmitModuleDeclaration(node);
if (!shouldEmit) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node);
var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node);
@@ -33875,7 +34000,7 @@ var ts;
}
return;
}
- if (ts.isInternalModuleImportEqualsDeclaration(node)) {
+ if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) {
if (!hoistedVars) {
hoistedVars = [];
}
@@ -34438,7 +34563,7 @@ var ts;
function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) {
if (node) {
if (node.flags & 2 /* Ambient */) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
if (isSpecializedCommentHandling(node)) {
// This is the node that will handle its own comments and sourcemap
@@ -34686,21 +34811,27 @@ var ts;
}
return leadingComments;
}
+ function isPinnedComments(comment) {
+ return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
+ }
/**
- * Removes all but the pinned or triple slash comments.
- * @param ranges The array to be filtered
- * @param onlyPinnedOrTripleSlashComments whether the filtering should be performed.
- */
- function filterComments(ranges, onlyPinnedOrTripleSlashComments) {
- // If we're removing comments, then we want to strip out all but the pinned or
- // triple slash comments.
- if (ranges && onlyPinnedOrTripleSlashComments) {
- ranges = ts.filter(ranges, isPinnedOrTripleSlashComment);
- if (ranges.length === 0) {
- return undefined;
- }
+ * Determine if the given comment is a triple-slash
+ *
+ * @return true if the comment is a triple-slash comment else false
+ **/
+ function isTripleSlashComment(comment) {
+ // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
+ // so that we don't end up computing comment string and doing match for all // comments
+ if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ &&
+ comment.pos + 2 < comment.end &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) {
+ var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end);
+ return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
+ textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ?
+ true : false;
}
- return ranges;
+ return false;
}
function getLeadingCommentsToEmit(node) {
// Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments
@@ -34725,23 +34856,46 @@ var ts;
}
}
}
- function emitOnlyPinnedOrTripleSlashComments(node) {
- emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true);
+ /**
+ * Emit comments associated with node that will not be emitted into JS file
+ */
+ function emitCommentsOnNotEmittedNode(node) {
+ emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false);
}
function emitLeadingComments(node) {
- return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true);
}
- function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) {
- // If the caller only wants pinned or triple slash comments, then always filter
- // down to that set. Otherwise, filter based on the current compiler options.
- var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments);
+ function emitLeadingCommentsWorker(node, isEmittedNode) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var leadingComments;
+ if (isEmittedNode) {
+ leadingComments = getLeadingCommentsToEmit(node);
+ }
+ else {
+ // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node,
+ // unless it is a triple slash comment at the top of the file.
+ // For Example:
+ // ///
+ // declare var x;
+ // ///
+ // interface F {}
+ // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted
+ if (node.pos === 0) {
+ leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment);
+ }
+ }
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
- ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
+ ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment);
}
function emitTrailingComments(node) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
// Emit the trailing comments only if the parent's end doesn't match
- var trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ var trailingComments = getTrailingCommentsToEmit(node);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment);
}
@@ -34751,11 +34905,17 @@ var ts;
* ^ => pos; the function will emit "comment1" in the emitJS
*/
function emitTrailingCommentsOfPosition(pos) {
- var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment);
}
- function emitLeadingCommentsOfPosition(pos) {
+ function emitLeadingCommentsOfPositionWorker(pos) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
var leadingComments;
if (hasDetachedComments(pos)) {
// get comments without detached comments
@@ -34765,13 +34925,26 @@ var ts;
// get the leading comments from the node
leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos);
}
- leadingComments = filterComments(leadingComments, compilerOptions.removeComments);
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
}
function emitDetachedComments(node) {
- var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ var leadingComments;
+ if (compilerOptions.removeComments) {
+ // removeComments is true, only reserve pinned comment at the top of file
+ // For example:
+ // /*! Pinned Comment */
+ //
+ // var x = 10;
+ if (node.pos === 0) {
+ leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments);
+ }
+ }
+ else {
+ // removeComments is false, just get detached as normal and bypass the process to filter comment
+ leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ }
if (leadingComments) {
var detachedComments = [];
var lastComment;
@@ -34816,17 +34989,6 @@ var ts;
write(shebang);
}
}
- function isPinnedOrTripleSlashComment(comment) {
- if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) {
- return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
- }
- else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ &&
- comment.pos + 2 < comment.end &&
- currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */ &&
- currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) {
- return true;
- }
- }
}
function emitFile(jsFilePath, sourceFile) {
emitJavaScript(jsFilePath, sourceFile);
@@ -35103,7 +35265,7 @@ var ts;
/* @internal */ ts.ioWriteTime = 0;
/** The version of the TypeScript compiler release */
var emptyArray = [];
- ts.version = "1.6.0";
+ ts.version = "1.7.0";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@@ -35143,10 +35305,12 @@ var ts;
var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
if (resolvedFileName) {
- return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations };
}
resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
- return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
+ return resolvedFileName
+ ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }
+ : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
}
else {
return loadModuleFromNodeModules(moduleName, containingDirectory, host);
@@ -35206,11 +35370,11 @@ var ts;
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName));
var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
if (result) {
- return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations };
}
result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
if (result) {
- return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations };
}
}
var parentPath = ts.getDirectoryPath(directory);
@@ -35219,39 +35383,16 @@ var ts;
}
directory = parentPath;
}
- return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
+ return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
}
- function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) {
- ts.Debug.assert(baseUrl !== undefined);
- var normalizedModuleName = ts.normalizeSlashes(moduleName);
- var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile);
- var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName));
- var failedLookupLocations = [];
- return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
- function tryLoadFile(location) {
- if (host.fileExists(location)) {
- return { resolvedFileName: location, failedLookupLocations: failedLookupLocations };
- }
- else {
- failedLookupLocations.push(location);
- return undefined;
- }
- }
- }
- ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver;
function nameStartsWithDotSlashOrDotDotSlash(name) {
var i = name.lastIndexOf("./", 1);
return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */);
}
- function useBaseUrl(moduleName) {
- // path is not rooted
- // module name does not start with './' or '../'
- return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName);
- }
function classicNameResolver(moduleName, containingFile, compilerOptions, host) {
// module names that contain '!' are used to reference resources and are not resolved to actual files on disk
if (moduleName.indexOf('!') != -1) {
- return { resolvedFileName: undefined, failedLookupLocations: [] };
+ return { resolvedModule: undefined, failedLookupLocations: [] };
}
var searchPath = ts.getDirectoryPath(containingFile);
var searchName;
@@ -35282,7 +35423,9 @@ var ts;
}
searchPath = parentPath;
}
- return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations };
+ return referencedSourceFile
+ ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations }
+ : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
}
ts.classicNameResolver = classicNameResolver;
/* @internal */
@@ -35399,7 +35542,8 @@ var ts;
function createProgram(rootNames, options, host, oldProgram) {
var program;
var files = [];
- var diagnostics = ts.createDiagnosticCollection();
+ var fileProcessingDiagnostics = ts.createDiagnosticCollection();
+ var programDiagnostics = ts.createDiagnosticCollection();
var commonSourceDirectory;
var diagnosticsProducingTypeChecker;
var noDiagnosticsTypeChecker;
@@ -35407,8 +35551,9 @@ var ts;
var skipDefaultLib = options.noLib;
var start = new Date().getTime();
host = host || createCompilerHost(options);
- var resolveModuleNamesWorker = host.resolveModuleNames ||
- (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedFileName; }); });
+ var resolveModuleNamesWorker = host.resolveModuleNames
+ ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); })
+ : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); });
var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); });
if (oldProgram) {
// check properties that can affect structure of the program or module resolution strategy
@@ -35455,7 +35600,8 @@ var ts;
getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
- getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }
+ getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
+ getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }
};
return program;
function getClassifiableNames() {
@@ -35482,6 +35628,7 @@ var ts;
}
// check if program source files has changed in the way that can affect structure of the program
var newSourceFiles = [];
+ var modifiedSourceFiles = [];
for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) {
var oldSourceFile = _a[_i];
var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target);
@@ -35510,14 +35657,21 @@ var ts;
var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName);
// ensure that module resolution results are still correct
for (var i = 0; i < moduleNames.length; ++i) {
- var oldResolution = ts.getResolvedModuleFileName(oldSourceFile, moduleNames[i]);
- if (oldResolution !== resolutions[i]) {
+ var newResolution = resolutions[i];
+ var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]);
+ var resolutionChanged = oldResolution
+ ? !newResolution ||
+ oldResolution.resolvedFileName !== newResolution.resolvedFileName ||
+ !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport
+ : newResolution;
+ if (resolutionChanged) {
return false;
}
}
}
// pass the cache of module resolutions from the old source file
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
+ modifiedSourceFiles.push(newSourceFile);
}
else {
// file has no changes - use it as is
@@ -35532,6 +35686,11 @@ var ts;
filesByName.set(file.fileName, file);
}
files = newSourceFiles;
+ fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
+ for (var _c = 0; _c < modifiedSourceFiles.length; _c++) {
+ var modifiedFile = modifiedSourceFiles[_c];
+ fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile);
+ }
oldProgram.structureIsReused = true;
return true;
}
@@ -35633,8 +35792,9 @@ var ts;
ts.Debug.assert(!!sourceFile.bindDiagnostics);
var bindDiagnostics = sourceFile.bindDiagnostics;
var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken);
- var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
- return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics);
+ var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
+ var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
+ return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile);
});
}
function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) {
@@ -35649,7 +35809,8 @@ var ts;
}
function getOptionsDiagnostics() {
var allDiagnostics = [];
- ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
+ ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics());
+ ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics());
return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
}
function getGlobalDiagnostics() {
@@ -35747,10 +35908,10 @@ var ts;
}
if (diagnostic) {
if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) {
- diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument)));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument)));
}
else {
- diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument)));
+ fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument)));
}
}
}
@@ -35770,10 +35931,10 @@ var ts;
// We haven't looked for this file, do so now and cache result
var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) {
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
- diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
}
else {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
+ fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
}
});
filesByName.set(canonicalName, file);
@@ -35803,10 +35964,10 @@ var ts;
var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName;
if (canonicalName !== sourceFileName) {
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
- diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
}
else {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
+ fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
}
}
}
@@ -35827,9 +35988,23 @@ var ts;
var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName);
for (var i = 0; i < file.imports.length; ++i) {
var resolution = resolutions[i];
- ts.setResolvedModuleName(file, moduleNames[i], resolution);
+ ts.setResolvedModule(file, moduleNames[i], resolution);
if (resolution && !options.noResolve) {
- findModuleSourceFile(resolution, file.imports[i]);
+ var importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]);
+ if (importedFile && resolution.isExternalLibraryImport) {
+ if (!ts.isExternalModule(importedFile)) {
+ var start_2 = ts.getTokenPosOfNode(file.imports[i], file);
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
+ }
+ else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) {
+ var start_3 = ts.getTokenPosOfNode(file.imports[i], file);
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_3, file.imports[i].end - start_3, ts.Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition));
+ }
+ else if (importedFile.referencedFiles.length) {
+ var firstRef = importedFile.referencedFiles[0];
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition));
+ }
+ }
}
}
}
@@ -35839,7 +36014,7 @@ var ts;
}
return;
function findModuleSourceFile(fileName, nameLiteral) {
- return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end);
+ return findSourceFile(fileName, /* isDefaultLib */ false, file, ts.skipTrivia(file.text, nameLiteral.pos), nameLiteral.end);
}
}
function computeCommonSourceDirectory(sourceFiles) {
@@ -35860,7 +36035,7 @@ var ts;
for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) {
if (commonPathComponents[i] !== sourcePathComponents[i]) {
if (i === 0) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
return;
}
// New common path found that is 0 -> i-1
@@ -35885,7 +36060,7 @@ var ts;
if (!ts.isDeclarationFile(sourceFile)) {
var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
allFilesBelongToPath = false;
}
}
@@ -35896,44 +36071,44 @@ var ts;
function verifyCompilerOptions() {
if (options.isolatedModules) {
if (options.declaration) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules"));
}
if (options.noEmitOnError) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules"));
}
if (options.out) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"));
}
if (options.outFile) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules"));
}
}
if (options.inlineSourceMap) {
if (options.sourceMap) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap"));
}
if (options.mapRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
}
if (options.sourceRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
}
}
if (options.inlineSources) {
if (!options.sourceMap && !options.inlineSourceMap) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
}
}
if (options.out && options.outFile) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
}
if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) {
// Error to specify --mapRoot or --sourceRoot without mapSourceFiles
if (options.mapRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
}
if (options.sourceRoot) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
}
return;
}
@@ -35942,22 +36117,22 @@ var ts;
var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; });
if (options.isolatedModules) {
if (!options.module && languageVersion < 2 /* ES6 */) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
}
var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; });
if (firstNonExternalModuleSourceFile) {
var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
- diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) {
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
- diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
}
// Cannot specify module gen target when in es6 or above
if (options.module && languageVersion >= 2 /* ES6 */) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
}
// there has to be common source directory if user specified --outdir || --sourceRoot
// if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted
@@ -35982,25 +36157,25 @@ var ts;
}
if (options.noEmit) {
if (options.out) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));
}
if (options.outFile) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile"));
}
if (options.outDir) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir"));
}
if (options.declaration) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
}
}
if (options.emitDecoratorMetadata &&
!options.experimentalDecorators) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
}
if (options.experimentalAsyncFunctions &&
options.target !== 2 /* ES6 */) {
- diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
}
}
}
@@ -36251,8 +36426,8 @@ var ts;
"node": 2 /* NodeJs */,
"classic": 1 /* Classic */
},
- experimental: true,
- description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
+ description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
+ error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic
}
];
var optionNameMapCache;
@@ -36374,10 +36549,10 @@ var ts;
* Read tsconfig.json file
* @param fileName The path to the config file
*/
- function readConfigFile(fileName) {
+ function readConfigFile(fileName, readFile) {
var text = "";
try {
- text = ts.sys.readFile(fileName);
+ text = readFile(fileName);
}
catch (e) {
return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
@@ -38721,7 +38896,7 @@ var ts;
function findPrecedingToken(position, sourceFile, startNode) {
return find(startNode || sourceFile);
function findRightmostToken(n) {
- if (isToken(n)) {
+ if (isToken(n) || n.kind === 234 /* JsxText */) {
return n;
}
var children = n.getChildren();
@@ -38729,23 +38904,32 @@ var ts;
return candidate && findRightmostToken(candidate);
}
function find(n) {
- if (isToken(n)) {
+ if (isToken(n) || n.kind === 234 /* JsxText */) {
return n;
}
var children = n.getChildren();
for (var i = 0, len = children.length; i < len; i++) {
var child = children[i];
- if (nodeHasTokens(child)) {
- if (position <= child.end) {
- if (child.getStart(sourceFile) >= position) {
- // actual start of the node is past the position - previous token should be at the end of previous child
- var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i);
- return candidate && findRightmostToken(candidate);
- }
- else {
- // candidate should be in this node
- return find(child);
- }
+ // condition 'position < child.end' checks if child node end after the position
+ // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc'
+ // aaaa___bbbb___$__ccc
+ // after we found child node with end after the position we check if start of the node is after the position.
+ // if yes - then position is in the trivia and we need to look into the previous child to find the token in question.
+ // if no - position is in the node itself so we should recurse in it.
+ // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia).
+ // if this is the case - then we should assume that token in question is located in previous child.
+ if (position < child.end && (nodeHasTokens(child) || child.kind === 234 /* JsxText */)) {
+ var start = child.getStart(sourceFile);
+ var lookInPreviousChild = (start >= position) ||
+ (child.kind === 234 /* JsxText */ && start === child.end); // whitespace only JsxText
+ if (lookInPreviousChild) {
+ // actual start of the node is past the position - previous token should be at the end of previous child
+ var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i);
+ return candidate && findRightmostToken(candidate);
+ }
+ else {
+ // candidate should be in this node
+ return find(child);
}
}
}
@@ -39162,6 +39346,7 @@ var ts;
ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken";
ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken";
ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken";
+ ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier";
})(ScanAction || (ScanAction = {}));
function getFormattingScanner(sourceFile, startPos, endPos) {
scanner.setText(sourceFile.text);
@@ -39235,6 +39420,18 @@ var ts;
}
return false;
}
+ function shouldRescanJsxIdentifier(node) {
+ if (node.parent) {
+ switch (node.parent.kind) {
+ case 236 /* JsxAttribute */:
+ case 233 /* JsxOpeningElement */:
+ case 235 /* JsxClosingElement */:
+ case 232 /* JsxSelfClosingElement */:
+ return node.kind === 67 /* Identifier */;
+ }
+ }
+ return false;
+ }
function shouldRescanSlashToken(container) {
return container.kind === 10 /* RegularExpressionLiteral */;
}
@@ -39262,7 +39459,9 @@ var ts;
? 2 /* RescanSlashToken */
: shouldRescanTemplateToken(n)
? 3 /* RescanTemplateToken */
- : 0 /* Scan */;
+ : shouldRescanJsxIdentifier(n)
+ ? 4 /* RescanJsxIdentifier */
+ : 0 /* Scan */;
if (lastTokenInfo && expectedScanAction === lastScanAction) {
// readTokenInfo was called before with the same expected scan action.
// No need to re-scan text, return existing 'lastTokenInfo'
@@ -39293,6 +39492,10 @@ var ts;
currentToken = scanner.reScanTemplateToken();
lastScanAction = 3 /* RescanTemplateToken */;
}
+ else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 67 /* Identifier */) {
+ currentToken = scanner.scanJsxIdentifier();
+ lastScanAction = 4 /* RescanJsxIdentifier */;
+ }
else {
lastScanAction = 0 /* Scan */;
}
@@ -39633,7 +39836,7 @@ var ts;
this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments;
this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */);
// Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc)
- this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */]);
+ this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */, 71 /* ClassKeyword */]);
this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */);
// Place a space before open brace in a control flow construct
this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 77 /* DoKeyword */, 98 /* TryKeyword */, 83 /* FinallyKeyword */, 78 /* ElseKeyword */]);
@@ -39666,7 +39869,7 @@ var ts;
this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */, 117 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */));
this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */));
this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */));
@@ -39690,7 +39893,7 @@ var ts;
// Use of module as a function call. e.g.: import m2 = module("m2");
this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Add a space around certain TypeScript keywords
- this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */, 130 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81 /* ExtendsKeyword */, 104 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */));
@@ -39718,20 +39921,8 @@ var ts;
this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */));
// Async-await
this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- // Type alias declaration
- this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// template string
this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- // union type
- this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -39758,11 +39949,8 @@ var ts;
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
- this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
- this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
- this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
- this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
- this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
+ this.SpaceBetweenAsyncAndFunctionKeyword,
+ this.SpaceBetweenTagAndTemplateString,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
@@ -39857,6 +40045,8 @@ var ts;
case 180 /* ConditionalExpression */:
case 187 /* AsExpression */:
case 148 /* TypePredicate */:
+ case 156 /* UnionType */:
+ case 157 /* IntersectionType */:
return true;
// equals in binding elements: function foo([[x, y] = [1, 2]])
case 161 /* BindingElement */:
@@ -39967,6 +40157,7 @@ var ts;
Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) {
switch (node.kind) {
case 212 /* ClassDeclaration */:
+ case 184 /* ClassExpression */:
case 213 /* InterfaceDeclaration */:
case 215 /* EnumDeclaration */:
case 153 /* TypeLiteral */:
@@ -40813,7 +41004,7 @@ var ts;
}
function getDynamicIndentation(node, nodeStartLine, indentation, delta) {
return {
- getIndentationForComment: function (kind) {
+ getIndentationForComment: function (kind, tokenIndentation) {
switch (kind) {
// preceding comment to the token that closes the indentation scope inherits the indentation from the scope
// .. {
@@ -40821,9 +41012,10 @@ var ts;
// }
case 16 /* CloseBraceToken */:
case 20 /* CloseBracketToken */:
+ case 18 /* CloseParenToken */:
return indentation + delta;
}
- return indentation;
+ return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation;
},
getIndentationForToken: function (line, kind) {
if (nodeStartLine !== line && node.decorators) {
@@ -41025,8 +41217,12 @@ var ts;
processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation);
}
if (indentToken) {
- var indentNextTokenOrTrivia = true;
+ var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
+ dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) :
+ -1 /* Unknown */;
if (currentTokenInfo.leadingTrivia) {
+ var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation);
+ var indentNextTokenOrTrivia = true;
for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) {
var triviaItem = _a[_i];
if (!ts.rangeContainsRange(originalRange, triviaItem)) {
@@ -41034,14 +41230,12 @@ var ts;
}
switch (triviaItem.kind) {
case 3 /* MultiLineCommentTrivia */:
- var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia);
indentNextTokenOrTrivia = false;
break;
case 2 /* SingleLineCommentTrivia */:
if (indentNextTokenOrTrivia) {
- var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
- insertIndentation(triviaItem.pos, commentIndentation_1, /*lineAdded*/ false);
+ insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false);
indentNextTokenOrTrivia = false;
}
break;
@@ -41052,8 +41246,7 @@ var ts;
}
}
// indent token only if is it is in target range and does not overlap with any error ranges
- if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
- var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
+ if (tokenIndentation !== -1 /* Unknown */) {
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
lastIndentedLine = tokenStart.line;
indentationOnLastIndentedLine = tokenIndentation;
@@ -41704,6 +41897,7 @@ var ts;
function nodeContentIsAlwaysIndented(kind) {
switch (kind) {
case 212 /* ClassDeclaration */:
+ case 184 /* ClassExpression */:
case 213 /* InterfaceDeclaration */:
case 215 /* EnumDeclaration */:
case 214 /* TypeAliasDeclaration */:
@@ -41728,13 +41922,13 @@ var ts;
case 160 /* ArrayBindingPattern */:
case 159 /* ObjectBindingPattern */:
case 231 /* JsxElement */:
+ case 232 /* JsxSelfClosingElement */:
case 140 /* MethodSignature */:
case 145 /* CallSignature */:
case 146 /* ConstructSignature */:
case 136 /* Parameter */:
case 150 /* FunctionType */:
case 151 /* ConstructorType */:
- case 156 /* UnionType */:
case 158 /* ParenthesizedType */:
case 168 /* TaggedTemplateExpression */:
case 176 /* AwaitExpression */:
@@ -42858,7 +43052,7 @@ var ts;
var sourceMapText;
// Create a compilerHost object to allow the compiler to read and write files
var compilerHost = {
- getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; },
+ getSourceFile: function (fileName, target) { return fileName === ts.normalizeSlashes(inputFileName) ? sourceFile : undefined; },
writeFile: function (name, text, writeByteOrderMark) {
if (ts.fileExtensionIs(name, ".map")) {
ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'");
@@ -43106,6 +43300,7 @@ var ts;
//
// export * from "mod"
// export {a as b} from "mod"
+ // export import i = require("mod")
while (token !== 1 /* EndOfFileToken */) {
if (token === 120 /* DeclareKeyword */) {
// declare module "mod"
@@ -43226,6 +43421,25 @@ var ts;
}
}
}
+ else if (token === 87 /* ImportKeyword */) {
+ token = scanner.scan();
+ if (token === 67 /* Identifier */ || ts.isKeyword(token)) {
+ token = scanner.scan();
+ if (token === 55 /* EqualsToken */) {
+ token = scanner.scan();
+ if (token === 125 /* RequireKeyword */) {
+ token = scanner.scan();
+ if (token === 17 /* OpenParenToken */) {
+ token = scanner.scan();
+ if (token === 9 /* StringLiteral */) {
+ // export import i = require("mod");
+ recordModuleName();
+ }
+ }
+ }
+ }
+ }
+ }
}
token = scanner.scan();
}
@@ -43929,9 +44143,9 @@ var ts;
// Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS|
// Skip this partial identifier and adjust the contextToken to the token that precedes it.
if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) {
- var start_2 = new Date().getTime();
+ var start_4 = new Date().getTime();
contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile);
- log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_2));
+ log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_4));
}
// Find the node where completion is requested on.
// Also determine whether we are trying to complete with members of that node
@@ -44179,13 +44393,13 @@ var ts;
if (contextToken.kind === 9 /* StringLiteral */
|| contextToken.kind === 10 /* RegularExpressionLiteral */
|| ts.isTemplateLiteralKind(contextToken.kind)) {
- var start_3 = contextToken.getStart();
+ var start_5 = contextToken.getStart();
var end = contextToken.getEnd();
// To be "in" one of these literals, the position has to be:
// 1. entirely within the token text.
// 2. at the end position of an unterminated token.
// 3. at the end of a regular expression (due to trailing flags like '/foo/g').
- if (start_3 < position && position < end) {
+ if (start_5 < position && position < end) {
return true;
}
if (position === end) {
@@ -46349,6 +46563,7 @@ var ts;
result.push(getReferenceEntryFromNode(node));
}
break;
+ case 184 /* ClassExpression */:
case 212 /* ClassDeclaration */:
// Make sure the container belongs to the same class
// and has the appropriate static modifier from the original container.
@@ -48557,7 +48772,10 @@ var ts;
if ("getModuleResolutionsForFile" in this.shimHost) {
this.resolveModuleNames = function (moduleNames, containingFile) {
var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile));
- return ts.map(moduleNames, function (name) { return ts.lookUp(resolutionsInFile, name); });
+ return ts.map(moduleNames, function (name) {
+ var result = ts.lookUp(resolutionsInFile, name);
+ return result ? { resolvedFileName: result } : undefined;
+ });
};
}
}
@@ -49104,7 +49322,11 @@ var ts;
var _this = this;
return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () {
var compilerOptions = JSON.parse(compilerOptionsJson);
- return ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host);
+ var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host);
+ return {
+ resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined,
+ failedLookupLocations: result.failedLookupLocations
+ };
});
};
CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) {
diff --git a/package.json b/package.json
index abd81e12f47..b743b04838d 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "typescript",
"author": "Microsoft Corp.",
"homepage": "http://typescriptlang.org/",
- "version": "1.6.0",
+ "version": "1.7.0",
"license": "Apache-2.0",
"description": "TypeScript is a language for application scale JavaScript development",
"keywords": [
diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index c214239117e..013ecbe470c 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -14246,7 +14246,10 @@ namespace ts {
let symbols: Symbol[] = [];
let name = symbol.name;
forEach(getSymbolLinks(symbol).containingType.types, t => {
- symbols.push(getPropertyOfType(t, name));
+ let symbol = getPropertyOfType(t, name);
+ if (symbol) {
+ symbols.push(symbol);
+ }
});
return symbols;
}
diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts
index 7117aaea180..d2ec7bbe950 100644
--- a/src/compiler/commandLineParser.ts
+++ b/src/compiler/commandLineParser.ts
@@ -243,7 +243,8 @@ namespace ts {
"node": ModuleResolutionKind.NodeJs,
"classic": ModuleResolutionKind.Classic
},
- description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
+ description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
+ error: Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic,
},
{
name: "noUnusedLabels",
@@ -347,7 +348,7 @@ namespace ts {
options[opt.name] = map[key];
}
else {
- errors.push(createCompilerDiagnostic(opt.error));
+ errors.push(createCompilerDiagnostic((opt).error));
}
}
}
@@ -460,7 +461,7 @@ namespace ts {
value = optType[key];
}
else {
- errors.push(createCompilerDiagnostic(opt.error));
+ errors.push(createCompilerDiagnostic((opt).error));
value = 0;
}
}
diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts
index 0e26d748c2e..3816ee5673e 100644
--- a/src/compiler/diagnosticInformationMap.generated.ts
+++ b/src/compiler/diagnosticInformationMap.generated.ts
@@ -565,13 +565,14 @@ namespace ts {
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'." },
+ Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." },
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'." },
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." },
- Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
+ Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." },
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json
index 592b6e6dcb7..7930609290e 100644
--- a/src/compiler/diagnosticMessages.json
+++ b/src/compiler/diagnosticMessages.json
@@ -1700,11 +1700,11 @@
"Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.": {
"category": "Error",
"code": 2652
- },
+ },
"Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'.": {
"category": "Error",
"code": 2653
- },
+ },
"Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.": {
"category": "Error",
"code": 2654
@@ -1712,11 +1712,11 @@
"Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition.": {
"category": "Error",
"code": 2655
- },
+ },
"Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition.": {
"category": "Error",
"code": 2656
- },
+ },
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000
@@ -2250,6 +2250,11 @@
"category": "Error",
"code": 6062
},
+ "Argument for '--moduleResolution' option must be 'node' or 'classic'.": {
+ "category": "Error",
+ "code": 6063
+ },
+
"Specify JSX code generation: 'preserve' or 'react'": {
"category": "Message",
"code": 6080
@@ -2274,7 +2279,7 @@
"category": "Message",
"code": 6068
},
- "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) .": {
+ "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6).": {
"category": "Message",
"code": 6069
},
diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts
index 5410cd9c681..44e5a45b057 100644
--- a/src/compiler/emitter.ts
+++ b/src/compiler/emitter.ts
@@ -3220,22 +3220,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
- function ensureIdentifier(expr: Expression): Expression {
- if (expr.kind !== SyntaxKind.Identifier) {
- let identifier = createTempVariable(TempFlags.Auto);
- if (!canDefineTempVariablesInPlace) {
- recordTempDeclaration(identifier);
- }
- emitAssignment(identifier, expr);
- expr = identifier;
+ /**
+ * Ensures that there exists a declared identifier whose value holds the given expression.
+ * This function is useful to ensure that the expression's value can be read from in subsequent expressions.
+ * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier.
+ *
+ * @param expr the expression whose value needs to be bound.
+ * @param reuseIdentifierExpressions true if identifier expressions can simply be returned;
+ * false if it is necessary to always emit an identifier.
+ */
+ function ensureIdentifier(expr: Expression, reuseIdentifierExpressions: boolean): Expression {
+ if (expr.kind === SyntaxKind.Identifier && reuseIdentifierExpressions) {
+ return expr;
}
- return expr;
+
+ let identifier = createTempVariable(TempFlags.Auto);
+ if (!canDefineTempVariablesInPlace) {
+ recordTempDeclaration(identifier);
+ }
+ emitAssignment(identifier, expr);
+ return identifier;
}
function createDefaultValueCheck(value: Expression, defaultValue: Expression): Expression {
// The value expression will be evaluated twice, so for anything but a simple identifier
// we need to generate a temporary variable
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
// Return the expression 'value === void 0 ? defaultValue : value'
let equals = createSynthesizedNode(SyntaxKind.BinaryExpression);
equals.left = value;
@@ -3286,7 +3296,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (properties.length !== 1) {
// For anything but a single element destructuring we need to generate a temporary
// to ensure value is evaluated exactly once.
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
}
for (let p of properties) {
if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) {
@@ -3301,7 +3311,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (elements.length !== 1) {
// For anything but a single element destructuring we need to generate a temporary
// to ensure value is evaluated exactly once.
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
}
for (let i = 0; i < elements.length; i++) {
let e = elements[i];
@@ -3346,7 +3356,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (root.parent.kind !== SyntaxKind.ParenthesizedExpression) {
write("(");
}
- value = ensureIdentifier(value);
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
emitDestructuringAssignment(target, value);
write(", ");
emit(value);
@@ -3356,7 +3366,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
- function emitBindingElement(target: BindingElement, value: Expression) {
+ function emitBindingElement(target: BindingElement | VariableDeclaration, value: Expression) {
if (target.initializer) {
// Combine value and initializer
value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer;
@@ -3366,14 +3376,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
value = createVoidZero();
}
if (isBindingPattern(target.name)) {
- let pattern = target.name;
- let elements = pattern.elements;
- if (elements.length !== 1) {
- // For anything but a single element destructuring we need to generate a temporary
- // to ensure value is evaluated exactly once.
- value = ensureIdentifier(value);
+ const pattern = target.name;
+ const elements = pattern.elements;
+ const numElements = elements.length;
+
+ if (numElements !== 1) {
+ // For anything other than a single-element destructuring we need to generate a temporary
+ // to ensure value is evaluated exactly once. Additionally, if we have zero elements
+ // we need to emit *something* to ensure that in case a 'var' keyword was already emitted,
+ // so in that case, we'll intentionally create that temporary.
+ value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0);
}
- for (let i = 0; i < elements.length; i++) {
+
+ for (let i = 0; i < numElements; i++) {
let element = elements[i];
if (pattern.kind === SyntaxKind.ObjectBindingPattern) {
// Rewrite element to a declaration with an initializer that fetches property
@@ -3385,7 +3400,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// Rewrite element to a declaration that accesses array element at index i
emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i)));
}
- else if (i === elements.length - 1) {
+ else if (i === numElements - 1) {
emitBindingElement(element, createSliceCall(value, i));
}
}
diff --git a/src/compiler/program.ts b/src/compiler/program.ts
index 1ac4151e834..3da3c354fb2 100644
--- a/src/compiler/program.ts
+++ b/src/compiler/program.ts
@@ -12,7 +12,7 @@ namespace ts {
let emptyArray: any[] = [];
- export const version = "1.6.0";
+ export const version = "1.7.0";
export function findConfigFile(searchPath: string): string {
let fileName = "tsconfig.json";
@@ -862,8 +862,8 @@ namespace ts {
const importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]);
if (importedFile && resolution.isExternalLibraryImport) {
if (!isExternalModule(importedFile)) {
- let start = getTokenPosOfNode(file.imports[i], file)
- fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
+ let start = getTokenPosOfNode(file.imports[i], file)
+ fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
}
else if (!fileExtensionIs(importedFile.fileName, ".d.ts")) {
let start = getTokenPosOfNode(file.imports[i], file)
diff --git a/src/compiler/types.ts b/src/compiler/types.ts
index 58228679d3b..225f804e8a7 100644
--- a/src/compiler/types.ts
+++ b/src/compiler/types.ts
@@ -2122,17 +2122,30 @@ namespace ts {
}
/* @internal */
- export interface CommandLineOption {
+ export interface CommandLineOptionBase {
name: string;
type: string | Map; // "string", "number", "boolean", or an object literal mapping named values to actual values
isFilePath?: boolean; // True if option value is a path or fileName
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'
description?: DiagnosticMessage; // The message describing what the command line switch does
paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter
- error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'
experimental?: boolean;
}
+ /* @internal */
+ export interface CommandLineOptionOfPrimitiveType extends CommandLineOptionBase {
+ type: string; // "string" | "number" | "boolean"
+ }
+
+ /* @internal */
+ export interface CommandLineOptionOfCustomType extends CommandLineOptionBase {
+ type: Map; // an object literal mapping named values to actual values
+ error: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'
+ }
+
+ /* @internal */
+ export type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType;
+
/* @internal */
export const enum CharacterCodes {
nullCharacter = 0,
diff --git a/src/harness/harness.ts b/src/harness/harness.ts
index 01b583d64e1..57eb848ac23 100644
--- a/src/harness/harness.ts
+++ b/src/harness/harness.ts
@@ -428,6 +428,7 @@ module Harness {
args(): string[];
getExecutingFilePath(): string;
exit(exitCode?: number): void;
+ readDirectory(path: string, extension?: string, exclude?: string[]): string[];
}
export var IO: IO;
@@ -464,6 +465,7 @@ module Harness {
export const directoryExists: typeof IO.directoryExists = fso.FolderExists;
export const fileExists: typeof IO.fileExists = fso.FileExists;
export const log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine;
+ export const readDirectory: typeof IO.readDirectory = (path, extension, exclude) => ts.sys.readDirectory(path, extension, exclude);
export function createDirectory(path: string) {
if (directoryExists(path)) {
@@ -532,6 +534,8 @@ module Harness {
export const fileExists: typeof IO.fileExists = fs.existsSync;
export const log: typeof IO.log = s => console.log(s);
+ export const readDirectory: typeof IO.readDirectory = (path, extension, exclude) => ts.sys.readDirectory(path, extension, exclude);
+
export function createDirectory(path: string) {
if (!directoryExists(path)) {
fs.mkdirSync(path);
@@ -730,6 +734,10 @@ module Harness {
export function writeFile(path: string, contents: string) {
Http.writeToServerSync(serverRoot + path, "WRITE", contents);
}
+
+ export function readDirectory(path: string, extension?: string, exclude?: string[]) {
+ return listFiles(path).filter(f => !extension || ts.fileExtensionIs(f, extension));
+ }
}
}
diff --git a/src/harness/instrumenter.ts b/src/harness/instrumenter.ts
index 1c9b9af78d2..b1b1750b8a8 100644
--- a/src/harness/instrumenter.ts
+++ b/src/harness/instrumenter.ts
@@ -3,11 +3,15 @@ var fs: any = require('fs');
var path: any = require('path');
function instrumentForRecording(fn: string, tscPath: string) {
- instrument(tscPath, 'ts.sys = Playback.wrapSystem(ts.sys); ts.sys.startRecord("' + fn + '");', 'ts.sys.endRecord();');
+ instrument(tscPath, `
+ts.sys = Playback.wrapSystem(ts.sys);
+ts.sys.startRecord("${ fn }");`, `ts.sys.endRecord();`);
}
function instrumentForReplay(logFilename: string, tscPath: string) {
- instrument(tscPath, 'ts.sys = Playback.wrapSystem(ts.sys); ts.sys.startReplay("' + logFilename + '");');
+ instrument(tscPath, `
+ts.sys = Playback.wrapSystem(ts.sys);
+ts.sys.startReplay("${ logFilename }");`);
}
function instrument(tscPath: string, prepareCode: string, cleanupCode: string = '') {
diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts
index 5a572e220b3..d0801612500 100644
--- a/src/harness/loggedIO.ts
+++ b/src/harness/loggedIO.ts
@@ -59,6 +59,12 @@ interface IOLog {
path: string;
result?: string;
}[];
+ directoriesRead: {
+ path: string,
+ extension: string,
+ exclude: string[],
+ result: string[]
+ }[];
}
interface PlaybackControl {
@@ -95,12 +101,15 @@ module Playback {
export interface PlaybackIO extends Harness.IO, PlaybackControl { }
+ export interface PlaybackSystem extends ts.System, PlaybackControl { }
+
function createEmptyLog(): IOLog {
return {
timestamp: (new Date()).toString(),
arguments: [],
currentDirectory: "",
filesRead: [],
+ directoriesRead: [],
filesWritten: [],
filesDeleted: [],
filesAppended: [],
@@ -114,8 +123,10 @@ module Playback {
};
}
- function initWrapper(wrapper: PlaybackControl, underlying: T) {
- Object.keys(underlying).forEach(prop => {
+ function initWrapper(wrapper: PlaybackSystem, underlying: ts.System): void;
+ function initWrapper(wrapper: PlaybackIO, underlying: Harness.IO): void;
+ function initWrapper(wrapper: PlaybackSystem | PlaybackIO, underlying: ts.System | Harness.IO): void {
+ ts.forEach(Object.keys(underlying), prop => {
(wrapper)[prop] = (underlying)[prop];
});
@@ -135,6 +146,93 @@ module Playback {
wrapper.startRecord = (fileNameBase) => {
recordLogFileNameBase = fileNameBase;
recordLog = createEmptyLog();
+
+ if (typeof underlying.args !== "function") {
+ recordLog.arguments = underlying.args;
+ }
+ };
+
+ wrapper.startReplayFromFile = logFn => {
+ wrapper.startReplayFromString(underlying.readFile(logFn));
+ };
+ wrapper.endRecord = () => {
+ if (recordLog !== undefined) {
+ let i = 0;
+ let fn = () => recordLogFileNameBase + i + ".json";
+ while (underlying.fileExists(fn())) i++;
+ underlying.writeFile(fn(), JSON.stringify(recordLog));
+ recordLog = undefined;
+ }
+ };
+
+ wrapper.fileExists = recordReplay(wrapper.fileExists, underlying)(
+ path => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path }),
+ memoize(path => {
+ // If we read from the file, it must exist
+ if (findResultByPath(wrapper, replayLog.filesRead, path, null) !== null) {
+ return true;
+ }
+ else {
+ return findResultByFields(replayLog.fileExists, { path }, false);
+ }
+ })
+ );
+
+ wrapper.getExecutingFilePath = () => {
+ if (replayLog !== undefined) {
+ return replayLog.executingPath;
+ }
+ else if (recordLog !== undefined) {
+ return recordLog.executingPath = underlying.getExecutingFilePath();
+ }
+ else {
+ return underlying.getExecutingFilePath();
+ }
+ };
+
+ wrapper.getCurrentDirectory = () => {
+ if (replayLog !== undefined) {
+ return replayLog.currentDirectory || "";
+ }
+ else if (recordLog !== undefined) {
+ return recordLog.currentDirectory = underlying.getCurrentDirectory();
+ }
+ else {
+ return underlying.getCurrentDirectory();
+ }
+ };
+
+ wrapper.resolvePath = recordReplay(wrapper.resolvePath, underlying)(
+ path => callAndRecord(underlying.resolvePath(path), recordLog.pathsResolved, { path }),
+ memoize(path => findResultByFields(replayLog.pathsResolved, { path }, !ts.isRootedDiskPath(ts.normalizeSlashes(path)) && replayLog.currentDirectory ? replayLog.currentDirectory + "/" + path : ts.normalizeSlashes(path))));
+
+ wrapper.readFile = recordReplay(wrapper.readFile, underlying)(
+ path => {
+ let result = underlying.readFile(path);
+ let logEntry = { path, codepage: 0, result: { contents: result, codepage: 0 } };
+ recordLog.filesRead.push(logEntry);
+ return result;
+ },
+ memoize(path => findResultByPath(wrapper, replayLog.filesRead, path).contents));
+
+ wrapper.readDirectory = recordReplay(wrapper.readDirectory, underlying)(
+ (path, extension, exclude) => {
+ let result = (underlying).readDirectory(path, extension, exclude);
+ let logEntry = { path, extension, exclude, result };
+ recordLog.directoriesRead.push(logEntry);
+ return result;
+ },
+ (path, extension, exclude) => findResultByPath(wrapper, replayLog.directoriesRead.filter(d => d.extension === extension && ts.arrayIsEqualTo(d.exclude, exclude)), path));
+
+ wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)(
+ (path, contents) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }),
+ (path, contents) => noOpReplay("writeFile"));
+
+ wrapper.exit = (exitCode) => {
+ if (recordLog !== undefined) {
+ wrapper.endRecord();
+ }
+ underlying.exit(exitCode);
};
}
@@ -143,9 +241,11 @@ module Playback {
return (function () {
if (replayLog !== undefined) {
return replay.apply(undefined, arguments);
- } else if (recordLog !== undefined) {
+ }
+ else if (recordLog !== undefined) {
return record.apply(undefined, arguments);
- } else {
+ }
+ else {
return original.apply(underlying, arguments);
}
});
@@ -169,7 +269,8 @@ module Playback {
if (results.length === 0) {
if (defaultValue !== undefined) {
return defaultValue;
- } else {
+ }
+ else {
throw new Error("No matching result in log array for: " + JSON.stringify(expectedFields));
}
}
@@ -177,7 +278,7 @@ module Playback {
}
function findResultByPath(wrapper: { resolvePath(s: string): string }, logArray: { path: string; result?: T }[], expectedPath: string, defaultValue?: T): T {
- let normalizedName = ts.normalizeSlashes(expectedPath).toLowerCase();
+ let normalizedName = ts.normalizePath(expectedPath).toLowerCase();
// Try to find the result through normal fileName
for (let i = 0; i < logArray.length; i++) {
if (ts.normalizeSlashes(logArray[i].path).toLowerCase() === normalizedName) {
@@ -193,10 +294,12 @@ module Playback {
}
}
}
+
// If we got here, we didn't find a match
if (defaultValue === undefined) {
throw new Error("No matching result in log array for path: " + expectedPath);
- } else {
+ }
+ else {
return defaultValue;
}
}
@@ -214,7 +317,8 @@ module Playback {
}
if (pathEquivCache.hasOwnProperty(key)) {
return pathEquivCache[key];
- } else {
+ }
+ else {
return pathEquivCache[key] = check();
}
}
@@ -227,93 +331,18 @@ module Playback {
let wrapper: PlaybackIO = {};
initWrapper(wrapper, underlying);
- wrapper.startReplayFromFile = logFn => {
- wrapper.startReplayFromString(underlying.readFile(logFn));
- };
- wrapper.endRecord = () => {
- if (recordLog !== undefined) {
- let i = 0;
- let fn = () => recordLogFileNameBase + i + ".json";
- while (underlying.fileExists(fn())) i++;
- underlying.writeFile(fn(), JSON.stringify(recordLog));
- recordLog = undefined;
- }
- };
-
- wrapper.args = () => {
- if (replayLog !== undefined) {
- return replayLog.arguments;
- } else if (recordLog !== undefined) {
- recordLog.arguments = underlying.args();
- }
- return underlying.args();
- }
-
- wrapper.newLine = () => underlying.newLine();
- wrapper.useCaseSensitiveFileNames = () => underlying.useCaseSensitiveFileNames();
wrapper.directoryName = (path): string => { throw new Error("NotSupported"); };
- wrapper.createDirectory = path => { throw new Error("NotSupported"); };
+ wrapper.createDirectory = (path): void => { throw new Error("NotSupported"); };
wrapper.directoryExists = (path): boolean => { throw new Error("NotSupported"); };
- wrapper.deleteFile = path => { throw new Error("NotSupported"); };
+ wrapper.deleteFile = (path): void => { throw new Error("NotSupported"); };
wrapper.listFiles = (path, filter, options): string[] => { throw new Error("NotSupported"); };
- wrapper.log = text => underlying.log(text);
-
- wrapper.fileExists = recordReplay(wrapper.fileExists, underlying)(
- (path) => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path: path }),
- memoize((path) => {
- // If we read from the file, it must exist
- if (findResultByPath(wrapper, replayLog.filesRead, path, null) !== null) {
- return true;
- } else {
- return findResultByFields(replayLog.fileExists, { path: path }, false);
- }
- })
- );
-
- wrapper.getExecutingFilePath = () => {
- if (replayLog !== undefined) {
- return replayLog.executingPath;
- } else if (recordLog !== undefined) {
- return recordLog.executingPath = underlying.getExecutingFilePath();
- } else {
- return underlying.getExecutingFilePath();
- }
- };
-
- wrapper.getCurrentDirectory = () => {
- if (replayLog !== undefined) {
- return replayLog.currentDirectory || "";
- } else if (recordLog !== undefined) {
- return recordLog.currentDirectory = underlying.getCurrentDirectory();
- } else {
- return underlying.getCurrentDirectory();
- }
- };
-
- wrapper.resolvePath = recordReplay(wrapper.resolvePath, underlying)(
- (path) => callAndRecord(underlying.resolvePath(path), recordLog.pathsResolved, { path: path }),
- memoize((path) => findResultByFields(replayLog.pathsResolved, { path: path }, !ts.isRootedDiskPath(ts.normalizeSlashes(path)) && replayLog.currentDirectory ? replayLog.currentDirectory + "/" + path : ts.normalizeSlashes(path))));
-
- wrapper.readFile = recordReplay(wrapper.readFile, underlying)(
- (path) => {
- let result = underlying.readFile(path);
- let logEntry = { path: path, codepage: 0, result: { contents: result, codepage: 0 } };
- recordLog.filesRead.push(logEntry);
- return result;
- },
- memoize((path) => findResultByPath(wrapper, replayLog.filesRead, path).contents));
-
- wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)(
- (path, contents) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path: path, contents: contents, bom: false }),
- (path, contents) => noOpReplay("writeFile"));
-
- wrapper.exit = (exitCode) => {
- if (recordLog !== undefined) {
- wrapper.endRecord();
- }
- underlying.exit(exitCode);
- };
return wrapper;
}
+
+ export function wrapSystem(underlying: ts.System): PlaybackSystem {
+ let wrapper: PlaybackSystem = {};
+ initWrapper(wrapper, underlying);
+ return wrapper;
+ }
}
\ No newline at end of file
diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts
index a1aaeed3d55..1e81392049d 100644
--- a/src/harness/rwcRunner.ts
+++ b/src/harness/rwcRunner.ts
@@ -19,6 +19,11 @@ module RWC {
}
}
+ function isTsConfigFile(file: { path: string }): boolean {
+ const tsConfigFileName = "tsconfig.json";
+ return file.path.substr(file.path.length - tsConfigFileName.length).toLowerCase() === tsConfigFileName;
+ }
+
export function runRWCTest(jsonPath: string) {
describe("Testing a RWC project: " + jsonPath, () => {
let inputFiles: { unitName: string; content: string; }[] = [];
@@ -67,10 +72,21 @@ module RWC {
runWithIOLog(ioLog, oldIO => {
harnessCompiler.reset();
+ let fileNames = opts.fileNames;
+
+ let tsconfigFile = ts.forEach(ioLog.filesRead, f => isTsConfigFile(f) ? f : undefined);
+ if (tsconfigFile) {
+ let tsconfigFileContents = getHarnessCompilerInputUnit(tsconfigFile.path);
+ let parsedTsconfigFileContents = ts.parseConfigFileText(tsconfigFile.path, tsconfigFileContents.content);
+ let configParseResult = ts.parseConfigFile(parsedTsconfigFileContents.config, Harness.IO, ts.getDirectoryPath(tsconfigFile.path));
+ fileNames = configParseResult.fileNames;
+ opts.options = ts.extend(opts.options, configParseResult.options);
+ }
+
// Load the files
- ts.forEach(opts.fileNames, fileName => {
+ for (let fileName of fileNames) {
inputFiles.push(getHarnessCompilerInputUnit(fileName));
- });
+ }
// Add files to compilation
let isInInputList = (resolvedPath: string) => (inputFile: { unitName: string; content: string; }) => inputFile.unitName === resolvedPath;
@@ -79,6 +95,10 @@ module RWC {
const resolvedPath = ts.normalizeSlashes(Harness.IO.resolvePath(fileRead.path));
let inInputList = ts.forEach(inputFiles, isInInputList(resolvedPath));
+ if (isTsConfigFile(fileRead)) {
+ continue;
+ }
+
if (!Harness.isLibraryFile(fileRead.path)) {
if (inInputList) {
continue;
diff --git a/src/services/services.ts b/src/services/services.ts
index 6f4ae2cdb1a..9d7cd55c5fb 100644
--- a/src/services/services.ts
+++ b/src/services/services.ts
@@ -2152,6 +2152,7 @@ namespace ts {
//
// export * from "mod"
// export {a as b} from "mod"
+ // export import i = require("mod")
while (token !== SyntaxKind.EndOfFileToken) {
if (token === SyntaxKind.DeclareKeyword) {
@@ -2276,6 +2277,25 @@ namespace ts {
}
}
}
+ else if (token === SyntaxKind.ImportKeyword) {
+ token = scanner.scan();
+ if (token === SyntaxKind.Identifier || isKeyword(token)) {
+ token = scanner.scan();
+ if (token === SyntaxKind.EqualsToken) {
+ token = scanner.scan();
+ if (token === SyntaxKind.RequireKeyword) {
+ token = scanner.scan();
+ if (token === SyntaxKind.OpenParenToken) {
+ token = scanner.scan();
+ if (token === SyntaxKind.StringLiteral) {
+ // export import i = require("mod");
+ recordModuleName();
+ }
+ }
+ }
+ }
+ }
+ }
}
token = scanner.scan();
}
diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter01.js b/tests/baselines/reference/emptyArrayBindingPatternParameter01.js
index 5723c74f117..1eb76741e84 100644
--- a/tests/baselines/reference/emptyArrayBindingPatternParameter01.js
+++ b/tests/baselines/reference/emptyArrayBindingPatternParameter01.js
@@ -1,6 +1,5 @@
//// [emptyArrayBindingPatternParameter01.ts]
-
function f([]) {
var x, y, z;
}
@@ -9,3 +8,7 @@ function f([]) {
function f(_a) {
var x, y, z;
}
+
+
+//// [emptyArrayBindingPatternParameter01.d.ts]
+declare function f([]: any[]): void;
diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols b/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols
index f5089ce5850..e1630be639b 100644
--- a/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols
+++ b/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols
@@ -1,11 +1,10 @@
=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts ===
-
function f([]) {
>f : Symbol(f, Decl(emptyArrayBindingPatternParameter01.ts, 0, 0))
var x, y, z;
->x : Symbol(x, Decl(emptyArrayBindingPatternParameter01.ts, 3, 7))
->y : Symbol(y, Decl(emptyArrayBindingPatternParameter01.ts, 3, 10))
->z : Symbol(z, Decl(emptyArrayBindingPatternParameter01.ts, 3, 13))
+>x : Symbol(x, Decl(emptyArrayBindingPatternParameter01.ts, 2, 7))
+>y : Symbol(y, Decl(emptyArrayBindingPatternParameter01.ts, 2, 10))
+>z : Symbol(z, Decl(emptyArrayBindingPatternParameter01.ts, 2, 13))
}
diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter01.types b/tests/baselines/reference/emptyArrayBindingPatternParameter01.types
index 7ef40d52d59..4ca0b892ecf 100644
--- a/tests/baselines/reference/emptyArrayBindingPatternParameter01.types
+++ b/tests/baselines/reference/emptyArrayBindingPatternParameter01.types
@@ -1,6 +1,5 @@
=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts ===
-
function f([]) {
>f : ([]: any[]) => void
diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter02.js b/tests/baselines/reference/emptyArrayBindingPatternParameter02.js
index dbd86e843a8..d6dda16e12f 100644
--- a/tests/baselines/reference/emptyArrayBindingPatternParameter02.js
+++ b/tests/baselines/reference/emptyArrayBindingPatternParameter02.js
@@ -1,6 +1,5 @@
//// [emptyArrayBindingPatternParameter02.ts]
-
function f(a, []) {
var x, y, z;
}
@@ -9,3 +8,7 @@ function f(a, []) {
function f(a, _a) {
var x, y, z;
}
+
+
+//// [emptyArrayBindingPatternParameter02.d.ts]
+declare function f(a: any, []: any[]): void;
diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter02.symbols b/tests/baselines/reference/emptyArrayBindingPatternParameter02.symbols
index 48cdcfaf93d..3289c06f962 100644
--- a/tests/baselines/reference/emptyArrayBindingPatternParameter02.symbols
+++ b/tests/baselines/reference/emptyArrayBindingPatternParameter02.symbols
@@ -1,12 +1,11 @@
=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts ===
-
function f(a, []) {
>f : Symbol(f, Decl(emptyArrayBindingPatternParameter02.ts, 0, 0))
->a : Symbol(a, Decl(emptyArrayBindingPatternParameter02.ts, 2, 11))
+>a : Symbol(a, Decl(emptyArrayBindingPatternParameter02.ts, 1, 11))
var x, y, z;
->x : Symbol(x, Decl(emptyArrayBindingPatternParameter02.ts, 3, 7))
->y : Symbol(y, Decl(emptyArrayBindingPatternParameter02.ts, 3, 10))
->z : Symbol(z, Decl(emptyArrayBindingPatternParameter02.ts, 3, 13))
+>x : Symbol(x, Decl(emptyArrayBindingPatternParameter02.ts, 2, 7))
+>y : Symbol(y, Decl(emptyArrayBindingPatternParameter02.ts, 2, 10))
+>z : Symbol(z, Decl(emptyArrayBindingPatternParameter02.ts, 2, 13))
}
diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter02.types b/tests/baselines/reference/emptyArrayBindingPatternParameter02.types
index a58fe6b91d3..34d9e7dde6b 100644
--- a/tests/baselines/reference/emptyArrayBindingPatternParameter02.types
+++ b/tests/baselines/reference/emptyArrayBindingPatternParameter02.types
@@ -1,6 +1,5 @@
=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts ===
-
function f(a, []) {
>f : (a: any, []: any[]) => void
>a : any
diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter03.js b/tests/baselines/reference/emptyArrayBindingPatternParameter03.js
index e2c3f7196e6..4867b39ac2f 100644
--- a/tests/baselines/reference/emptyArrayBindingPatternParameter03.js
+++ b/tests/baselines/reference/emptyArrayBindingPatternParameter03.js
@@ -1,6 +1,5 @@
//// [emptyArrayBindingPatternParameter03.ts]
-
function f(a, []) {
var x, y, z;
}
@@ -9,3 +8,7 @@ function f(a, []) {
function f(a, _a) {
var x, y, z;
}
+
+
+//// [emptyArrayBindingPatternParameter03.d.ts]
+declare function f(a: any, []: any[]): void;
diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter03.symbols b/tests/baselines/reference/emptyArrayBindingPatternParameter03.symbols
index d3ec078df78..86a95687310 100644
--- a/tests/baselines/reference/emptyArrayBindingPatternParameter03.symbols
+++ b/tests/baselines/reference/emptyArrayBindingPatternParameter03.symbols
@@ -1,12 +1,11 @@
=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts ===
-
function f(a, []) {
>f : Symbol(f, Decl(emptyArrayBindingPatternParameter03.ts, 0, 0))
->a : Symbol(a, Decl(emptyArrayBindingPatternParameter03.ts, 2, 11))
+>a : Symbol(a, Decl(emptyArrayBindingPatternParameter03.ts, 1, 11))
var x, y, z;
->x : Symbol(x, Decl(emptyArrayBindingPatternParameter03.ts, 3, 7))
->y : Symbol(y, Decl(emptyArrayBindingPatternParameter03.ts, 3, 10))
->z : Symbol(z, Decl(emptyArrayBindingPatternParameter03.ts, 3, 13))
+>x : Symbol(x, Decl(emptyArrayBindingPatternParameter03.ts, 2, 7))
+>y : Symbol(y, Decl(emptyArrayBindingPatternParameter03.ts, 2, 10))
+>z : Symbol(z, Decl(emptyArrayBindingPatternParameter03.ts, 2, 13))
}
diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter03.types b/tests/baselines/reference/emptyArrayBindingPatternParameter03.types
index 43f0af63ace..1c5579ebe36 100644
--- a/tests/baselines/reference/emptyArrayBindingPatternParameter03.types
+++ b/tests/baselines/reference/emptyArrayBindingPatternParameter03.types
@@ -1,6 +1,5 @@
=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts ===
-
function f(a, []) {
>f : (a: any, []: any[]) => void
>a : any
diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter04.js b/tests/baselines/reference/emptyArrayBindingPatternParameter04.js
index e0715499ffe..c9819c88f40 100644
--- a/tests/baselines/reference/emptyArrayBindingPatternParameter04.js
+++ b/tests/baselines/reference/emptyArrayBindingPatternParameter04.js
@@ -1,6 +1,5 @@
//// [emptyArrayBindingPatternParameter04.ts]
-
function f([] = [1,2,3,4]) {
var x, y, z;
}
@@ -10,3 +9,7 @@ function f(_a) {
var _a = [1, 2, 3, 4];
var x, y, z;
}
+
+
+//// [emptyArrayBindingPatternParameter04.d.ts]
+declare function f([]?: number[]): void;
diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter04.symbols b/tests/baselines/reference/emptyArrayBindingPatternParameter04.symbols
index bb76a2c5925..9f4c9bae0c6 100644
--- a/tests/baselines/reference/emptyArrayBindingPatternParameter04.symbols
+++ b/tests/baselines/reference/emptyArrayBindingPatternParameter04.symbols
@@ -1,11 +1,10 @@
=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts ===
-
function f([] = [1,2,3,4]) {
>f : Symbol(f, Decl(emptyArrayBindingPatternParameter04.ts, 0, 0))
var x, y, z;
->x : Symbol(x, Decl(emptyArrayBindingPatternParameter04.ts, 3, 7))
->y : Symbol(y, Decl(emptyArrayBindingPatternParameter04.ts, 3, 10))
->z : Symbol(z, Decl(emptyArrayBindingPatternParameter04.ts, 3, 13))
+>x : Symbol(x, Decl(emptyArrayBindingPatternParameter04.ts, 2, 7))
+>y : Symbol(y, Decl(emptyArrayBindingPatternParameter04.ts, 2, 10))
+>z : Symbol(z, Decl(emptyArrayBindingPatternParameter04.ts, 2, 13))
}
diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter04.types b/tests/baselines/reference/emptyArrayBindingPatternParameter04.types
index 6f00a994f7b..834eb41b34d 100644
--- a/tests/baselines/reference/emptyArrayBindingPatternParameter04.types
+++ b/tests/baselines/reference/emptyArrayBindingPatternParameter04.types
@@ -1,6 +1,5 @@
=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts ===
-
function f([] = [1,2,3,4]) {
>f : ([]?: number[]) => void
>[1,2,3,4] : number[]
diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js
index b89db88e5e5..fe0a642c51e 100644
--- a/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js
+++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js
@@ -9,3 +9,7 @@ var a: any;
var a;
(a);
(a);
+
+
+//// [emptyAssignmentPatterns01_ES5.d.ts]
+declare var a: any;
diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES6.js b/tests/baselines/reference/emptyAssignmentPatterns01_ES6.js
index fe311ac9061..4cf33452d98 100644
--- a/tests/baselines/reference/emptyAssignmentPatterns01_ES6.js
+++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES6.js
@@ -9,3 +9,7 @@ var a: any;
var a;
({} = a);
([] = a);
+
+
+//// [emptyAssignmentPatterns01_ES6.d.ts]
+declare var a: any;
diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js
index 7b9f1f402f9..27a0b5f9b61 100644
--- a/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js
+++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js
@@ -11,3 +11,8 @@ var a;
var x, y, z, a1, a2, a3;
((x = a.x, y = a.y, z = a.z, a));
((a1 = a[0], a2 = a[1], a3 = a[2], a));
+
+
+//// [emptyAssignmentPatterns02_ES5.d.ts]
+declare var a: any;
+declare let x: any, y: any, z: any, a1: any, a2: any, a3: any;
diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES6.js b/tests/baselines/reference/emptyAssignmentPatterns02_ES6.js
index e9783c7e57d..493246c9473 100644
--- a/tests/baselines/reference/emptyAssignmentPatterns02_ES6.js
+++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES6.js
@@ -11,3 +11,8 @@ var a;
let x, y, z, a1, a2, a3;
({} = { x, y, z } = a);
([] = [a1, a2, a3] = a);
+
+
+//// [emptyAssignmentPatterns02_ES6.d.ts]
+declare var a: any;
+declare let x: any, y: any, z: any, a1: any, a2: any, a3: any;
diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js
index d9ff8ba9ede..adaad2e3b63 100644
--- a/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js
+++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js
@@ -9,3 +9,7 @@ var a: any;
var a;
(a);
(a);
+
+
+//// [emptyAssignmentPatterns03_ES5.d.ts]
+declare var a: any;
diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES6.js b/tests/baselines/reference/emptyAssignmentPatterns03_ES6.js
index 95bfdfefa52..8050cc1e47a 100644
--- a/tests/baselines/reference/emptyAssignmentPatterns03_ES6.js
+++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES6.js
@@ -9,3 +9,7 @@ var a: any;
var a;
({} = {} = a);
([] = [] = a);
+
+
+//// [emptyAssignmentPatterns03_ES6.d.ts]
+declare var a: any;
diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js
index 7e342d08e39..e6b3cc7e3f2 100644
--- a/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js
+++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js
@@ -12,3 +12,8 @@ var x, y, z, a1, a2, a3;
(_a = a, x = _a.x, y = _a.y, z = _a.z, _a);
(_b = a, a1 = _b[0], a2 = _b[1], a3 = _b[2], _b);
var _a, _b;
+
+
+//// [emptyAssignmentPatterns04_ES5.d.ts]
+declare var a: any;
+declare let x: any, y: any, z: any, a1: any, a2: any, a3: any;
diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES6.js b/tests/baselines/reference/emptyAssignmentPatterns04_ES6.js
index eabc2678c05..fb52975d6d1 100644
--- a/tests/baselines/reference/emptyAssignmentPatterns04_ES6.js
+++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES6.js
@@ -11,3 +11,8 @@ var a;
let x, y, z, a1, a2, a3;
({ x, y, z } = {} = a);
([a1, a2, a3] = [] = a);
+
+
+//// [emptyAssignmentPatterns04_ES6.d.ts]
+declare var a: any;
+declare let x: any, y: any, z: any, a1: any, a2: any, a3: any;
diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter01.js b/tests/baselines/reference/emptyObjectBindingPatternParameter01.js
index 28cc30d2a0b..6a8ec808cd0 100644
--- a/tests/baselines/reference/emptyObjectBindingPatternParameter01.js
+++ b/tests/baselines/reference/emptyObjectBindingPatternParameter01.js
@@ -1,6 +1,5 @@
//// [emptyObjectBindingPatternParameter01.ts]
-
function f({}) {
var x, y, z;
}
@@ -9,3 +8,7 @@ function f({}) {
function f(_a) {
var x, y, z;
}
+
+
+//// [emptyObjectBindingPatternParameter01.d.ts]
+declare function f({}: {}): void;
diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter01.symbols b/tests/baselines/reference/emptyObjectBindingPatternParameter01.symbols
index 98829df994f..3ef5898c29a 100644
--- a/tests/baselines/reference/emptyObjectBindingPatternParameter01.symbols
+++ b/tests/baselines/reference/emptyObjectBindingPatternParameter01.symbols
@@ -1,11 +1,10 @@
=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts ===
-
function f({}) {
>f : Symbol(f, Decl(emptyObjectBindingPatternParameter01.ts, 0, 0))
var x, y, z;
->x : Symbol(x, Decl(emptyObjectBindingPatternParameter01.ts, 3, 7))
->y : Symbol(y, Decl(emptyObjectBindingPatternParameter01.ts, 3, 10))
->z : Symbol(z, Decl(emptyObjectBindingPatternParameter01.ts, 3, 13))
+>x : Symbol(x, Decl(emptyObjectBindingPatternParameter01.ts, 2, 7))
+>y : Symbol(y, Decl(emptyObjectBindingPatternParameter01.ts, 2, 10))
+>z : Symbol(z, Decl(emptyObjectBindingPatternParameter01.ts, 2, 13))
}
diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter01.types b/tests/baselines/reference/emptyObjectBindingPatternParameter01.types
index c46569ea770..05ddc54719c 100644
--- a/tests/baselines/reference/emptyObjectBindingPatternParameter01.types
+++ b/tests/baselines/reference/emptyObjectBindingPatternParameter01.types
@@ -1,6 +1,5 @@
=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts ===
-
function f({}) {
>f : ({}: {}) => void
diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter02.js b/tests/baselines/reference/emptyObjectBindingPatternParameter02.js
index 8488428ea51..be2bdcab298 100644
--- a/tests/baselines/reference/emptyObjectBindingPatternParameter02.js
+++ b/tests/baselines/reference/emptyObjectBindingPatternParameter02.js
@@ -1,6 +1,5 @@
//// [emptyObjectBindingPatternParameter02.ts]
-
function f(a, {}) {
var x, y, z;
}
@@ -9,3 +8,7 @@ function f(a, {}) {
function f(a, _a) {
var x, y, z;
}
+
+
+//// [emptyObjectBindingPatternParameter02.d.ts]
+declare function f(a: any, {}: {}): void;
diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter02.symbols b/tests/baselines/reference/emptyObjectBindingPatternParameter02.symbols
index fb0fa946b6f..d5bb4f292aa 100644
--- a/tests/baselines/reference/emptyObjectBindingPatternParameter02.symbols
+++ b/tests/baselines/reference/emptyObjectBindingPatternParameter02.symbols
@@ -1,12 +1,11 @@
=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts ===
-
function f(a, {}) {
>f : Symbol(f, Decl(emptyObjectBindingPatternParameter02.ts, 0, 0))
->a : Symbol(a, Decl(emptyObjectBindingPatternParameter02.ts, 2, 11))
+>a : Symbol(a, Decl(emptyObjectBindingPatternParameter02.ts, 1, 11))
var x, y, z;
->x : Symbol(x, Decl(emptyObjectBindingPatternParameter02.ts, 3, 7))
->y : Symbol(y, Decl(emptyObjectBindingPatternParameter02.ts, 3, 10))
->z : Symbol(z, Decl(emptyObjectBindingPatternParameter02.ts, 3, 13))
+>x : Symbol(x, Decl(emptyObjectBindingPatternParameter02.ts, 2, 7))
+>y : Symbol(y, Decl(emptyObjectBindingPatternParameter02.ts, 2, 10))
+>z : Symbol(z, Decl(emptyObjectBindingPatternParameter02.ts, 2, 13))
}
diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter02.types b/tests/baselines/reference/emptyObjectBindingPatternParameter02.types
index 0a77fac8588..e2b485538e6 100644
--- a/tests/baselines/reference/emptyObjectBindingPatternParameter02.types
+++ b/tests/baselines/reference/emptyObjectBindingPatternParameter02.types
@@ -1,6 +1,5 @@
=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts ===
-
function f(a, {}) {
>f : (a: any, {}: {}) => void
>a : any
diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter03.js b/tests/baselines/reference/emptyObjectBindingPatternParameter03.js
index 0279744e386..320bfe2d0df 100644
--- a/tests/baselines/reference/emptyObjectBindingPatternParameter03.js
+++ b/tests/baselines/reference/emptyObjectBindingPatternParameter03.js
@@ -1,6 +1,5 @@
//// [emptyObjectBindingPatternParameter03.ts]
-
function f({}, a) {
var x, y, z;
}
@@ -9,3 +8,7 @@ function f({}, a) {
function f(_a, a) {
var x, y, z;
}
+
+
+//// [emptyObjectBindingPatternParameter03.d.ts]
+declare function f({}: {}, a: any): void;
diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter03.symbols b/tests/baselines/reference/emptyObjectBindingPatternParameter03.symbols
index 4e658e21ccf..82a1bcee75b 100644
--- a/tests/baselines/reference/emptyObjectBindingPatternParameter03.symbols
+++ b/tests/baselines/reference/emptyObjectBindingPatternParameter03.symbols
@@ -1,12 +1,11 @@
=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts ===
-
function f({}, a) {
>f : Symbol(f, Decl(emptyObjectBindingPatternParameter03.ts, 0, 0))
->a : Symbol(a, Decl(emptyObjectBindingPatternParameter03.ts, 2, 14))
+>a : Symbol(a, Decl(emptyObjectBindingPatternParameter03.ts, 1, 14))
var x, y, z;
->x : Symbol(x, Decl(emptyObjectBindingPatternParameter03.ts, 3, 7))
->y : Symbol(y, Decl(emptyObjectBindingPatternParameter03.ts, 3, 10))
->z : Symbol(z, Decl(emptyObjectBindingPatternParameter03.ts, 3, 13))
+>x : Symbol(x, Decl(emptyObjectBindingPatternParameter03.ts, 2, 7))
+>y : Symbol(y, Decl(emptyObjectBindingPatternParameter03.ts, 2, 10))
+>z : Symbol(z, Decl(emptyObjectBindingPatternParameter03.ts, 2, 13))
}
diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter03.types b/tests/baselines/reference/emptyObjectBindingPatternParameter03.types
index 873c748dd9b..0f89702402a 100644
--- a/tests/baselines/reference/emptyObjectBindingPatternParameter03.types
+++ b/tests/baselines/reference/emptyObjectBindingPatternParameter03.types
@@ -1,6 +1,5 @@
=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts ===
-
function f({}, a) {
>f : ({}: {}, a: any) => void
>a : any
diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter04.errors.txt b/tests/baselines/reference/emptyObjectBindingPatternParameter04.errors.txt
index cf1b0e9a9a1..03b58378a0f 100644
--- a/tests/baselines/reference/emptyObjectBindingPatternParameter04.errors.txt
+++ b/tests/baselines/reference/emptyObjectBindingPatternParameter04.errors.txt
@@ -1,11 +1,10 @@
-tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(3,18): error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{}'.
-tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(3,24): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{}'.
-tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(3,32): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type '{}'.
+tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(2,18): error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{}'.
+tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(2,24): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{}'.
+tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(2,32): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type '{}'.
==== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts (3 errors) ====
-
function f({} = {a: 1, b: "2", c: true}) {
~
!!! error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{}'.
diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter04.js b/tests/baselines/reference/emptyObjectBindingPatternParameter04.js
index fc3e41d0709..8c128bb806e 100644
--- a/tests/baselines/reference/emptyObjectBindingPatternParameter04.js
+++ b/tests/baselines/reference/emptyObjectBindingPatternParameter04.js
@@ -1,6 +1,5 @@
//// [emptyObjectBindingPatternParameter04.ts]
-
function f({} = {a: 1, b: "2", c: true}) {
var x, y, z;
}
@@ -10,3 +9,11 @@ function f(_a) {
var _a = { a: 1, b: "2", c: true };
var x, y, z;
}
+
+
+//// [emptyObjectBindingPatternParameter04.d.ts]
+declare function f({}?: {
+ a: number;
+ b: string;
+ c: boolean;
+}): void;
diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.js b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.js
new file mode 100644
index 00000000000..11c4f4e1807
--- /dev/null
+++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.js
@@ -0,0 +1,101 @@
+//// [emptyVariableDeclarationBindingPatterns01_ES5.ts]
+
+(function () {
+ var a: any;
+
+ var {} = a;
+ let {} = a;
+ const {} = a;
+
+ var [] = a;
+ let [] = a;
+ const [] = a;
+
+ var {} = a, [] = a;
+ let {} = a, [] = a;
+ const {} = a, [] = a;
+
+ var { p1: {}, p2: [] } = a;
+ let { p1: {}, p2: [] } = a;
+ const { p1: {}, p2: [] } = a;
+
+ for (var {} = {}, {} = {}; false; void 0) {
+ }
+
+ function f({} = a, [] = a, { p: {} = a} = a) {
+ return ({} = a, [] = a, { p: {} = a } = a) => a;
+ }
+})();
+
+(function () {
+ const ns: number[][] = [];
+
+ for (var {} of ns) {
+ }
+
+ for (let {} of ns) {
+ }
+
+ for (const {} of ns) {
+ }
+
+ for (var [] of ns) {
+ }
+
+ for (let [] of ns) {
+ }
+
+ for (const [] of ns) {
+ }
+})();
+
+//// [emptyVariableDeclarationBindingPatterns01_ES5.js]
+(function () {
+ var a;
+ var _a = a;
+ var _b = a;
+ var _c = a;
+ var _d = a;
+ var _e = a;
+ var _f = a;
+ var _g = a, _h = a;
+ var _j = a, _k = a;
+ var _l = a, _m = a;
+ var _o = a.p1, _p = a.p2;
+ var _q = a.p1, _r = a.p2;
+ var _s = a.p1, _t = a.p2;
+ for (var _u = {}, _v = {}; false; void 0) {
+ }
+ function f(_a, _b, _c) {
+ var _a = a;
+ var _b = a;
+ var _d = (_c === void 0 ? a : _c).p, _e = _d === void 0 ? a : _d;
+ return function (_a, _b, _c) {
+ var _a = a;
+ var _b = a;
+ var _d = (_c === void 0 ? a : _c).p, _e = _d === void 0 ? a : _d;
+ return a;
+ };
+ }
+})();
+(function () {
+ var ns = [];
+ for (var _i = 0; _i < ns.length; _i++) {
+ var _a = ns[_i];
+ }
+ for (var _b = 0; _b < ns.length; _b++) {
+ var _c = ns[_b];
+ }
+ for (var _d = 0; _d < ns.length; _d++) {
+ var _e = ns[_d];
+ }
+ for (var _f = 0; _f < ns.length; _f++) {
+ var _g = ns[_f];
+ }
+ for (var _h = 0; _h < ns.length; _h++) {
+ var _j = ns[_h];
+ }
+ for (var _k = 0; _k < ns.length; _k++) {
+ var _l = ns[_k];
+ }
+})();
diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.symbols b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.symbols
new file mode 100644
index 00000000000..ddba9738e08
--- /dev/null
+++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.symbols
@@ -0,0 +1,92 @@
+=== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5.ts ===
+
+(function () {
+ var a: any;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ var {} = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ let {} = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ const {} = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ var [] = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ let [] = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ const [] = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ var {} = a, [] = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ let {} = a, [] = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ const {} = a, [] = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ var { p1: {}, p2: [] } = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ let { p1: {}, p2: [] } = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ const { p1: {}, p2: [] } = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ for (var {} = {}, {} = {}; false; void 0) {
+ }
+
+ function f({} = a, [] = a, { p: {} = a} = a) {
+>f : Symbol(f, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 21, 5))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+
+ return ({} = a, [] = a, { p: {} = a } = a) => a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7))
+ }
+})();
+
+(function () {
+ const ns: number[][] = [];
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9))
+
+ for (var {} of ns) {
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9))
+ }
+
+ for (let {} of ns) {
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9))
+ }
+
+ for (const {} of ns) {
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9))
+ }
+
+ for (var [] of ns) {
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9))
+ }
+
+ for (let [] of ns) {
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9))
+ }
+
+ for (const [] of ns) {
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9))
+ }
+})();
diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types
new file mode 100644
index 00000000000..ed6b935db0f
--- /dev/null
+++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types
@@ -0,0 +1,115 @@
+=== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5.ts ===
+
+(function () {
+>(function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }})() : void
+>(function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }}) : () => void
+>function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }} : () => void
+
+ var a: any;
+>a : any
+
+ var {} = a;
+>a : any
+
+ let {} = a;
+>a : any
+
+ const {} = a;
+>a : any
+
+ var [] = a;
+>a : any
+
+ let [] = a;
+>a : any
+
+ const [] = a;
+>a : any
+
+ var {} = a, [] = a;
+>a : any
+>a : any
+
+ let {} = a, [] = a;
+>a : any
+>a : any
+
+ const {} = a, [] = a;
+>a : any
+>a : any
+
+ var { p1: {}, p2: [] } = a;
+>p1 : any
+>p2 : any
+>a : any
+
+ let { p1: {}, p2: [] } = a;
+>p1 : any
+>p2 : any
+>a : any
+
+ const { p1: {}, p2: [] } = a;
+>p1 : any
+>p2 : any
+>a : any
+
+ for (var {} = {}, {} = {}; false; void 0) {
+>{} : {}
+>{} : {}
+>false : boolean
+>void 0 : undefined
+>0 : number
+ }
+
+ function f({} = a, [] = a, { p: {} = a} = a) {
+>f : ({}?: any, []?: any, { p: {} = a}?: any) => ({}?: any, []?: any, { p: {} = a }?: any) => any
+>a : any
+>a : any
+>p : any
+>a : any
+>a : any
+
+ return ({} = a, [] = a, { p: {} = a } = a) => a;
+>({} = a, [] = a, { p: {} = a } = a) => a : ({}?: any, []?: any, { p: {} = a }?: any) => any
+>a : any
+>a : any
+>p : any
+>a : any
+>a : any
+>a : any
+ }
+})();
+
+(function () {
+>(function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }})() : void
+>(function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }}) : () => void
+>function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }} : () => void
+
+ const ns: number[][] = [];
+>ns : number[][]
+>[] : undefined[]
+
+ for (var {} of ns) {
+>ns : number[][]
+ }
+
+ for (let {} of ns) {
+>ns : number[][]
+ }
+
+ for (const {} of ns) {
+>ns : number[][]
+ }
+
+ for (var [] of ns) {
+>ns : number[][]
+ }
+
+ for (let [] of ns) {
+>ns : number[][]
+ }
+
+ for (const [] of ns) {
+>ns : number[][]
+ }
+})();
diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.js b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.js
new file mode 100644
index 00000000000..1303ab1e3d0
--- /dev/null
+++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.js
@@ -0,0 +1,87 @@
+//// [emptyVariableDeclarationBindingPatterns01_ES6.ts]
+
+(function () {
+ var a: any;
+
+ var {} = a;
+ let {} = a;
+ const {} = a;
+
+ var [] = a;
+ let [] = a;
+ const [] = a;
+
+ var {} = a, [] = a;
+ let {} = a, [] = a;
+ const {} = a, [] = a;
+
+ var { p1: {}, p2: [] } = a;
+ let { p1: {}, p2: [] } = a;
+ const { p1: {}, p2: [] } = a;
+
+ for (var {} = {}, {} = {}; false; void 0) {
+ }
+
+ function f({} = a, [] = a, { p: {} = a} = a) {
+ return ({} = a, [] = a, { p: {} = a } = a) => a;
+ }
+})();
+
+(function () {
+ const ns: number[][] = [];
+
+ for (var {} of ns) {
+ }
+
+ for (let {} of ns) {
+ }
+
+ for (const {} of ns) {
+ }
+
+ for (var [] of ns) {
+ }
+
+ for (let [] of ns) {
+ }
+
+ for (const [] of ns) {
+ }
+})();
+
+//// [emptyVariableDeclarationBindingPatterns01_ES6.js]
+(function () {
+ var a;
+ var { } = a;
+ let { } = a;
+ const { } = a;
+ var [] = a;
+ let [] = a;
+ const [] = a;
+ var { } = a, [] = a;
+ let { } = a, [] = a;
+ const { } = a, [] = a;
+ var { p1: { }, p2: [] } = a;
+ let { p1: { }, p2: [] } = a;
+ const { p1: { }, p2: [] } = a;
+ for (var { } = {}, { } = {}; false; void 0) {
+ }
+ function f({ } = a, [] = a, { p: { } = a } = a) {
+ return ({ } = a, [] = a, { p: { } = a } = a) => a;
+ }
+})();
+(function () {
+ const ns = [];
+ for (var { } of ns) {
+ }
+ for (let { } of ns) {
+ }
+ for (const { } of ns) {
+ }
+ for (var [] of ns) {
+ }
+ for (let [] of ns) {
+ }
+ for (const [] of ns) {
+ }
+})();
diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.symbols b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.symbols
new file mode 100644
index 00000000000..6a826d4b6c9
--- /dev/null
+++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.symbols
@@ -0,0 +1,92 @@
+=== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6.ts ===
+
+(function () {
+ var a: any;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ var {} = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ let {} = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ const {} = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ var [] = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ let [] = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ const [] = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ var {} = a, [] = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ let {} = a, [] = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ const {} = a, [] = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ var { p1: {}, p2: [] } = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ let { p1: {}, p2: [] } = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ const { p1: {}, p2: [] } = a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ for (var {} = {}, {} = {}; false; void 0) {
+ }
+
+ function f({} = a, [] = a, { p: {} = a} = a) {
+>f : Symbol(f, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 21, 5))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+
+ return ({} = a, [] = a, { p: {} = a } = a) => a;
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7))
+ }
+})();
+
+(function () {
+ const ns: number[][] = [];
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9))
+
+ for (var {} of ns) {
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9))
+ }
+
+ for (let {} of ns) {
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9))
+ }
+
+ for (const {} of ns) {
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9))
+ }
+
+ for (var [] of ns) {
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9))
+ }
+
+ for (let [] of ns) {
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9))
+ }
+
+ for (const [] of ns) {
+>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9))
+ }
+})();
diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types
new file mode 100644
index 00000000000..fcb48048148
--- /dev/null
+++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types
@@ -0,0 +1,115 @@
+=== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6.ts ===
+
+(function () {
+>(function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }})() : void
+>(function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }}) : () => void
+>function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }} : () => void
+
+ var a: any;
+>a : any
+
+ var {} = a;
+>a : any
+
+ let {} = a;
+>a : any
+
+ const {} = a;
+>a : any
+
+ var [] = a;
+>a : any
+
+ let [] = a;
+>a : any
+
+ const [] = a;
+>a : any
+
+ var {} = a, [] = a;
+>a : any
+>a : any
+
+ let {} = a, [] = a;
+>a : any
+>a : any
+
+ const {} = a, [] = a;
+>a : any
+>a : any
+
+ var { p1: {}, p2: [] } = a;
+>p1 : any
+>p2 : any
+>a : any
+
+ let { p1: {}, p2: [] } = a;
+>p1 : any
+>p2 : any
+>a : any
+
+ const { p1: {}, p2: [] } = a;
+>p1 : any
+>p2 : any
+>a : any
+
+ for (var {} = {}, {} = {}; false; void 0) {
+>{} : {}
+>{} : {}
+>false : boolean
+>void 0 : undefined
+>0 : number
+ }
+
+ function f({} = a, [] = a, { p: {} = a} = a) {
+>f : ({}?: any, []?: any, { p: {} = a}?: any) => ({}?: any, []?: any, { p: {} = a }?: any) => any
+>a : any
+>a : any
+>p : any
+>a : any
+>a : any
+
+ return ({} = a, [] = a, { p: {} = a } = a) => a;
+>({} = a, [] = a, { p: {} = a } = a) => a : ({}?: any, []?: any, { p: {} = a }?: any) => any
+>a : any
+>a : any
+>p : any
+>a : any
+>a : any
+>a : any
+ }
+})();
+
+(function () {
+>(function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }})() : void
+>(function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }}) : () => void
+>function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }} : () => void
+
+ const ns: number[][] = [];
+>ns : number[][]
+>[] : undefined[]
+
+ for (var {} of ns) {
+>ns : number[][]
+ }
+
+ for (let {} of ns) {
+>ns : number[][]
+ }
+
+ for (const {} of ns) {
+>ns : number[][]
+ }
+
+ for (var [] of ns) {
+>ns : number[][]
+ }
+
+ for (let [] of ns) {
+>ns : number[][]
+ }
+
+ for (const [] of ns) {
+>ns : number[][]
+ }
+})();
diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5.errors.txt b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5.errors.txt
new file mode 100644
index 00000000000..b589b075ecb
--- /dev/null
+++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5.errors.txt
@@ -0,0 +1,31 @@
+tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts(3,9): error TS1182: A destructuring declaration must have an initializer.
+tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts(4,9): error TS1182: A destructuring declaration must have an initializer.
+tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts(5,11): error TS1182: A destructuring declaration must have an initializer.
+tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts(7,9): error TS1182: A destructuring declaration must have an initializer.
+tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts(8,9): error TS1182: A destructuring declaration must have an initializer.
+tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts(9,11): error TS1182: A destructuring declaration must have an initializer.
+
+
+==== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts (6 errors) ====
+
+ (function () {
+ var {};
+ ~~
+!!! error TS1182: A destructuring declaration must have an initializer.
+ let {};
+ ~~
+!!! error TS1182: A destructuring declaration must have an initializer.
+ const {};
+ ~~
+!!! error TS1182: A destructuring declaration must have an initializer.
+
+ var [];
+ ~~
+!!! error TS1182: A destructuring declaration must have an initializer.
+ let [];
+ ~~
+!!! error TS1182: A destructuring declaration must have an initializer.
+ const [];
+ ~~
+!!! error TS1182: A destructuring declaration must have an initializer.
+ })();
\ No newline at end of file
diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5.js b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5.js
new file mode 100644
index 00000000000..7710b5e26c1
--- /dev/null
+++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5.js
@@ -0,0 +1,24 @@
+//// [emptyVariableDeclarationBindingPatterns02_ES5.ts]
+
+(function () {
+ var {};
+ let {};
+ const {};
+
+ var [];
+ let [];
+ const [];
+})();
+
+//// [emptyVariableDeclarationBindingPatterns02_ES5.js]
+(function () {
+ var _a = void 0;
+ var _b = void 0;
+ var _c = void 0;
+ var _d = void 0;
+ var _e = void 0;
+ var _f = void 0;
+})();
+
+
+//// [emptyVariableDeclarationBindingPatterns02_ES5.d.ts]
diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES6.errors.txt b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES6.errors.txt
new file mode 100644
index 00000000000..81349584f47
--- /dev/null
+++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES6.errors.txt
@@ -0,0 +1,31 @@
+tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts(3,9): error TS1182: A destructuring declaration must have an initializer.
+tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts(4,9): error TS1182: A destructuring declaration must have an initializer.
+tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts(5,11): error TS1182: A destructuring declaration must have an initializer.
+tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts(7,9): error TS1182: A destructuring declaration must have an initializer.
+tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts(8,9): error TS1182: A destructuring declaration must have an initializer.
+tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts(9,11): error TS1182: A destructuring declaration must have an initializer.
+
+
+==== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts (6 errors) ====
+
+ (function () {
+ var {};
+ ~~
+!!! error TS1182: A destructuring declaration must have an initializer.
+ let {};
+ ~~
+!!! error TS1182: A destructuring declaration must have an initializer.
+ const {};
+ ~~
+!!! error TS1182: A destructuring declaration must have an initializer.
+
+ var [];
+ ~~
+!!! error TS1182: A destructuring declaration must have an initializer.
+ let [];
+ ~~
+!!! error TS1182: A destructuring declaration must have an initializer.
+ const [];
+ ~~
+!!! error TS1182: A destructuring declaration must have an initializer.
+ })();
\ No newline at end of file
diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES6.js b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES6.js
new file mode 100644
index 00000000000..8b2df68ed70
--- /dev/null
+++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES6.js
@@ -0,0 +1,24 @@
+//// [emptyVariableDeclarationBindingPatterns02_ES6.ts]
+
+(function () {
+ var {};
+ let {};
+ const {};
+
+ var [];
+ let [];
+ const [];
+})();
+
+//// [emptyVariableDeclarationBindingPatterns02_ES6.js]
+(function () {
+ var { };
+ let { };
+ const { };
+ var [];
+ let [];
+ const [];
+})();
+
+
+//// [emptyVariableDeclarationBindingPatterns02_ES6.d.ts]
diff --git a/tests/cases/compiler/APISample_compile.ts b/tests/cases/compiler/APISample_compile.ts
index d3cc650dd2a..c63009f7d63 100644
--- a/tests/cases/compiler/APISample_compile.ts
+++ b/tests/cases/compiler/APISample_compile.ts
@@ -1,5 +1,5 @@
// @module: commonjs
-// @includebuiltfile: typescript.d.ts
+// @includebuiltfile: typescript_standalone.d.ts
// @stripInternal:true
/*
diff --git a/tests/cases/compiler/APISample_linter.ts b/tests/cases/compiler/APISample_linter.ts
index 9f9b55a0a67..8cb6934cee3 100644
--- a/tests/cases/compiler/APISample_linter.ts
+++ b/tests/cases/compiler/APISample_linter.ts
@@ -1,5 +1,5 @@
// @module: commonjs
-// @includebuiltfile: typescript.d.ts
+// @includebuiltfile: typescript_standalone.d.ts
// @stripInternal:true
/*
diff --git a/tests/cases/compiler/APISample_transform.ts b/tests/cases/compiler/APISample_transform.ts
index 48e27c4e008..88b9754536a 100644
--- a/tests/cases/compiler/APISample_transform.ts
+++ b/tests/cases/compiler/APISample_transform.ts
@@ -1,5 +1,5 @@
// @module: commonjs
-// @includebuiltfile: typescript.d.ts
+// @includebuiltfile: typescript_standalone.d.ts
// @stripInternal:true
/*
diff --git a/tests/cases/compiler/APISample_watcher.ts b/tests/cases/compiler/APISample_watcher.ts
index b152f86c378..9afa53ddf14 100644
--- a/tests/cases/compiler/APISample_watcher.ts
+++ b/tests/cases/compiler/APISample_watcher.ts
@@ -1,5 +1,5 @@
// @module: commonjs
-// @includebuiltfile: typescript.d.ts
+// @includebuiltfile: typescript_standalone.d.ts
// @stripInternal:true
/*
diff --git a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts
index 64b198b0916..90e25765847 100644
--- a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts
@@ -1,4 +1,4 @@
-
+// @declaration: true
function f([]) {
var x, y, z;
diff --git a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts
index 39663a4bed7..e9e99c6d0eb 100644
--- a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts
@@ -1,4 +1,4 @@
-
+// @declaration: true
function f(a, []) {
var x, y, z;
diff --git a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts
index 39663a4bed7..e9e99c6d0eb 100644
--- a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts
@@ -1,4 +1,4 @@
-
+// @declaration: true
function f(a, []) {
var x, y, z;
diff --git a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts
index 313d4fe6708..7f57c6a6acf 100644
--- a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts
@@ -1,4 +1,4 @@
-
+// @declaration: true
function f([] = [1,2,3,4]) {
var x, y, z;
diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts
index dd10e552615..44175dbb63a 100644
--- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts
@@ -1,4 +1,5 @@
// @target: es5
+// @declaration: true
var a: any;
diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts
index 043f0cf1108..4f367ee8853 100644
--- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts
@@ -1,4 +1,5 @@
// @target: es6
+// @declaration: true
var a: any;
diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts
index 60fe89758d6..1d291425e67 100644
--- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts
@@ -1,4 +1,5 @@
// @target: es5
+// @declaration: true
var a: any;
let x, y, z, a1, a2, a3;
diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts
index 295401545d4..b156883f7d2 100644
--- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts
@@ -1,4 +1,5 @@
// @target: es6
+// @declaration: true
var a: any;
let x, y, z, a1, a2, a3;
diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts
index 080c828ad62..dbe79355cd8 100644
--- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts
@@ -1,4 +1,5 @@
// @target: es5
+// @declaration: true
var a: any;
diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts
index 10d67254cd8..d86f01f5c79 100644
--- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts
@@ -1,4 +1,5 @@
// @target: es6
+// @declaration: true
var a: any;
diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts
index 0233ddcda70..ac79e87a11c 100644
--- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts
@@ -1,4 +1,5 @@
// @target: es5
+// @declaration: true
var a: any;
let x, y, z, a1, a2, a3;
diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts
index 3380a56aaa7..25e56c353b9 100644
--- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts
@@ -1,4 +1,5 @@
// @target: es6
+// @declaration: true
var a: any;
let x, y, z, a1, a2, a3;
diff --git a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts
index 01aa5b54230..270d7f10227 100644
--- a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts
@@ -1,4 +1,4 @@
-
+// @declaration: true
function f({}) {
var x, y, z;
diff --git a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts
index f34503c1152..79d026eac9e 100644
--- a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts
@@ -1,4 +1,4 @@
-
+// @declaration: true
function f(a, {}) {
var x, y, z;
diff --git a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts
index a940c659703..c5d51b20cfa 100644
--- a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts
@@ -1,4 +1,4 @@
-
+// @declaration: true
function f({}, a) {
var x, y, z;
diff --git a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts
index da05e5cb428..0273e174de0 100644
--- a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts
+++ b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts
@@ -1,4 +1,4 @@
-
+// @declaration: true
function f({} = {a: 1, b: "2", c: true}) {
var x, y, z;
diff --git a/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5.ts
new file mode 100644
index 00000000000..bc7a729fd1e
--- /dev/null
+++ b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5.ts
@@ -0,0 +1,50 @@
+// @target: es5
+
+(function () {
+ var a: any;
+
+ var {} = a;
+ let {} = a;
+ const {} = a;
+
+ var [] = a;
+ let [] = a;
+ const [] = a;
+
+ var {} = a, [] = a;
+ let {} = a, [] = a;
+ const {} = a, [] = a;
+
+ var { p1: {}, p2: [] } = a;
+ let { p1: {}, p2: [] } = a;
+ const { p1: {}, p2: [] } = a;
+
+ for (var {} = {}, {} = {}; false; void 0) {
+ }
+
+ function f({} = a, [] = a, { p: {} = a} = a) {
+ return ({} = a, [] = a, { p: {} = a } = a) => a;
+ }
+})();
+
+(function () {
+ const ns: number[][] = [];
+
+ for (var {} of ns) {
+ }
+
+ for (let {} of ns) {
+ }
+
+ for (const {} of ns) {
+ }
+
+ for (var [] of ns) {
+ }
+
+ for (let [] of ns) {
+ }
+
+ for (const [] of ns) {
+ }
+})();
\ No newline at end of file
diff --git a/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6.ts
new file mode 100644
index 00000000000..9f2a9905480
--- /dev/null
+++ b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6.ts
@@ -0,0 +1,50 @@
+// @target: es6
+
+(function () {
+ var a: any;
+
+ var {} = a;
+ let {} = a;
+ const {} = a;
+
+ var [] = a;
+ let [] = a;
+ const [] = a;
+
+ var {} = a, [] = a;
+ let {} = a, [] = a;
+ const {} = a, [] = a;
+
+ var { p1: {}, p2: [] } = a;
+ let { p1: {}, p2: [] } = a;
+ const { p1: {}, p2: [] } = a;
+
+ for (var {} = {}, {} = {}; false; void 0) {
+ }
+
+ function f({} = a, [] = a, { p: {} = a} = a) {
+ return ({} = a, [] = a, { p: {} = a } = a) => a;
+ }
+})();
+
+(function () {
+ const ns: number[][] = [];
+
+ for (var {} of ns) {
+ }
+
+ for (let {} of ns) {
+ }
+
+ for (const {} of ns) {
+ }
+
+ for (var [] of ns) {
+ }
+
+ for (let [] of ns) {
+ }
+
+ for (const [] of ns) {
+ }
+})();
\ No newline at end of file
diff --git a/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts
new file mode 100644
index 00000000000..34c05e1838f
--- /dev/null
+++ b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts
@@ -0,0 +1,12 @@
+// @target: es5
+// @declaration: true
+
+(function () {
+ var {};
+ let {};
+ const {};
+
+ var [];
+ let [];
+ const [];
+})();
\ No newline at end of file
diff --git a/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts
new file mode 100644
index 00000000000..3146fec4cb7
--- /dev/null
+++ b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts
@@ -0,0 +1,12 @@
+// @target: es6
+// @declaration: true
+
+(function () {
+ var {};
+ let {};
+ const {};
+
+ var [];
+ let [];
+ const [];
+})();
\ No newline at end of file
diff --git a/tests/cases/fourslash/genericTypeAliasIntersectionCompletions.ts b/tests/cases/fourslash/genericTypeAliasIntersectionCompletions.ts
new file mode 100644
index 00000000000..0b2646291da
--- /dev/null
+++ b/tests/cases/fourslash/genericTypeAliasIntersectionCompletions.ts
@@ -0,0 +1,33 @@
+///
+
+//// type MixinCtor = new () => A & B & { constructor: MixinCtor };
+//// function merge(a: { prototype: A }, b: { prototype: B }): MixinCtor {
+//// let merged = function() { }
+//// Object.assign(merged.prototype, a.prototype, b.prototype);
+//// return >merged;
+//// }
+////
+//// class TreeNode {
+//// value: any;
+//// }
+////
+//// abstract class LeftSideNode extends TreeNode {
+//// abstract right(): TreeNode;
+//// left(): TreeNode {
+//// return null;
+//// }
+//// }
+////
+//// abstract class RightSideNode extends TreeNode {
+//// abstract left(): TreeNode;
+//// right(): TreeNode {
+//// return null;
+//// };
+//// }
+////
+//// var obj = new (merge(LeftSideNode, RightSideNode))();
+//// obj./**/
+
+goTo.marker();
+verify.completionListContains("left");
+verify.completionListContains("right");
diff --git a/tests/cases/unittests/services/preProcessFile.ts b/tests/cases/unittests/services/preProcessFile.ts
index 982c45f0f2d..a3f8db5528f 100644
--- a/tests/cases/unittests/services/preProcessFile.ts
+++ b/tests/cases/unittests/services/preProcessFile.ts
@@ -173,6 +173,20 @@ describe('PreProcessFile:', function () {
isLibFile: false
})
});
+
+ it("Correctly handles export import declarations", function () {
+ test("export import a = require(\"m1\");",
+ true,
+ {
+ referencedFiles: [],
+ importedFiles: [
+ { fileName: "m1", pos: 26, end: 28 }
+ ],
+ ambientExternalModules: undefined,
+ isLibFile: false
+ })
+ });
+
});
});