diff --git a/lib/tsc.js b/lib/tsc.js index eccb3bbfc6051..1a32bce669257 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -67,7 +67,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook var ts; (function (ts) { ts.versionMajorMinor = "3.8"; - ts.version = ts.versionMajorMinor + ".2"; + ts.version = "3.8.3"; function tryGetNativeMap() { return typeof Map !== "undefined" && "entries" in Map.prototype ? Map : undefined; } @@ -4377,6 +4377,7 @@ var ts; Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_t_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), + Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", undefined, true), @@ -4998,7 +4999,7 @@ var ts; File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: diag(6059, ts.DiagnosticCategory.Error, "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files."), Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: diag(6060, ts.DiagnosticCategory.Message, "Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", "Specify the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)."), NEWLINE: diag(6061, ts.DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"), - Option_0_can_only_be_specified_in_tsconfig_json_file: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_6064", "Option '{0}' can only be specified in 'tsconfig.json' file."), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line_6064", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'null' on command line."), Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."), Enables_experimental_support_for_emitting_type_metadata_for_decorators: diag(6066, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", "Enables experimental support for emitting type metadata for decorators."), Enables_experimental_support_for_ES7_async_functions: diag(6068, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_async_functions_6068", "Enables experimental support for ES7 async functions."), @@ -5159,6 +5160,7 @@ var ts; Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -14579,6 +14581,10 @@ var ts; || !isExpressionNode(useSite); } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; + function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { + return typeOnlyDeclaration.kind === 263; + } + ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { while (node.kind === 75 || node.kind === 194) { node = node.parent; @@ -21913,46 +21919,73 @@ var ts; parseStrings(args); } } + ts.parseCommandLineWorker = parseCommandLineWorker; function parseOptionValue(args, i, diagnostics, opt, options, errors) { if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); + var optValue = args[i]; + if (optValue === "null") { + options[opt.name] = undefined; + i++; + } + else if (opt.type === "boolean") { + if (optValue === "false") { + options[opt.name] = false; + i++; + } + else { + if (optValue === "true") + i++; + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line, opt.name)); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line, opt.name)); + if (optValue && !ts.startsWith(optValue, "-")) + i++; + } } else { if (!args[i] && opt.type !== "boolean") { errors.push(ts.createCompilerDiagnostic(diagnostics.optionTypeMismatchDiagnostic, opt.name, getCompilerOptionValueTypeString(opt))); } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - var optValue = args[i]; - options[opt.name] = optValue !== "false"; - if (optValue === "false" || optValue === "true") { + if (args[i] !== "null") { + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); i++; - } - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { + break; + case "boolean": + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + if (optValue === "false" || optValue === "true") { + i++; + } + break; + case "string": + options[opt.name] = args[i] || ""; i++; - } - break; - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; + } + break; + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; + } + } + else { + options[opt.name] = undefined; + i++; } } return i; } - var compilerOptionsDidYouMeanDiagnostics = { + ts.compilerOptionsDidYouMeanDiagnostics = { getOptionsNameMap: getOptionsNameMap, optionDeclarations: ts.optionDeclarations, unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0, @@ -21960,7 +21993,7 @@ var ts; optionTypeMismatchDiagnostic: ts.Diagnostics.Compiler_option_0_expects_an_argument }; function parseCommandLine(commandLine, readFile) { - return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile); + return parseCommandLineWorker(ts.compilerOptionsDidYouMeanDiagnostics, commandLine, readFile); } ts.parseCommandLine = parseCommandLine; function getOptionFromName(optionName, allowShort) { @@ -22113,7 +22146,7 @@ var ts; name: "compilerOptions", type: "object", elementOptions: getCommandLineCompilerOptionsMap(), - extraKeyDiagnostics: compilerOptionsDidYouMeanDiagnostics, + extraKeyDiagnostics: ts.compilerOptionsDidYouMeanDiagnostics, }, { name: "watchOptions", @@ -22540,7 +22573,7 @@ var ts; } ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths; function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) { - if (option) { + if (option && !isNullOrUndefined(value)) { if (option.type === "list") { var values = value; if (option.element.isFilePath && values.length) { @@ -22923,7 +22956,7 @@ var ts; } function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = getDefaultCompilerOptions(configFileName); - convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, compilerOptionsDidYouMeanDiagnostics, errors); + convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, ts.compilerOptionsDidYouMeanDiagnostics, errors); if (configFileName) { options.configFilePath = ts.normalizeSlashes(configFileName); } @@ -25952,7 +25985,9 @@ var ts; container = declName.parent.expression.name; break; case 5: - container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file + : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name + : declName.parent.expression; break; case 0: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); @@ -29207,10 +29242,11 @@ var ts; if (!ts.isValidTypeOnlyAliasUseSite(useSite)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 263 + var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); + var message = isExport ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; - var relatedMessage = typeOnlyDeclaration.kind === 263 + var relatedMessage = isExport ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -29482,10 +29518,11 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var message = typeOnlyDeclaration.kind === 263 + var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); + var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; - var relatedMessage = typeOnlyDeclaration.kind === 263 + var relatedMessage = isExport ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here; var name = ts.unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText); @@ -32536,7 +32573,7 @@ var ts; && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = modifierFlags | (isStatic ? 32 : 0); + var flag = (modifierFlags & ~256) | (isStatic ? 32 : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); if (p.flags & 98304 && useAccessors) { @@ -39866,7 +39903,7 @@ var ts; checkTypes = reducedTarget.flags & 1048576 ? reducedTarget.types : [reducedTarget]; } var _loop_11 = function (prop) { - if (shouldCheckAsExcessProperty(prop, source.symbol)) { + if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { var errorTarget = filterType(reducedTarget, isExcessPropertyCheckTarget); @@ -40615,6 +40652,7 @@ var ts; if (unmatchedProperty.valueDeclaration && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) + && source.symbol && source.symbol.flags & 32) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); @@ -53922,6 +53960,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } + checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { if (ts.isNamedExports(node.exportClause)) { @@ -53948,6 +53987,14 @@ var ts; } } } + function checkGrammarExportDeclaration(node) { + var _a; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 261; + if (isTypeOnlyExportStar) { + grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); + } + return !isTypeOnlyExportStar; + } function checkGrammarModuleElementContext(node, errorMessage) { var isInAppropriateContext = node.parent.kind === 290 || node.parent.kind === 250 || node.parent.kind === 249; if (!isInAppropriateContext) { diff --git a/lib/tsserver.js b/lib/tsserver.js index 6118a10ac29bd..d1132f3ad4d07 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -94,7 +94,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "3.8"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".2"; + ts.version = "3.8.3"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -6824,6 +6824,7 @@ var ts; Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_t_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), + Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -7445,7 +7446,7 @@ var ts; File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: diag(6059, ts.DiagnosticCategory.Error, "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files."), Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: diag(6060, ts.DiagnosticCategory.Message, "Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", "Specify the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)."), NEWLINE: diag(6061, ts.DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"), - Option_0_can_only_be_specified_in_tsconfig_json_file: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_6064", "Option '{0}' can only be specified in 'tsconfig.json' file."), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line_6064", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'null' on command line."), Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."), Enables_experimental_support_for_emitting_type_metadata_for_decorators: diag(6066, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", "Enables experimental support for emitting type metadata for decorators."), Enables_experimental_support_for_ES7_async_functions: diag(6068, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_async_functions_6068", "Enables experimental support for ES7 async functions."), @@ -7606,6 +7607,7 @@ var ts; Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -18216,6 +18218,10 @@ var ts; || !isExpressionNode(useSite); } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; + function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { + return typeOnlyDeclaration.kind === 263 /* ExportSpecifier */; + } + ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { while (node.kind === 75 /* Identifier */ || node.kind === 194 /* PropertyAccessExpression */) { node = node.parent; @@ -26888,6 +26894,7 @@ var ts; createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption); } + /*@internal*/ function parseCommandLineWorker(diagnostics, commandLine, readFile) { var options = {}; var watchOptions; @@ -26964,50 +26971,78 @@ var ts; parseStrings(args); } } + ts.parseCommandLineWorker = parseCommandLineWorker; function parseOptionValue(args, i, diagnostics, opt, options, errors) { if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); + var optValue = args[i]; + if (optValue === "null") { + options[opt.name] = undefined; + i++; + } + else if (opt.type === "boolean") { + if (optValue === "false") { + options[opt.name] = false; + i++; + } + else { + if (optValue === "true") + i++; + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line, opt.name)); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line, opt.name)); + if (optValue && !ts.startsWith(optValue, "-")) + i++; + } } else { // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). if (!args[i] && opt.type !== "boolean") { errors.push(ts.createCompilerDiagnostic(diagnostics.optionTypeMismatchDiagnostic, opt.name, getCompilerOptionValueTypeString(opt))); } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - // boolean flag has optional value true, false, others - var optValue = args[i]; - options[opt.name] = optValue !== "false"; - // consume next argument as boolean flag value - if (optValue === "false" || optValue === "true") { + if (args[i] !== "null") { + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); i++; - } - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { + break; + case "boolean": + // boolean flag has optional value true, false, others + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + // consume next argument as boolean flag value + if (optValue === "false" || optValue === "true") { + i++; + } + break; + case "string": + options[opt.name] = args[i] || ""; i++; - } - break; - // If not a primitive, the possible types are specified in what is effectively a map of options. - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; + } + break; + // If not a primitive, the possible types are specified in what is effectively a map of options. + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; + } + } + else { + options[opt.name] = undefined; + i++; } } return i; } - var compilerOptionsDidYouMeanDiagnostics = { + /*@internal*/ + ts.compilerOptionsDidYouMeanDiagnostics = { getOptionsNameMap: getOptionsNameMap, optionDeclarations: ts.optionDeclarations, unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0, @@ -27015,7 +27050,7 @@ var ts; optionTypeMismatchDiagnostic: ts.Diagnostics.Compiler_option_0_expects_an_argument }; function parseCommandLine(commandLine, readFile) { - return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile); + return parseCommandLineWorker(ts.compilerOptionsDidYouMeanDiagnostics, commandLine, readFile); } ts.parseCommandLine = parseCommandLine; /** @internal */ @@ -27192,7 +27227,7 @@ var ts; name: "compilerOptions", type: "object", elementOptions: getCommandLineCompilerOptionsMap(), - extraKeyDiagnostics: compilerOptionsDidYouMeanDiagnostics, + extraKeyDiagnostics: ts.compilerOptionsDidYouMeanDiagnostics, }, { name: "watchOptions", @@ -27670,7 +27705,7 @@ var ts; } ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths; function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) { - if (option) { + if (option && !isNullOrUndefined(value)) { if (option.type === "list") { var values = value; if (option.element.isFilePath && values.length) { @@ -28091,7 +28126,7 @@ var ts; } function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = getDefaultCompilerOptions(configFileName); - convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, compilerOptionsDidYouMeanDiagnostics, errors); + convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, ts.compilerOptionsDidYouMeanDiagnostics, errors); if (configFileName) { options.configFilePath = ts.normalizeSlashes(configFileName); } @@ -31732,7 +31767,9 @@ var ts; container = declName.parent.expression.name; break; case 5 /* Property */: - container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file + : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name + : declName.parent.expression; break; case 0 /* None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); @@ -35688,10 +35725,11 @@ var ts; if (!ts.isValidTypeOnlyAliasUseSite(useSite)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); + var message = isExport ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; - var relatedMessage = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var relatedMessage = isExport ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -35993,10 +36031,11 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var message = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); + var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; - var relatedMessage = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var relatedMessage = isExport ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here; // Non-null assertion is safe because the optionality comes from ImportClause, @@ -39523,7 +39562,7 @@ var ts; && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = modifierFlags | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); if (p.flags & 98304 /* Accessor */ && useAccessors) { @@ -47855,7 +47894,7 @@ var ts; checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; } var _loop_11 = function (prop) { - if (shouldCheckAsExcessProperty(prop, source.symbol)) { + if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -48749,6 +48788,7 @@ var ts; if (unmatchedProperty.valueDeclaration && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) + && source.symbol && source.symbol.flags & 32 /* Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); @@ -64413,6 +64453,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } + checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { // export { x, y } @@ -64442,6 +64483,14 @@ var ts; } } } + function checkGrammarExportDeclaration(node) { + var _a; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 261 /* NamedExports */; + if (isTypeOnlyExportStar) { + grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); + } + return !isTypeOnlyExportStar; + } function checkGrammarModuleElementContext(node, errorMessage) { var isInAppropriateContext = node.parent.kind === 290 /* SourceFile */ || node.parent.kind === 250 /* ModuleBlock */ || node.parent.kind === 249 /* ModuleDeclaration */; if (!isInAppropriateContext) { @@ -117314,7 +117363,8 @@ var ts; function addNodeOutliningSpans(sourceFile, cancellationToken, out) { var depthRemaining = 40; var current = 0; - var statements = sourceFile.statements; + // Includes the EOF Token so that comments which aren't attached to statements are included + var statements = __spreadArrays(sourceFile.statements, [sourceFile.endOfFileToken]); var n = statements.length; while (current < n) { while (current < n && !ts.isAnyImportSyntax(statements[current])) { @@ -117338,7 +117388,7 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n)) { + if (ts.isDeclaration(n) || n.kind === 1 /* EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } if (isFunctionExpressionAssignedToVariable(n)) { @@ -142650,7 +142700,7 @@ var ts; this.openFilesWithNonRootedDiskPath.set(this.toCanonicalFileName(fileName), info); } } - if (openedByClient && !info.isScriptOpen()) { + if (openedByClient) { // Opening closed script info // either it was created just now, or was part of projects but was closed this.stopWatchingScriptInfo(info); @@ -142659,9 +142709,6 @@ var ts; info.registerFileUpdate(); } } - else { - ts.Debug.assert(fileContent === undefined); - } return info; }; /** @@ -143278,8 +143325,9 @@ var ts; if (!project.languageServiceEnabled) { return; } - var info = { checkJs: !!project.getSourceFile(scriptInfo.path).checkJsDirective }; - this.eventHandler({ eventName: server.OpenFileInfoTelemetryEvent, data: { info: info } }); + var sourceFile = project.getSourceFile(scriptInfo.path); + var checkJs = !!sourceFile && !!sourceFile.checkJsDirective; + this.eventHandler({ eventName: server.OpenFileInfoTelemetryEvent, data: { info: { checkJs: checkJs } } }); }; ProjectService.prototype.closeClientFile = function (uncheckedFileName, skipAssignOrphanScriptInfosToInferredProject) { var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); @@ -143318,10 +143366,8 @@ var ts; if (iterResult.done) break; var file = iterResult.value; - var scriptInfo = this.getScriptInfo(file.fileName); - ts.Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen(), "Script should not exist and not be open already"); // Create script infos so we have the new content for all the open files before we do any updates to projects - var info = this.getOrCreateOpenScriptInfo(scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName), file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent, file.projectRootPath ? server.toNormalizedPath(file.projectRootPath) : undefined); + var info = this.getOrCreateOpenScriptInfo(server.toNormalizedPath(file.fileName), file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent, file.projectRootPath ? server.toNormalizedPath(file.projectRootPath) : undefined); (openScriptInfos || (openScriptInfos = [])).push(info); } } diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index fce7c60c366ba..871c3b8680e3c 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -244,7 +244,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "3.8"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".2"; + ts.version = "3.8.3"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -6974,6 +6974,7 @@ var ts; Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_t_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), + Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -7595,7 +7596,7 @@ var ts; File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: diag(6059, ts.DiagnosticCategory.Error, "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files."), Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: diag(6060, ts.DiagnosticCategory.Message, "Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", "Specify the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)."), NEWLINE: diag(6061, ts.DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"), - Option_0_can_only_be_specified_in_tsconfig_json_file: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_6064", "Option '{0}' can only be specified in 'tsconfig.json' file."), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line_6064", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'null' on command line."), Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."), Enables_experimental_support_for_emitting_type_metadata_for_decorators: diag(6066, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", "Enables experimental support for emitting type metadata for decorators."), Enables_experimental_support_for_ES7_async_functions: diag(6068, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_async_functions_6068", "Enables experimental support for ES7 async functions."), @@ -7756,6 +7757,7 @@ var ts; Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -18366,6 +18368,10 @@ var ts; || !isExpressionNode(useSite); } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; + function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { + return typeOnlyDeclaration.kind === 263 /* ExportSpecifier */; + } + ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { while (node.kind === 75 /* Identifier */ || node.kind === 194 /* PropertyAccessExpression */) { node = node.parent; @@ -27038,6 +27044,7 @@ var ts; createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption); } + /*@internal*/ function parseCommandLineWorker(diagnostics, commandLine, readFile) { var options = {}; var watchOptions; @@ -27114,50 +27121,78 @@ var ts; parseStrings(args); } } + ts.parseCommandLineWorker = parseCommandLineWorker; function parseOptionValue(args, i, diagnostics, opt, options, errors) { if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); + var optValue = args[i]; + if (optValue === "null") { + options[opt.name] = undefined; + i++; + } + else if (opt.type === "boolean") { + if (optValue === "false") { + options[opt.name] = false; + i++; + } + else { + if (optValue === "true") + i++; + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line, opt.name)); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line, opt.name)); + if (optValue && !ts.startsWith(optValue, "-")) + i++; + } } else { // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). if (!args[i] && opt.type !== "boolean") { errors.push(ts.createCompilerDiagnostic(diagnostics.optionTypeMismatchDiagnostic, opt.name, getCompilerOptionValueTypeString(opt))); } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - // boolean flag has optional value true, false, others - var optValue = args[i]; - options[opt.name] = optValue !== "false"; - // consume next argument as boolean flag value - if (optValue === "false" || optValue === "true") { + if (args[i] !== "null") { + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); i++; - } - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { + break; + case "boolean": + // boolean flag has optional value true, false, others + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + // consume next argument as boolean flag value + if (optValue === "false" || optValue === "true") { + i++; + } + break; + case "string": + options[opt.name] = args[i] || ""; i++; - } - break; - // If not a primitive, the possible types are specified in what is effectively a map of options. - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; + } + break; + // If not a primitive, the possible types are specified in what is effectively a map of options. + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; + } + } + else { + options[opt.name] = undefined; + i++; } } return i; } - var compilerOptionsDidYouMeanDiagnostics = { + /*@internal*/ + ts.compilerOptionsDidYouMeanDiagnostics = { getOptionsNameMap: getOptionsNameMap, optionDeclarations: ts.optionDeclarations, unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0, @@ -27165,7 +27200,7 @@ var ts; optionTypeMismatchDiagnostic: ts.Diagnostics.Compiler_option_0_expects_an_argument }; function parseCommandLine(commandLine, readFile) { - return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile); + return parseCommandLineWorker(ts.compilerOptionsDidYouMeanDiagnostics, commandLine, readFile); } ts.parseCommandLine = parseCommandLine; /** @internal */ @@ -27342,7 +27377,7 @@ var ts; name: "compilerOptions", type: "object", elementOptions: getCommandLineCompilerOptionsMap(), - extraKeyDiagnostics: compilerOptionsDidYouMeanDiagnostics, + extraKeyDiagnostics: ts.compilerOptionsDidYouMeanDiagnostics, }, { name: "watchOptions", @@ -27820,7 +27855,7 @@ var ts; } ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths; function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) { - if (option) { + if (option && !isNullOrUndefined(value)) { if (option.type === "list") { var values = value; if (option.element.isFilePath && values.length) { @@ -28241,7 +28276,7 @@ var ts; } function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = getDefaultCompilerOptions(configFileName); - convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, compilerOptionsDidYouMeanDiagnostics, errors); + convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, ts.compilerOptionsDidYouMeanDiagnostics, errors); if (configFileName) { options.configFilePath = ts.normalizeSlashes(configFileName); } @@ -31882,7 +31917,9 @@ var ts; container = declName.parent.expression.name; break; case 5 /* Property */: - container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file + : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name + : declName.parent.expression; break; case 0 /* None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); @@ -35838,10 +35875,11 @@ var ts; if (!ts.isValidTypeOnlyAliasUseSite(useSite)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); + var message = isExport ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; - var relatedMessage = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var relatedMessage = isExport ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -36143,10 +36181,11 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var message = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); + var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; - var relatedMessage = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var relatedMessage = isExport ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here; // Non-null assertion is safe because the optionality comes from ImportClause, @@ -39673,7 +39712,7 @@ var ts; && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = modifierFlags | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); if (p.flags & 98304 /* Accessor */ && useAccessors) { @@ -48005,7 +48044,7 @@ var ts; checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; } var _loop_11 = function (prop) { - if (shouldCheckAsExcessProperty(prop, source.symbol)) { + if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -48899,6 +48938,7 @@ var ts; if (unmatchedProperty.valueDeclaration && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) + && source.symbol && source.symbol.flags & 32 /* Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); @@ -64563,6 +64603,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } + checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { // export { x, y } @@ -64592,6 +64633,14 @@ var ts; } } } + function checkGrammarExportDeclaration(node) { + var _a; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 261 /* NamedExports */; + if (isTypeOnlyExportStar) { + grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); + } + return !isTypeOnlyExportStar; + } function checkGrammarModuleElementContext(node, errorMessage) { var isInAppropriateContext = node.parent.kind === 290 /* SourceFile */ || node.parent.kind === 250 /* ModuleBlock */ || node.parent.kind === 249 /* ModuleDeclaration */; if (!isInAppropriateContext) { @@ -117837,7 +117886,8 @@ var ts; function addNodeOutliningSpans(sourceFile, cancellationToken, out) { var depthRemaining = 40; var current = 0; - var statements = sourceFile.statements; + // Includes the EOF Token so that comments which aren't attached to statements are included + var statements = __spreadArrays(sourceFile.statements, [sourceFile.endOfFileToken]); var n = statements.length; while (current < n) { while (current < n && !ts.isAnyImportSyntax(statements[current])) { @@ -117861,7 +117911,7 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n)) { + if (ts.isDeclaration(n) || n.kind === 1 /* EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } if (isFunctionExpressionAssignedToVariable(n)) { @@ -142800,7 +142850,7 @@ var ts; this.openFilesWithNonRootedDiskPath.set(this.toCanonicalFileName(fileName), info); } } - if (openedByClient && !info.isScriptOpen()) { + if (openedByClient) { // Opening closed script info // either it was created just now, or was part of projects but was closed this.stopWatchingScriptInfo(info); @@ -142809,9 +142859,6 @@ var ts; info.registerFileUpdate(); } } - else { - ts.Debug.assert(fileContent === undefined); - } return info; }; /** @@ -143428,8 +143475,9 @@ var ts; if (!project.languageServiceEnabled) { return; } - var info = { checkJs: !!project.getSourceFile(scriptInfo.path).checkJsDirective }; - this.eventHandler({ eventName: server.OpenFileInfoTelemetryEvent, data: { info: info } }); + var sourceFile = project.getSourceFile(scriptInfo.path); + var checkJs = !!sourceFile && !!sourceFile.checkJsDirective; + this.eventHandler({ eventName: server.OpenFileInfoTelemetryEvent, data: { info: { checkJs: checkJs } } }); }; ProjectService.prototype.closeClientFile = function (uncheckedFileName, skipAssignOrphanScriptInfosToInferredProject) { var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); @@ -143468,10 +143516,8 @@ var ts; if (iterResult.done) break; var file = iterResult.value; - var scriptInfo = this.getScriptInfo(file.fileName); - ts.Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen(), "Script should not exist and not be open already"); // Create script infos so we have the new content for all the open files before we do any updates to projects - var info = this.getOrCreateOpenScriptInfo(scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName), file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent, file.projectRootPath ? server.toNormalizedPath(file.projectRootPath) : undefined); + var info = this.getOrCreateOpenScriptInfo(server.toNormalizedPath(file.fileName), file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent, file.projectRootPath ? server.toNormalizedPath(file.projectRootPath) : undefined); (openScriptInfos || (openScriptInfos = [])).push(info); } } diff --git a/lib/typescript.js b/lib/typescript.js index 38f13a0a68561..583f65b37a622 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -244,7 +244,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "3.8"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".2"; + ts.version = "3.8.3"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -6974,6 +6974,7 @@ var ts; Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_t_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), + Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -7595,7 +7596,7 @@ var ts; File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: diag(6059, ts.DiagnosticCategory.Error, "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files."), Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: diag(6060, ts.DiagnosticCategory.Message, "Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", "Specify the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)."), NEWLINE: diag(6061, ts.DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"), - Option_0_can_only_be_specified_in_tsconfig_json_file: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_6064", "Option '{0}' can only be specified in 'tsconfig.json' file."), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line_6064", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'null' on command line."), Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."), Enables_experimental_support_for_emitting_type_metadata_for_decorators: diag(6066, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", "Enables experimental support for emitting type metadata for decorators."), Enables_experimental_support_for_ES7_async_functions: diag(6068, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_async_functions_6068", "Enables experimental support for ES7 async functions."), @@ -7756,6 +7757,7 @@ var ts; Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -18366,6 +18368,10 @@ var ts; || !isExpressionNode(useSite); } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; + function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { + return typeOnlyDeclaration.kind === 263 /* ExportSpecifier */; + } + ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { while (node.kind === 75 /* Identifier */ || node.kind === 194 /* PropertyAccessExpression */) { node = node.parent; @@ -27038,6 +27044,7 @@ var ts; createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption); } + /*@internal*/ function parseCommandLineWorker(diagnostics, commandLine, readFile) { var options = {}; var watchOptions; @@ -27114,50 +27121,78 @@ var ts; parseStrings(args); } } + ts.parseCommandLineWorker = parseCommandLineWorker; function parseOptionValue(args, i, diagnostics, opt, options, errors) { if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); + var optValue = args[i]; + if (optValue === "null") { + options[opt.name] = undefined; + i++; + } + else if (opt.type === "boolean") { + if (optValue === "false") { + options[opt.name] = false; + i++; + } + else { + if (optValue === "true") + i++; + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line, opt.name)); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line, opt.name)); + if (optValue && !ts.startsWith(optValue, "-")) + i++; + } } else { // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). if (!args[i] && opt.type !== "boolean") { errors.push(ts.createCompilerDiagnostic(diagnostics.optionTypeMismatchDiagnostic, opt.name, getCompilerOptionValueTypeString(opt))); } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - // boolean flag has optional value true, false, others - var optValue = args[i]; - options[opt.name] = optValue !== "false"; - // consume next argument as boolean flag value - if (optValue === "false" || optValue === "true") { + if (args[i] !== "null") { + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); i++; - } - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { + break; + case "boolean": + // boolean flag has optional value true, false, others + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + // consume next argument as boolean flag value + if (optValue === "false" || optValue === "true") { + i++; + } + break; + case "string": + options[opt.name] = args[i] || ""; i++; - } - break; - // If not a primitive, the possible types are specified in what is effectively a map of options. - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; + } + break; + // If not a primitive, the possible types are specified in what is effectively a map of options. + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; + } + } + else { + options[opt.name] = undefined; + i++; } } return i; } - var compilerOptionsDidYouMeanDiagnostics = { + /*@internal*/ + ts.compilerOptionsDidYouMeanDiagnostics = { getOptionsNameMap: getOptionsNameMap, optionDeclarations: ts.optionDeclarations, unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0, @@ -27165,7 +27200,7 @@ var ts; optionTypeMismatchDiagnostic: ts.Diagnostics.Compiler_option_0_expects_an_argument }; function parseCommandLine(commandLine, readFile) { - return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile); + return parseCommandLineWorker(ts.compilerOptionsDidYouMeanDiagnostics, commandLine, readFile); } ts.parseCommandLine = parseCommandLine; /** @internal */ @@ -27342,7 +27377,7 @@ var ts; name: "compilerOptions", type: "object", elementOptions: getCommandLineCompilerOptionsMap(), - extraKeyDiagnostics: compilerOptionsDidYouMeanDiagnostics, + extraKeyDiagnostics: ts.compilerOptionsDidYouMeanDiagnostics, }, { name: "watchOptions", @@ -27820,7 +27855,7 @@ var ts; } ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths; function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) { - if (option) { + if (option && !isNullOrUndefined(value)) { if (option.type === "list") { var values = value; if (option.element.isFilePath && values.length) { @@ -28241,7 +28276,7 @@ var ts; } function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = getDefaultCompilerOptions(configFileName); - convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, compilerOptionsDidYouMeanDiagnostics, errors); + convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, ts.compilerOptionsDidYouMeanDiagnostics, errors); if (configFileName) { options.configFilePath = ts.normalizeSlashes(configFileName); } @@ -31882,7 +31917,9 @@ var ts; container = declName.parent.expression.name; break; case 5 /* Property */: - container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file + : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name + : declName.parent.expression; break; case 0 /* None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); @@ -35838,10 +35875,11 @@ var ts; if (!ts.isValidTypeOnlyAliasUseSite(useSite)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); + var message = isExport ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; - var relatedMessage = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var relatedMessage = isExport ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -36143,10 +36181,11 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var message = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); + var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; - var relatedMessage = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var relatedMessage = isExport ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here; // Non-null assertion is safe because the optionality comes from ImportClause, @@ -39673,7 +39712,7 @@ var ts; && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = modifierFlags | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); if (p.flags & 98304 /* Accessor */ && useAccessors) { @@ -48005,7 +48044,7 @@ var ts; checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; } var _loop_11 = function (prop) { - if (shouldCheckAsExcessProperty(prop, source.symbol)) { + if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -48899,6 +48938,7 @@ var ts; if (unmatchedProperty.valueDeclaration && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) + && source.symbol && source.symbol.flags & 32 /* Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); @@ -64563,6 +64603,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } + checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { // export { x, y } @@ -64592,6 +64633,14 @@ var ts; } } } + function checkGrammarExportDeclaration(node) { + var _a; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 261 /* NamedExports */; + if (isTypeOnlyExportStar) { + grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); + } + return !isTypeOnlyExportStar; + } function checkGrammarModuleElementContext(node, errorMessage) { var isInAppropriateContext = node.parent.kind === 290 /* SourceFile */ || node.parent.kind === 250 /* ModuleBlock */ || node.parent.kind === 249 /* ModuleDeclaration */; if (!isInAppropriateContext) { @@ -117837,7 +117886,8 @@ var ts; function addNodeOutliningSpans(sourceFile, cancellationToken, out) { var depthRemaining = 40; var current = 0; - var statements = sourceFile.statements; + // Includes the EOF Token so that comments which aren't attached to statements are included + var statements = __spreadArrays(sourceFile.statements, [sourceFile.endOfFileToken]); var n = statements.length; while (current < n) { while (current < n && !ts.isAnyImportSyntax(statements[current])) { @@ -117861,7 +117911,7 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n)) { + if (ts.isDeclaration(n) || n.kind === 1 /* EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } if (isFunctionExpressionAssignedToVariable(n)) { diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 49e41d363d08a..3fcdde7178db4 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -244,7 +244,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "3.8"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".2"; + ts.version = "3.8.3"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -6974,6 +6974,7 @@ var ts; Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_t_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), + Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -7595,7 +7596,7 @@ var ts; File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: diag(6059, ts.DiagnosticCategory.Error, "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files."), Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: diag(6060, ts.DiagnosticCategory.Message, "Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", "Specify the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)."), NEWLINE: diag(6061, ts.DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"), - Option_0_can_only_be_specified_in_tsconfig_json_file: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_6064", "Option '{0}' can only be specified in 'tsconfig.json' file."), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line_6064", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'null' on command line."), Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."), Enables_experimental_support_for_emitting_type_metadata_for_decorators: diag(6066, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", "Enables experimental support for emitting type metadata for decorators."), Enables_experimental_support_for_ES7_async_functions: diag(6068, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_async_functions_6068", "Enables experimental support for ES7 async functions."), @@ -7756,6 +7757,7 @@ var ts; Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -18366,6 +18368,10 @@ var ts; || !isExpressionNode(useSite); } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; + function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { + return typeOnlyDeclaration.kind === 263 /* ExportSpecifier */; + } + ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { while (node.kind === 75 /* Identifier */ || node.kind === 194 /* PropertyAccessExpression */) { node = node.parent; @@ -27038,6 +27044,7 @@ var ts; createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption); } + /*@internal*/ function parseCommandLineWorker(diagnostics, commandLine, readFile) { var options = {}; var watchOptions; @@ -27114,50 +27121,78 @@ var ts; parseStrings(args); } } + ts.parseCommandLineWorker = parseCommandLineWorker; function parseOptionValue(args, i, diagnostics, opt, options, errors) { if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); + var optValue = args[i]; + if (optValue === "null") { + options[opt.name] = undefined; + i++; + } + else if (opt.type === "boolean") { + if (optValue === "false") { + options[opt.name] = false; + i++; + } + else { + if (optValue === "true") + i++; + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line, opt.name)); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line, opt.name)); + if (optValue && !ts.startsWith(optValue, "-")) + i++; + } } else { // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). if (!args[i] && opt.type !== "boolean") { errors.push(ts.createCompilerDiagnostic(diagnostics.optionTypeMismatchDiagnostic, opt.name, getCompilerOptionValueTypeString(opt))); } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - // boolean flag has optional value true, false, others - var optValue = args[i]; - options[opt.name] = optValue !== "false"; - // consume next argument as boolean flag value - if (optValue === "false" || optValue === "true") { + if (args[i] !== "null") { + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); i++; - } - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { + break; + case "boolean": + // boolean flag has optional value true, false, others + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + // consume next argument as boolean flag value + if (optValue === "false" || optValue === "true") { + i++; + } + break; + case "string": + options[opt.name] = args[i] || ""; i++; - } - break; - // If not a primitive, the possible types are specified in what is effectively a map of options. - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; + } + break; + // If not a primitive, the possible types are specified in what is effectively a map of options. + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; + } + } + else { + options[opt.name] = undefined; + i++; } } return i; } - var compilerOptionsDidYouMeanDiagnostics = { + /*@internal*/ + ts.compilerOptionsDidYouMeanDiagnostics = { getOptionsNameMap: getOptionsNameMap, optionDeclarations: ts.optionDeclarations, unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0, @@ -27165,7 +27200,7 @@ var ts; optionTypeMismatchDiagnostic: ts.Diagnostics.Compiler_option_0_expects_an_argument }; function parseCommandLine(commandLine, readFile) { - return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile); + return parseCommandLineWorker(ts.compilerOptionsDidYouMeanDiagnostics, commandLine, readFile); } ts.parseCommandLine = parseCommandLine; /** @internal */ @@ -27342,7 +27377,7 @@ var ts; name: "compilerOptions", type: "object", elementOptions: getCommandLineCompilerOptionsMap(), - extraKeyDiagnostics: compilerOptionsDidYouMeanDiagnostics, + extraKeyDiagnostics: ts.compilerOptionsDidYouMeanDiagnostics, }, { name: "watchOptions", @@ -27820,7 +27855,7 @@ var ts; } ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths; function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) { - if (option) { + if (option && !isNullOrUndefined(value)) { if (option.type === "list") { var values = value; if (option.element.isFilePath && values.length) { @@ -28241,7 +28276,7 @@ var ts; } function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = getDefaultCompilerOptions(configFileName); - convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, compilerOptionsDidYouMeanDiagnostics, errors); + convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, ts.compilerOptionsDidYouMeanDiagnostics, errors); if (configFileName) { options.configFilePath = ts.normalizeSlashes(configFileName); } @@ -31882,7 +31917,9 @@ var ts; container = declName.parent.expression.name; break; case 5 /* Property */: - container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file + : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name + : declName.parent.expression; break; case 0 /* None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); @@ -35838,10 +35875,11 @@ var ts; if (!ts.isValidTypeOnlyAliasUseSite(useSite)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); + var message = isExport ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; - var relatedMessage = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var relatedMessage = isExport ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -36143,10 +36181,11 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var message = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); + var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; - var relatedMessage = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var relatedMessage = isExport ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here; // Non-null assertion is safe because the optionality comes from ImportClause, @@ -39673,7 +39712,7 @@ var ts; && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = modifierFlags | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); if (p.flags & 98304 /* Accessor */ && useAccessors) { @@ -48005,7 +48044,7 @@ var ts; checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; } var _loop_11 = function (prop) { - if (shouldCheckAsExcessProperty(prop, source.symbol)) { + if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -48899,6 +48938,7 @@ var ts; if (unmatchedProperty.valueDeclaration && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) + && source.symbol && source.symbol.flags & 32 /* Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); @@ -64563,6 +64603,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } + checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { // export { x, y } @@ -64592,6 +64633,14 @@ var ts; } } } + function checkGrammarExportDeclaration(node) { + var _a; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 261 /* NamedExports */; + if (isTypeOnlyExportStar) { + grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); + } + return !isTypeOnlyExportStar; + } function checkGrammarModuleElementContext(node, errorMessage) { var isInAppropriateContext = node.parent.kind === 290 /* SourceFile */ || node.parent.kind === 250 /* ModuleBlock */ || node.parent.kind === 249 /* ModuleDeclaration */; if (!isInAppropriateContext) { @@ -117837,7 +117886,8 @@ var ts; function addNodeOutliningSpans(sourceFile, cancellationToken, out) { var depthRemaining = 40; var current = 0; - var statements = sourceFile.statements; + // Includes the EOF Token so that comments which aren't attached to statements are included + var statements = __spreadArrays(sourceFile.statements, [sourceFile.endOfFileToken]); var n = statements.length; while (current < n) { while (current < n && !ts.isAnyImportSyntax(statements[current])) { @@ -117861,7 +117911,7 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n)) { + if (ts.isDeclaration(n) || n.kind === 1 /* EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } if (isFunctionExpressionAssignedToVariable(n)) { diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index e651612854441..d5b5f4d5f9703 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -83,7 +83,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "3.8"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".2"; + ts.version = "3.8.3"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -6813,6 +6813,7 @@ var ts; Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_t_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), + Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -7434,7 +7435,7 @@ var ts; File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: diag(6059, ts.DiagnosticCategory.Error, "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files."), Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: diag(6060, ts.DiagnosticCategory.Message, "Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", "Specify the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)."), NEWLINE: diag(6061, ts.DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"), - Option_0_can_only_be_specified_in_tsconfig_json_file: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_6064", "Option '{0}' can only be specified in 'tsconfig.json' file."), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line_6064", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'null' on command line."), Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."), Enables_experimental_support_for_emitting_type_metadata_for_decorators: diag(6066, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", "Enables experimental support for emitting type metadata for decorators."), Enables_experimental_support_for_ES7_async_functions: diag(6068, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_async_functions_6068", "Enables experimental support for ES7 async functions."), @@ -7595,6 +7596,7 @@ var ts; Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -18205,6 +18207,10 @@ var ts; || !isExpressionNode(useSite); } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; + function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { + return typeOnlyDeclaration.kind === 263 /* ExportSpecifier */; + } + ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { while (node.kind === 75 /* Identifier */ || node.kind === 194 /* PropertyAccessExpression */) { node = node.parent; @@ -26877,6 +26883,7 @@ var ts; createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption); } + /*@internal*/ function parseCommandLineWorker(diagnostics, commandLine, readFile) { var options = {}; var watchOptions; @@ -26953,50 +26960,78 @@ var ts; parseStrings(args); } } + ts.parseCommandLineWorker = parseCommandLineWorker; function parseOptionValue(args, i, diagnostics, opt, options, errors) { if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); + var optValue = args[i]; + if (optValue === "null") { + options[opt.name] = undefined; + i++; + } + else if (opt.type === "boolean") { + if (optValue === "false") { + options[opt.name] = false; + i++; + } + else { + if (optValue === "true") + i++; + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line, opt.name)); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line, opt.name)); + if (optValue && !ts.startsWith(optValue, "-")) + i++; + } } else { // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). if (!args[i] && opt.type !== "boolean") { errors.push(ts.createCompilerDiagnostic(diagnostics.optionTypeMismatchDiagnostic, opt.name, getCompilerOptionValueTypeString(opt))); } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - // boolean flag has optional value true, false, others - var optValue = args[i]; - options[opt.name] = optValue !== "false"; - // consume next argument as boolean flag value - if (optValue === "false" || optValue === "true") { + if (args[i] !== "null") { + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); i++; - } - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { + break; + case "boolean": + // boolean flag has optional value true, false, others + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + // consume next argument as boolean flag value + if (optValue === "false" || optValue === "true") { + i++; + } + break; + case "string": + options[opt.name] = args[i] || ""; i++; - } - break; - // If not a primitive, the possible types are specified in what is effectively a map of options. - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; + } + break; + // If not a primitive, the possible types are specified in what is effectively a map of options. + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; + } + } + else { + options[opt.name] = undefined; + i++; } } return i; } - var compilerOptionsDidYouMeanDiagnostics = { + /*@internal*/ + ts.compilerOptionsDidYouMeanDiagnostics = { getOptionsNameMap: getOptionsNameMap, optionDeclarations: ts.optionDeclarations, unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0, @@ -27004,7 +27039,7 @@ var ts; optionTypeMismatchDiagnostic: ts.Diagnostics.Compiler_option_0_expects_an_argument }; function parseCommandLine(commandLine, readFile) { - return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile); + return parseCommandLineWorker(ts.compilerOptionsDidYouMeanDiagnostics, commandLine, readFile); } ts.parseCommandLine = parseCommandLine; /** @internal */ @@ -27181,7 +27216,7 @@ var ts; name: "compilerOptions", type: "object", elementOptions: getCommandLineCompilerOptionsMap(), - extraKeyDiagnostics: compilerOptionsDidYouMeanDiagnostics, + extraKeyDiagnostics: ts.compilerOptionsDidYouMeanDiagnostics, }, { name: "watchOptions", @@ -27659,7 +27694,7 @@ var ts; } ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths; function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) { - if (option) { + if (option && !isNullOrUndefined(value)) { if (option.type === "list") { var values = value; if (option.element.isFilePath && values.length) { @@ -28080,7 +28115,7 @@ var ts; } function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = getDefaultCompilerOptions(configFileName); - convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, compilerOptionsDidYouMeanDiagnostics, errors); + convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, ts.compilerOptionsDidYouMeanDiagnostics, errors); if (configFileName) { options.configFilePath = ts.normalizeSlashes(configFileName); } @@ -31721,7 +31756,9 @@ var ts; container = declName.parent.expression.name; break; case 5 /* Property */: - container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file + : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name + : declName.parent.expression; break; case 0 /* None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); @@ -35677,10 +35714,11 @@ var ts; if (!ts.isValidTypeOnlyAliasUseSite(useSite)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); + var message = isExport ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; - var relatedMessage = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var relatedMessage = isExport ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -35982,10 +36020,11 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var message = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); + var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; - var relatedMessage = typeOnlyDeclaration.kind === 263 /* ExportSpecifier */ + var relatedMessage = isExport ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here; // Non-null assertion is safe because the optionality comes from ImportClause, @@ -39512,7 +39551,7 @@ var ts; && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = modifierFlags | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); if (p.flags & 98304 /* Accessor */ && useAccessors) { @@ -47844,7 +47883,7 @@ var ts; checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; } var _loop_11 = function (prop) { - if (shouldCheckAsExcessProperty(prop, source.symbol)) { + if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -48738,6 +48777,7 @@ var ts; if (unmatchedProperty.valueDeclaration && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) + && source.symbol && source.symbol.flags & 32 /* Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); @@ -64402,6 +64442,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } + checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { // export { x, y } @@ -64431,6 +64472,14 @@ var ts; } } } + function checkGrammarExportDeclaration(node) { + var _a; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 261 /* NamedExports */; + if (isTypeOnlyExportStar) { + grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); + } + return !isTypeOnlyExportStar; + } function checkGrammarModuleElementContext(node, errorMessage) { var isInAppropriateContext = node.parent.kind === 290 /* SourceFile */ || node.parent.kind === 250 /* ModuleBlock */ || node.parent.kind === 249 /* ModuleDeclaration */; if (!isInAppropriateContext) { diff --git a/package.json b/package.json index bb5e8b568d400..2d200f040b5ae 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "3.8.2", + "version": "3.8.3", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index 2c64d3e1f022c..7230e4ec8f48a 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -3,7 +3,7 @@ namespace ts { // If changing the text in this section, be sure to test `configurePrerelease` too. export const versionMajorMinor = "3.8"; /** The version of the TypeScript compiler release */ - export const version = `${versionMajorMinor}.2`; + export const version = "3.8.3" as string; /** * Type of objects whose values are all of the same type.