typescript 4.7.1-rc → 4.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +88 -40
- package/lib/tsserver.js +160 -74
- package/lib/tsserverlibrary.d.ts +26 -0
- package/lib/tsserverlibrary.js +160 -74
- package/lib/typescript.d.ts +26 -0
- package/lib/typescript.js +160 -74
- package/lib/typescriptServices.d.ts +26 -0
- package/lib/typescriptServices.js +160 -74
- package/lib/typingsInstaller.js +108 -44
- package/package.json +1 -1
package/lib/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = "
|
|
92
|
+
ts.version = "4.7.4";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -8378,7 +8378,7 @@ var ts;
|
|
|
8378
8378
|
Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."),
|
|
8379
8379
|
Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"),
|
|
8380
8380
|
Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
|
|
8381
|
-
|
|
8381
|
+
resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`."),
|
|
8382
8382
|
resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."),
|
|
8383
8383
|
resolution_mode_can_only_be_set_for_type_only_imports: diag(1454, ts.DiagnosticCategory.Error, "resolution_mode_can_only_be_set_for_type_only_imports_1454", "`resolution-mode` can only be set for type-only imports."),
|
|
8384
8384
|
resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."),
|
|
@@ -8882,6 +8882,7 @@ var ts;
|
|
|
8882
8882
|
Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."),
|
|
8883
8883
|
Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."),
|
|
8884
8884
|
All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."),
|
|
8885
|
+
The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
8885
8886
|
Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
8886
8887
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
8887
8888
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -8989,7 +8990,7 @@ var ts;
|
|
|
8989
8990
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."),
|
|
8990
8991
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"),
|
|
8991
8992
|
Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
8992
|
-
|
|
8993
|
+
resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "'resolution-mode' assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
8993
8994
|
The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
|
|
8994
8995
|
Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
|
|
8995
8996
|
File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
|
|
@@ -16007,6 +16008,8 @@ var ts;
|
|
|
16007
16008
|
case 218 /* SyntaxKind.AwaitExpression */:
|
|
16008
16009
|
case 231 /* SyntaxKind.MetaProperty */:
|
|
16009
16010
|
return true;
|
|
16011
|
+
case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
16012
|
+
return !ts.isHeritageClause(node.parent);
|
|
16010
16013
|
case 161 /* SyntaxKind.QualifiedName */:
|
|
16011
16014
|
while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) {
|
|
16012
16015
|
node = node.parent;
|
|
@@ -16178,9 +16181,6 @@ var ts;
|
|
|
16178
16181
|
}
|
|
16179
16182
|
ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
|
|
16180
16183
|
function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
|
|
16181
|
-
if (node.kind === 203 /* SyntaxKind.BindingElement */) {
|
|
16182
|
-
node = node.parent.parent;
|
|
16183
|
-
}
|
|
16184
16184
|
return ts.isVariableDeclaration(node) &&
|
|
16185
16185
|
!!node.initializer &&
|
|
16186
16186
|
isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
|
|
@@ -20002,8 +20002,9 @@ var ts;
|
|
|
20002
20002
|
*/
|
|
20003
20003
|
function isFileForcedToBeModuleByFormat(file) {
|
|
20004
20004
|
// Excludes declaration files - they still require an explicit `export {}` or the like
|
|
20005
|
-
// for back compat purposes.
|
|
20006
|
-
|
|
20005
|
+
// for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
|
|
20006
|
+
// that aren't esm-mode (meaning not in a `type: module` scope).
|
|
20007
|
+
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20007
20008
|
}
|
|
20008
20009
|
function getSetExternalModuleIndicator(options) {
|
|
20009
20010
|
// TODO: Should this callback be cached?
|
|
@@ -20011,7 +20012,7 @@ var ts;
|
|
|
20011
20012
|
case ts.ModuleDetectionKind.Force:
|
|
20012
20013
|
// All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
|
|
20013
20014
|
return function (file) {
|
|
20014
|
-
file.externalModuleIndicator = !file.isDeclarationFile ||
|
|
20015
|
+
file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
|
|
20015
20016
|
};
|
|
20016
20017
|
case ts.ModuleDetectionKind.Legacy:
|
|
20017
20018
|
// Files are modules if they have imports, exports, or import.meta
|
|
@@ -20071,7 +20072,8 @@ var ts;
|
|
|
20071
20072
|
}
|
|
20072
20073
|
ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
|
|
20073
20074
|
function getEmitModuleDetectionKind(options) {
|
|
20074
|
-
return options.moduleDetection ||
|
|
20075
|
+
return options.moduleDetection ||
|
|
20076
|
+
(getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
|
|
20075
20077
|
}
|
|
20076
20078
|
ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
|
|
20077
20079
|
function hasJsonModuleEmitEnabled(options) {
|
|
@@ -29051,6 +29053,10 @@ var ts;
|
|
|
29051
29053
|
return node.kind === 267 /* SyntaxKind.ImportClause */;
|
|
29052
29054
|
}
|
|
29053
29055
|
ts.isImportClause = isImportClause;
|
|
29056
|
+
function isImportTypeAssertionContainer(node) {
|
|
29057
|
+
return node.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */;
|
|
29058
|
+
}
|
|
29059
|
+
ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer;
|
|
29054
29060
|
function isAssertClause(node) {
|
|
29055
29061
|
return node.kind === 293 /* SyntaxKind.AssertClause */;
|
|
29056
29062
|
}
|
|
@@ -35407,10 +35413,11 @@ var ts;
|
|
|
35407
35413
|
}
|
|
35408
35414
|
nextToken();
|
|
35409
35415
|
var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType);
|
|
35410
|
-
if (
|
|
35416
|
+
if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) {
|
|
35411
35417
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
35412
35418
|
return undefined;
|
|
35413
35419
|
}
|
|
35420
|
+
nextToken();
|
|
35414
35421
|
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
35415
35422
|
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
35416
35423
|
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
@@ -41995,7 +42002,7 @@ var ts;
|
|
|
41995
42002
|
}
|
|
41996
42003
|
if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
|
|
41997
42004
|
return {
|
|
41998
|
-
key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
|
|
42005
|
+
key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
|
|
41999
42006
|
flags: 1 /* WatchDirectoryFlags.Recursive */
|
|
42000
42007
|
};
|
|
42001
42008
|
}
|
|
@@ -43100,16 +43107,20 @@ var ts;
|
|
|
43100
43107
|
function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
43101
43108
|
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
43102
43109
|
}
|
|
43110
|
+
var jsOnlyExtensions = [Extensions.JavaScript];
|
|
43111
|
+
var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
|
43112
|
+
var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
|
|
43113
|
+
var tsconfigExtensions = [Extensions.TSConfig];
|
|
43103
43114
|
function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
43104
43115
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
43105
43116
|
// es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
|
|
43106
43117
|
var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
|
|
43107
|
-
|
|
43118
|
+
var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
|
|
43119
|
+
if (compilerOptions.resolveJsonModule) {
|
|
43120
|
+
extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
|
|
43121
|
+
}
|
|
43122
|
+
return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
|
|
43108
43123
|
}
|
|
43109
|
-
var jsOnlyExtensions = [Extensions.JavaScript];
|
|
43110
|
-
var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
|
43111
|
-
var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
|
|
43112
|
-
var tsconfigExtensions = [Extensions.TSConfig];
|
|
43113
43124
|
function tryResolveJSModuleWorker(moduleName, initialDir, host) {
|
|
43114
43125
|
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
43115
43126
|
}
|
|
@@ -43792,13 +43803,36 @@ var ts;
|
|
|
43792
43803
|
}
|
|
43793
43804
|
return toSearchResult(/*value*/ undefined);
|
|
43794
43805
|
}
|
|
43806
|
+
/**
|
|
43807
|
+
* From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
|
|
43808
|
+
* "longest" has some nuance as to what "longest" means in the presence of pattern trailers
|
|
43809
|
+
*/
|
|
43810
|
+
function comparePatternKeys(a, b) {
|
|
43811
|
+
var aPatternIndex = a.indexOf("*");
|
|
43812
|
+
var bPatternIndex = b.indexOf("*");
|
|
43813
|
+
var baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
|
|
43814
|
+
var baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
|
|
43815
|
+
if (baseLenA > baseLenB)
|
|
43816
|
+
return -1;
|
|
43817
|
+
if (baseLenB > baseLenA)
|
|
43818
|
+
return 1;
|
|
43819
|
+
if (aPatternIndex === -1)
|
|
43820
|
+
return 1;
|
|
43821
|
+
if (bPatternIndex === -1)
|
|
43822
|
+
return -1;
|
|
43823
|
+
if (a.length > b.length)
|
|
43824
|
+
return -1;
|
|
43825
|
+
if (b.length > a.length)
|
|
43826
|
+
return 1;
|
|
43827
|
+
return 0;
|
|
43828
|
+
}
|
|
43795
43829
|
function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
|
43796
43830
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
43797
43831
|
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
43798
43832
|
var target = lookupTable[moduleName];
|
|
43799
43833
|
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
|
|
43800
43834
|
}
|
|
43801
|
-
var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }),
|
|
43835
|
+
var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
|
|
43802
43836
|
for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
|
|
43803
43837
|
var potentialTarget = expandingKeys_1[_i];
|
|
43804
43838
|
if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
|
|
@@ -44117,8 +44151,8 @@ var ts;
|
|
|
44117
44151
|
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
|
|
44118
44152
|
loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
|
|
44119
44153
|
if (!pathAndExtension && packageInfo
|
|
44120
|
-
|
|
44121
|
-
&& packageInfo.packageJsonContent.
|
|
44154
|
+
// eslint-disable-next-line no-null/no-null
|
|
44155
|
+
&& (packageInfo.packageJsonContent.exports === undefined || packageInfo.packageJsonContent.exports === null)
|
|
44122
44156
|
&& state.features & NodeResolutionFeatures.EsmMode) {
|
|
44123
44157
|
// EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
|
|
44124
44158
|
// a default `index.js` entrypoint if no `main` or `exports` are present
|
|
@@ -46894,12 +46928,14 @@ var ts;
|
|
|
46894
46928
|
}
|
|
46895
46929
|
}
|
|
46896
46930
|
function setCommonJsModuleIndicator(node) {
|
|
46897
|
-
if (file.externalModuleIndicator) {
|
|
46931
|
+
if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
|
|
46898
46932
|
return false;
|
|
46899
46933
|
}
|
|
46900
46934
|
if (!file.commonJsModuleIndicator) {
|
|
46901
46935
|
file.commonJsModuleIndicator = node;
|
|
46902
|
-
|
|
46936
|
+
if (!file.externalModuleIndicator) {
|
|
46937
|
+
bindSourceFileAsExternalModule();
|
|
46938
|
+
}
|
|
46903
46939
|
}
|
|
46904
46940
|
return true;
|
|
46905
46941
|
}
|
|
@@ -47313,7 +47349,11 @@ var ts;
|
|
|
47313
47349
|
checkStrictModeEvalOrArguments(node, node.name);
|
|
47314
47350
|
}
|
|
47315
47351
|
if (!ts.isBindingPattern(node.name)) {
|
|
47316
|
-
|
|
47352
|
+
var possibleVariableDecl = node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node : node.parent.parent;
|
|
47353
|
+
if (ts.isInJSFile(node) &&
|
|
47354
|
+
ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
|
|
47355
|
+
!ts.getJSDocTypeTag(node) &&
|
|
47356
|
+
!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) {
|
|
47317
47357
|
declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
|
|
47318
47358
|
}
|
|
47319
47359
|
else if (ts.isBlockOrCatchScoped(node)) {
|
|
@@ -50140,7 +50180,8 @@ var ts;
|
|
|
50140
50180
|
&& isAliasableOrJsExpression(node.parent.right)
|
|
50141
50181
|
|| node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */
|
|
50142
50182
|
|| node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
|
|
50143
|
-
|| ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
|
|
50183
|
+
|| node.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
|
|
50184
|
+
|| node.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
|
|
50144
50185
|
}
|
|
50145
50186
|
function isAliasableOrJsExpression(e) {
|
|
50146
50187
|
return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
|
|
@@ -50233,7 +50274,7 @@ var ts;
|
|
|
50233
50274
|
return hasExportAssignmentSymbol(moduleSymbol);
|
|
50234
50275
|
}
|
|
50235
50276
|
// JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
|
|
50236
|
-
return
|
|
50277
|
+
return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
|
|
50237
50278
|
}
|
|
50238
50279
|
function getTargetOfImportClause(node, dontResolveAlias) {
|
|
50239
50280
|
var _a;
|
|
@@ -53348,6 +53389,7 @@ var ts;
|
|
|
53348
53389
|
return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
|
|
53349
53390
|
}
|
|
53350
53391
|
function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
|
|
53392
|
+
var _a, _b, _c, _d;
|
|
53351
53393
|
var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
|
|
53352
53394
|
var isTypeOf = meaning === 111551 /* SymbolFlags.Value */;
|
|
53353
53395
|
if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
|
|
@@ -53365,6 +53407,7 @@ var ts;
|
|
|
53365
53407
|
assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
|
|
53366
53408
|
ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral("import"))
|
|
53367
53409
|
])));
|
|
53410
|
+
(_b = (_a = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
53368
53411
|
}
|
|
53369
53412
|
}
|
|
53370
53413
|
if (!specifier) {
|
|
@@ -53384,6 +53427,7 @@ var ts;
|
|
|
53384
53427
|
assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
|
|
53385
53428
|
ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral(swappedMode === ts.ModuleKind.ESNext ? "import" : "require"))
|
|
53386
53429
|
])));
|
|
53430
|
+
(_d = (_c = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
53387
53431
|
}
|
|
53388
53432
|
}
|
|
53389
53433
|
if (!assertion) {
|
|
@@ -58872,7 +58916,7 @@ var ts;
|
|
|
58872
58916
|
var objectType;
|
|
58873
58917
|
return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ &&
|
|
58874
58918
|
!isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
|
|
58875
|
-
!objectType.
|
|
58919
|
+
!(getMappedTypeModifiers(objectType) & 8 /* MappedTypeModifiers.ExcludeOptional */) && !objectType.declaration.nameType);
|
|
58876
58920
|
}
|
|
58877
58921
|
/**
|
|
58878
58922
|
* For a type parameter, return the base constraint of the type parameter. For the string, number,
|
|
@@ -58885,9 +58929,9 @@ var ts;
|
|
|
58885
58929
|
t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) :
|
|
58886
58930
|
t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType :
|
|
58887
58931
|
t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType :
|
|
58888
|
-
t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType(
|
|
58932
|
+
t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType() :
|
|
58889
58933
|
t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType :
|
|
58890
|
-
t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType(
|
|
58934
|
+
t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType() :
|
|
58891
58935
|
t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType :
|
|
58892
58936
|
t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType :
|
|
58893
58937
|
t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType :
|
|
@@ -60462,8 +60506,8 @@ var ts;
|
|
|
60462
60506
|
function getGlobalESSymbolConstructorTypeSymbol(reportErrors) {
|
|
60463
60507
|
return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors));
|
|
60464
60508
|
}
|
|
60465
|
-
function getGlobalESSymbolType(
|
|
60466
|
-
return (deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors))) || emptyObjectType;
|
|
60509
|
+
function getGlobalESSymbolType() {
|
|
60510
|
+
return (deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
|
|
60467
60511
|
}
|
|
60468
60512
|
function getGlobalPromiseType(reportErrors) {
|
|
60469
60513
|
return (deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", /*arity*/ 1, reportErrors))) || emptyGenericType;
|
|
@@ -60527,8 +60571,8 @@ var ts;
|
|
|
60527
60571
|
deferredGlobalAwaitedSymbol || (deferredGlobalAwaitedSymbol = getGlobalTypeAliasSymbol("Awaited", /*arity*/ 1, reportErrors) || (reportErrors ? unknownSymbol : undefined));
|
|
60528
60572
|
return deferredGlobalAwaitedSymbol === unknownSymbol ? undefined : deferredGlobalAwaitedSymbol;
|
|
60529
60573
|
}
|
|
60530
|
-
function getGlobalBigIntType(
|
|
60531
|
-
return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, reportErrors))) || emptyObjectType;
|
|
60574
|
+
function getGlobalBigIntType() {
|
|
60575
|
+
return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
|
|
60532
60576
|
}
|
|
60533
60577
|
/**
|
|
60534
60578
|
* Instantiates a global type that is generic with some element type, and returns that instantiation.
|
|
@@ -64680,7 +64724,7 @@ var ts;
|
|
|
64680
64724
|
if ((globalStringType === source && stringType === target) ||
|
|
64681
64725
|
(globalNumberType === source && numberType === target) ||
|
|
64682
64726
|
(globalBooleanType === source && booleanType === target) ||
|
|
64683
|
-
(getGlobalESSymbolType(
|
|
64727
|
+
(getGlobalESSymbolType() === source && esSymbolType === target)) {
|
|
64684
64728
|
reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
|
|
64685
64729
|
}
|
|
64686
64730
|
}
|
|
@@ -80623,8 +80667,11 @@ var ts;
|
|
|
80623
80667
|
if (node.assertions) {
|
|
80624
80668
|
var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
|
|
80625
80669
|
if (override) {
|
|
80670
|
+
if (!ts.isNightly()) {
|
|
80671
|
+
grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
|
|
80672
|
+
}
|
|
80626
80673
|
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
80627
|
-
grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.
|
|
80674
|
+
grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
|
80628
80675
|
}
|
|
80629
80676
|
}
|
|
80630
80677
|
}
|
|
@@ -82327,7 +82374,7 @@ var ts;
|
|
|
82327
82374
|
}
|
|
82328
82375
|
// For a commonjs `const x = require`, validate the alias and exit
|
|
82329
82376
|
var symbol = getSymbolOfNode(node);
|
|
82330
|
-
if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
|
|
82377
|
+
if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* SyntaxKind.BindingElement */ ? node.parent.parent : node)) {
|
|
82331
82378
|
checkAliasSymbol(node);
|
|
82332
82379
|
return;
|
|
82333
82380
|
}
|
|
@@ -82492,7 +82539,7 @@ var ts;
|
|
|
82492
82539
|
var childSymbol = getSymbolAtLocation(childNode);
|
|
82493
82540
|
if (childSymbol && childSymbol === testedSymbol) {
|
|
82494
82541
|
// If the test was a simple identifier, the above check is sufficient
|
|
82495
|
-
if (ts.isIdentifier(expr)) {
|
|
82542
|
+
if (ts.isIdentifier(expr) || ts.isIdentifier(testedNode) && ts.isBinaryExpression(testedNode.parent)) {
|
|
82496
82543
|
return true;
|
|
82497
82544
|
}
|
|
82498
82545
|
// Otherwise we need to ensure the symbol is called on the same target
|
|
@@ -84995,10 +85042,10 @@ var ts;
|
|
|
84995
85042
|
var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
|
|
84996
85043
|
if (validForTypeAssertions && override) {
|
|
84997
85044
|
if (!ts.isNightly()) {
|
|
84998
|
-
grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.
|
|
85045
|
+
grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
|
|
84999
85046
|
}
|
|
85000
85047
|
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
85001
|
-
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.
|
|
85048
|
+
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
|
85002
85049
|
}
|
|
85003
85050
|
return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
|
|
85004
85051
|
}
|
|
@@ -107850,7 +107897,8 @@ var ts;
|
|
|
107850
107897
|
trackReferencedAmbientModule: trackReferencedAmbientModule,
|
|
107851
107898
|
trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
|
|
107852
107899
|
reportNonlocalAugmentation: reportNonlocalAugmentation,
|
|
107853
|
-
reportNonSerializableProperty: reportNonSerializableProperty
|
|
107900
|
+
reportNonSerializableProperty: reportNonSerializableProperty,
|
|
107901
|
+
reportImportTypeNodeResolutionModeOverride: reportImportTypeNodeResolutionModeOverride,
|
|
107854
107902
|
};
|
|
107855
107903
|
var errorNameNode;
|
|
107856
107904
|
var errorFallbackNode;
|
|
@@ -107977,6 +108025,11 @@ var ts;
|
|
|
107977
108025
|
context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName));
|
|
107978
108026
|
}
|
|
107979
108027
|
}
|
|
108028
|
+
function reportImportTypeNodeResolutionModeOverride() {
|
|
108029
|
+
if (!ts.isNightly() && (errorNameNode || errorFallbackNode)) {
|
|
108030
|
+
context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
|
|
108031
|
+
}
|
|
108032
|
+
}
|
|
107980
108033
|
function transformDeclarationsForJS(sourceFile, bundled) {
|
|
107981
108034
|
var oldDiag = getSymbolAccessibilityDiagnostic;
|
|
107982
108035
|
getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
|
|
@@ -108427,7 +108480,7 @@ var ts;
|
|
|
108427
108480
|
var mode = ts.getResolutionModeOverrideForClause(assertClause);
|
|
108428
108481
|
if (mode !== undefined) {
|
|
108429
108482
|
if (!ts.isNightly()) {
|
|
108430
|
-
context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.
|
|
108483
|
+
context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
|
|
108431
108484
|
}
|
|
108432
108485
|
return assertClause;
|
|
108433
108486
|
}
|
|
@@ -115934,12 +115987,14 @@ var ts;
|
|
|
115934
115987
|
}
|
|
115935
115988
|
ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
|
|
115936
115989
|
;
|
|
115937
|
-
|
|
115990
|
+
/**
|
|
115991
|
+
* Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
|
|
115992
|
+
* provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
|
|
115993
|
+
*/
|
|
115938
115994
|
function getModeForFileReference(ref, containingFileMode) {
|
|
115939
115995
|
return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
115940
115996
|
}
|
|
115941
115997
|
ts.getModeForFileReference = getModeForFileReference;
|
|
115942
|
-
/* @internal */
|
|
115943
115998
|
function getModeForResolutionAtIndex(file, index) {
|
|
115944
115999
|
if (file.impliedNodeFormat === undefined)
|
|
115945
116000
|
return undefined;
|
|
@@ -115960,7 +116015,15 @@ var ts;
|
|
|
115960
116015
|
return false;
|
|
115961
116016
|
}
|
|
115962
116017
|
ts.isExclusivelyTypeOnlyImportOrExport = isExclusivelyTypeOnlyImportOrExport;
|
|
115963
|
-
|
|
116018
|
+
/**
|
|
116019
|
+
* Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
|
|
116020
|
+
* one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
|
|
116021
|
+
* Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
|
|
116022
|
+
* `moduleResolution` is `node16`+.
|
|
116023
|
+
* @param file The file the import or import-like reference is contained within
|
|
116024
|
+
* @param usage The module reference string
|
|
116025
|
+
* @returns The final resolution mode of the import
|
|
116026
|
+
*/
|
|
115964
116027
|
function getModeForUsageLocation(file, usage) {
|
|
115965
116028
|
var _a, _b;
|
|
115966
116029
|
if (file.impliedNodeFormat === undefined)
|
|
@@ -118194,7 +118257,7 @@ var ts;
|
|
|
118194
118257
|
ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
|
|
118195
118258
|
var mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
118196
118259
|
if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
118197
|
-
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.
|
|
118260
|
+
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
|
|
118198
118261
|
}
|
|
118199
118262
|
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
|
|
118200
118263
|
}
|
|
@@ -123487,6 +123550,7 @@ var ts;
|
|
|
123487
123550
|
}
|
|
123488
123551
|
function reloadFileNamesFromConfigFile() {
|
|
123489
123552
|
writeLog("Reloading new file names and options");
|
|
123553
|
+
reloadLevel = ts.ConfigFileProgramReloadLevel.None;
|
|
123490
123554
|
rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
|
|
123491
123555
|
if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
|
|
123492
123556
|
hasChangedConfigFileParsingErrors = true;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "4.7.
|
|
5
|
+
"version": "4.7.4",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|