typescript 4.9.0-dev.20220929 → 4.9.0-dev.20220930
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/protocol.d.ts +7 -0
- package/lib/tsc.js +95 -45
- package/lib/tsserver.js +180 -65
- package/lib/tsserverlibrary.d.ts +14 -0
- package/lib/tsserverlibrary.js +180 -65
- package/lib/typescript.d.ts +7 -0
- package/lib/typescript.js +171 -63
- package/lib/typescriptServices.d.ts +7 -0
- package/lib/typescriptServices.js +171 -63
- package/lib/typingsInstaller.js +121 -46
- package/package.json +2 -2
package/lib/typescript.js
CHANGED
|
@@ -99,7 +99,7 @@ var ts;
|
|
|
99
99
|
// The following is baselined as a literal template type without intervention
|
|
100
100
|
/** The version of the TypeScript compiler release */
|
|
101
101
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
102
|
-
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.
|
|
102
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220930");
|
|
103
103
|
/* @internal */
|
|
104
104
|
var Comparison;
|
|
105
105
|
(function (Comparison) {
|
|
@@ -49488,6 +49488,12 @@ var ts;
|
|
|
49488
49488
|
getOptionalType: function () { return optionalType; },
|
|
49489
49489
|
getPromiseType: function () { return getGlobalPromiseType(/*reportErrors*/ false); },
|
|
49490
49490
|
getPromiseLikeType: function () { return getGlobalPromiseLikeType(/*reportErrors*/ false); },
|
|
49491
|
+
getAsyncIterableType: function () {
|
|
49492
|
+
var type = getGlobalAsyncIterableType(/*reportErrors*/ false);
|
|
49493
|
+
if (type === emptyGenericType)
|
|
49494
|
+
return undefined;
|
|
49495
|
+
return type;
|
|
49496
|
+
},
|
|
49491
49497
|
isSymbolAccessible: isSymbolAccessible,
|
|
49492
49498
|
isArrayType: isArrayType,
|
|
49493
49499
|
isTupleType: isTupleType,
|
|
@@ -50325,9 +50331,9 @@ var ts;
|
|
|
50325
50331
|
return symbol;
|
|
50326
50332
|
}
|
|
50327
50333
|
if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
50328
|
-
var
|
|
50329
|
-
//
|
|
50330
|
-
if (
|
|
50334
|
+
var targetFlags = getAllSymbolFlags(symbol);
|
|
50335
|
+
// `targetFlags` will be `SymbolFlags.All` if an error occurred in alias resolution; this avoids cascading errors
|
|
50336
|
+
if (targetFlags & meaning) {
|
|
50331
50337
|
return symbol;
|
|
50332
50338
|
}
|
|
50333
50339
|
}
|
|
@@ -50960,8 +50966,8 @@ var ts;
|
|
|
50960
50966
|
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
50961
50967
|
!checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
|
|
50962
50968
|
!checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
|
|
50969
|
+
!checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) &&
|
|
50963
50970
|
!checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
|
|
50964
|
-
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
50965
50971
|
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
50966
50972
|
var suggestion = void 0;
|
|
50967
50973
|
var suggestedLib = void 0;
|
|
@@ -51048,7 +51054,7 @@ var ts;
|
|
|
51048
51054
|
}
|
|
51049
51055
|
}
|
|
51050
51056
|
if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
|
|
51051
|
-
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
|
|
51057
|
+
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result, 111551 /* SymbolFlags.Value */);
|
|
51052
51058
|
if (typeOnlyDeclaration) {
|
|
51053
51059
|
var message = typeOnlyDeclaration.kind === 278 /* SyntaxKind.ExportSpecifier */
|
|
51054
51060
|
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
@@ -51211,7 +51217,7 @@ var ts;
|
|
|
51211
51217
|
return false;
|
|
51212
51218
|
}
|
|
51213
51219
|
function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
|
|
51214
|
-
if (meaning &
|
|
51220
|
+
if (meaning & 111551 /* SymbolFlags.Value */) {
|
|
51215
51221
|
if (isPrimitiveTypeName(name)) {
|
|
51216
51222
|
if (isExtendedByInterface(errorLocation)) {
|
|
51217
51223
|
error(errorLocation, ts.Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, ts.unescapeLeadingUnderscores(name));
|
|
@@ -51222,7 +51228,8 @@ var ts;
|
|
|
51222
51228
|
return true;
|
|
51223
51229
|
}
|
|
51224
51230
|
var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51225
|
-
|
|
51231
|
+
var allFlags = symbol && getAllSymbolFlags(symbol);
|
|
51232
|
+
if (symbol && allFlags !== undefined && !(allFlags & 111551 /* SymbolFlags.Value */)) {
|
|
51226
51233
|
var rawName = ts.unescapeLeadingUnderscores(name);
|
|
51227
51234
|
if (isES2015OrLaterConstructorName(name)) {
|
|
51228
51235
|
error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName);
|
|
@@ -51270,16 +51277,16 @@ var ts;
|
|
|
51270
51277
|
}
|
|
51271
51278
|
return false;
|
|
51272
51279
|
}
|
|
51273
|
-
function
|
|
51274
|
-
if (meaning & (111551 /* SymbolFlags.Value */ & ~
|
|
51275
|
-
var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule
|
|
51280
|
+
function checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) {
|
|
51281
|
+
if (meaning & (111551 /* SymbolFlags.Value */ & ~788968 /* SymbolFlags.Type */)) {
|
|
51282
|
+
var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51276
51283
|
if (symbol) {
|
|
51277
51284
|
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
|
|
51278
51285
|
return true;
|
|
51279
51286
|
}
|
|
51280
51287
|
}
|
|
51281
|
-
else if (meaning & (788968 /* SymbolFlags.Type */ & ~
|
|
51282
|
-
var symbol = resolveSymbol(resolveName(errorLocation, name,
|
|
51288
|
+
else if (meaning & (788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */)) {
|
|
51289
|
+
var symbol = resolveSymbol(resolveName(errorLocation, name, 1536 /* SymbolFlags.Module */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51283
51290
|
if (symbol) {
|
|
51284
51291
|
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
|
|
51285
51292
|
return true;
|
|
@@ -51869,6 +51876,52 @@ var ts;
|
|
|
51869
51876
|
}
|
|
51870
51877
|
return undefined;
|
|
51871
51878
|
}
|
|
51879
|
+
/**
|
|
51880
|
+
* Gets combined flags of a `symbol` and all alias targets it resolves to. `resolveAlias`
|
|
51881
|
+
* is typically recursive over chains of aliases, but stops mid-chain if an alias is merged
|
|
51882
|
+
* with another exported symbol, e.g.
|
|
51883
|
+
* ```ts
|
|
51884
|
+
* // a.ts
|
|
51885
|
+
* export const a = 0;
|
|
51886
|
+
* // b.ts
|
|
51887
|
+
* export { a } from "./a";
|
|
51888
|
+
* export type a = number;
|
|
51889
|
+
* // c.ts
|
|
51890
|
+
* import { a } from "./b";
|
|
51891
|
+
* ```
|
|
51892
|
+
* Calling `resolveAlias` on the `a` in c.ts would stop at the merged symbol exported
|
|
51893
|
+
* from b.ts, even though there is still more alias to resolve. Consequently, if we were
|
|
51894
|
+
* trying to determine if the `a` in c.ts has a value meaning, looking at the flags on
|
|
51895
|
+
* the local symbol and on the symbol returned by `resolveAlias` is not enough.
|
|
51896
|
+
* @returns SymbolFlags.All if `symbol` is an alias that ultimately resolves to `unknown`;
|
|
51897
|
+
* combined flags of all alias targets otherwise.
|
|
51898
|
+
*/
|
|
51899
|
+
function getAllSymbolFlags(symbol) {
|
|
51900
|
+
var flags = symbol.flags;
|
|
51901
|
+
var seenSymbols;
|
|
51902
|
+
while (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
51903
|
+
var target = resolveAlias(symbol);
|
|
51904
|
+
if (target === unknownSymbol) {
|
|
51905
|
+
return 67108863 /* SymbolFlags.All */;
|
|
51906
|
+
}
|
|
51907
|
+
// Optimizations - try to avoid creating or adding to
|
|
51908
|
+
// `seenSymbols` if possible
|
|
51909
|
+
if (target === symbol || (seenSymbols === null || seenSymbols === void 0 ? void 0 : seenSymbols.has(target))) {
|
|
51910
|
+
break;
|
|
51911
|
+
}
|
|
51912
|
+
if (target.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
51913
|
+
if (seenSymbols) {
|
|
51914
|
+
seenSymbols.add(target);
|
|
51915
|
+
}
|
|
51916
|
+
else {
|
|
51917
|
+
seenSymbols = new ts.Set([symbol, target]);
|
|
51918
|
+
}
|
|
51919
|
+
}
|
|
51920
|
+
flags |= target.flags;
|
|
51921
|
+
symbol = target;
|
|
51922
|
+
}
|
|
51923
|
+
return flags;
|
|
51924
|
+
}
|
|
51872
51925
|
/**
|
|
51873
51926
|
* Marks a symbol as type-only if its declaration is syntactically type-only.
|
|
51874
51927
|
* If it is not itself marked type-only, but resolves to a type-only alias
|
|
@@ -51914,19 +51967,25 @@ var ts;
|
|
|
51914
51967
|
return !!aliasDeclarationLinks.typeOnlyDeclaration;
|
|
51915
51968
|
}
|
|
51916
51969
|
/** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */
|
|
51917
|
-
function getTypeOnlyAliasDeclaration(symbol) {
|
|
51970
|
+
function getTypeOnlyAliasDeclaration(symbol, include) {
|
|
51918
51971
|
if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) {
|
|
51919
51972
|
return undefined;
|
|
51920
51973
|
}
|
|
51921
51974
|
var links = getSymbolLinks(symbol);
|
|
51922
|
-
|
|
51975
|
+
if (include === undefined) {
|
|
51976
|
+
return links.typeOnlyDeclaration || undefined;
|
|
51977
|
+
}
|
|
51978
|
+
if (links.typeOnlyDeclaration) {
|
|
51979
|
+
return getAllSymbolFlags(resolveAlias(links.typeOnlyDeclaration.symbol)) & include ? links.typeOnlyDeclaration : undefined;
|
|
51980
|
+
}
|
|
51981
|
+
return undefined;
|
|
51923
51982
|
}
|
|
51924
51983
|
function markExportAsReferenced(node) {
|
|
51925
51984
|
var symbol = getSymbolOfNode(node);
|
|
51926
51985
|
var target = resolveAlias(symbol);
|
|
51927
51986
|
if (target) {
|
|
51928
51987
|
var markAlias = target === unknownSymbol ||
|
|
51929
|
-
((target
|
|
51988
|
+
((getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */));
|
|
51930
51989
|
if (markAlias) {
|
|
51931
51990
|
markAliasSymbolAsReferenced(symbol);
|
|
51932
51991
|
}
|
|
@@ -51946,8 +52005,7 @@ var ts;
|
|
|
51946
52005
|
// This way a chain of imports can be elided if ultimately the final input is only used in a type
|
|
51947
52006
|
// position.
|
|
51948
52007
|
if (ts.isInternalModuleImportEqualsDeclaration(node)) {
|
|
51949
|
-
|
|
51950
|
-
if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
|
|
52008
|
+
if (getAllSymbolFlags(resolveSymbol(symbol)) & 111551 /* SymbolFlags.Value */) {
|
|
51951
52009
|
// import foo = <symbol>
|
|
51952
52010
|
checkExpressionCached(node.moduleReference);
|
|
51953
52011
|
}
|
|
@@ -52769,7 +52827,7 @@ var ts;
|
|
|
52769
52827
|
}
|
|
52770
52828
|
function symbolIsValue(symbol, includeTypeOnlyMembers) {
|
|
52771
52829
|
return !!(symbol.flags & 111551 /* SymbolFlags.Value */ ||
|
|
52772
|
-
symbol.flags & 2097152 /* SymbolFlags.Alias */ &&
|
|
52830
|
+
symbol.flags & 2097152 /* SymbolFlags.Alias */ && getAllSymbolFlags(symbol) & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
|
|
52773
52831
|
}
|
|
52774
52832
|
function findConstructorDeclaration(node) {
|
|
52775
52833
|
var members = node.members;
|
|
@@ -53038,8 +53096,10 @@ var ts;
|
|
|
53038
53096
|
return true;
|
|
53039
53097
|
}
|
|
53040
53098
|
// Qualify if the symbol from symbol table has same meaning as expected
|
|
53041
|
-
|
|
53042
|
-
|
|
53099
|
+
var shouldResolveAlias = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */));
|
|
53100
|
+
symbolFromSymbolTable = shouldResolveAlias ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
|
|
53101
|
+
var flags = shouldResolveAlias ? getAllSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
|
|
53102
|
+
if (flags & meaning) {
|
|
53043
53103
|
qualify = true;
|
|
53044
53104
|
return true;
|
|
53045
53105
|
}
|
|
@@ -55696,7 +55756,7 @@ var ts;
|
|
|
55696
55756
|
return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
|
|
55697
55757
|
}
|
|
55698
55758
|
function isTypeOnlyNamespace(symbol) {
|
|
55699
|
-
return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m)
|
|
55759
|
+
return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(getAllSymbolFlags(resolveSymbol(m)) & 111551 /* SymbolFlags.Value */); });
|
|
55700
55760
|
}
|
|
55701
55761
|
function serializeModule(symbol, symbolName, modifierFlags) {
|
|
55702
55762
|
var members = getNamespaceMembersForSerialization(symbol);
|
|
@@ -57916,7 +57976,7 @@ var ts;
|
|
|
57916
57976
|
links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
|
|
57917
57977
|
: isDuplicatedCommonJSExport(symbol.declarations) ? autoType
|
|
57918
57978
|
: declaredType ? declaredType
|
|
57919
|
-
: targetSymbol
|
|
57979
|
+
: getAllSymbolFlags(targetSymbol) & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
|
|
57920
57980
|
: errorType;
|
|
57921
57981
|
}
|
|
57922
57982
|
return links.type;
|
|
@@ -60269,7 +60329,7 @@ var ts;
|
|
|
60269
60329
|
var indexTypes;
|
|
60270
60330
|
var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
|
|
60271
60331
|
// Flags we want to propagate to the result if they exist in all source symbols
|
|
60272
|
-
var optionalFlag
|
|
60332
|
+
var optionalFlag;
|
|
60273
60333
|
var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
|
|
60274
60334
|
var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
|
|
60275
60335
|
var mergedInstantiations = false;
|
|
@@ -60280,11 +60340,14 @@ var ts;
|
|
|
60280
60340
|
var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
|
|
60281
60341
|
var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
|
|
60282
60342
|
if (prop) {
|
|
60283
|
-
if (
|
|
60284
|
-
optionalFlag
|
|
60285
|
-
|
|
60286
|
-
|
|
60287
|
-
|
|
60343
|
+
if (prop.flags & 106500 /* SymbolFlags.ClassMember */) {
|
|
60344
|
+
optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : (optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */);
|
|
60345
|
+
if (isUnion) {
|
|
60346
|
+
optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
|
|
60347
|
+
}
|
|
60348
|
+
else {
|
|
60349
|
+
optionalFlag &= prop.flags;
|
|
60350
|
+
}
|
|
60288
60351
|
}
|
|
60289
60352
|
if (!singleProp) {
|
|
60290
60353
|
singleProp = prop;
|
|
@@ -60403,7 +60466,7 @@ var ts;
|
|
|
60403
60466
|
propTypes.push(type);
|
|
60404
60467
|
}
|
|
60405
60468
|
ts.addRange(propTypes, indexTypes);
|
|
60406
|
-
var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags);
|
|
60469
|
+
var result = createSymbol(4 /* SymbolFlags.Property */ | (optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : 0), name, syntheticFlag | checkFlags);
|
|
60407
60470
|
result.containingType = containingType;
|
|
60408
60471
|
if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
|
|
60409
60472
|
result.valueDeclaration = firstValueDeclaration;
|
|
@@ -67670,7 +67733,7 @@ var ts;
|
|
|
67670
67733
|
return 0 /* Ternary.False */;
|
|
67671
67734
|
}
|
|
67672
67735
|
// When checking for comparability, be more lenient with optional properties.
|
|
67673
|
-
if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
|
|
67736
|
+
if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && targetProp.flags & 106500 /* SymbolFlags.ClassMember */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
|
|
67674
67737
|
// TypeScript 1.0 spec (April 2014): 3.8.3
|
|
67675
67738
|
// S is a subtype of a type T, and T is a supertype of S if ...
|
|
67676
67739
|
// S' and T are object types and, for each member M in T..
|
|
@@ -72942,9 +73005,9 @@ var ts;
|
|
|
72942
73005
|
});
|
|
72943
73006
|
}
|
|
72944
73007
|
function markAliasReferenced(symbol, location) {
|
|
72945
|
-
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
73008
|
+
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
|
|
72946
73009
|
var target = resolveAlias(symbol);
|
|
72947
|
-
if (target
|
|
73010
|
+
if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
72948
73011
|
// An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
|
|
72949
73012
|
// (because the const enum value will not be inlined), or if (2) the alias is an export
|
|
72950
73013
|
// of a const enum declaration that will be preserved.
|
|
@@ -78836,7 +78899,7 @@ var ts;
|
|
|
78836
78899
|
if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
78837
78900
|
symbol = resolveAlias(symbol);
|
|
78838
78901
|
}
|
|
78839
|
-
return !!(symbol && (symbol
|
|
78902
|
+
return !!(symbol && (getAllSymbolFlags(symbol) & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
|
|
78840
78903
|
}
|
|
78841
78904
|
return false;
|
|
78842
78905
|
}
|
|
@@ -85011,7 +85074,16 @@ var ts;
|
|
|
85011
85074
|
var message = allowAsyncIterables
|
|
85012
85075
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
85013
85076
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
85014
|
-
|
|
85077
|
+
var suggestAwait =
|
|
85078
|
+
// for (const x of Promise<...>) or [...Promise<...>]
|
|
85079
|
+
!!getAwaitedTypeOfPromise(type)
|
|
85080
|
+
// for (const x of AsyncIterable<...>)
|
|
85081
|
+
|| (!allowAsyncIterables &&
|
|
85082
|
+
ts.isForOfStatement(errorNode.parent) &&
|
|
85083
|
+
errorNode.parent.expression === errorNode &&
|
|
85084
|
+
getGlobalAsyncIterableType(/** reportErrors */ false) !== emptyGenericType &&
|
|
85085
|
+
isTypeAssignableTo(type, getGlobalAsyncIterableType(/** reportErrors */ false)));
|
|
85086
|
+
return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
|
|
85015
85087
|
}
|
|
85016
85088
|
/**
|
|
85017
85089
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
@@ -86862,10 +86934,11 @@ var ts;
|
|
|
86862
86934
|
}
|
|
86863
86935
|
return;
|
|
86864
86936
|
}
|
|
86937
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
86865
86938
|
var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
|
|
86866
86939
|
(symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
|
|
86867
86940
|
(symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
|
|
86868
|
-
if (
|
|
86941
|
+
if (targetFlags & excludedMeanings) {
|
|
86869
86942
|
var message = node.kind === 278 /* SyntaxKind.ExportSpecifier */ ?
|
|
86870
86943
|
ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
|
|
86871
86944
|
ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
|
|
@@ -86875,7 +86948,7 @@ var ts;
|
|
|
86875
86948
|
&& !ts.isTypeOnlyImportOrExportDeclaration(node)
|
|
86876
86949
|
&& !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
|
|
86877
86950
|
var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
|
|
86878
|
-
var isType = !(
|
|
86951
|
+
var isType = !(targetFlags & 111551 /* SymbolFlags.Value */);
|
|
86879
86952
|
if (isType || typeOnlyAlias) {
|
|
86880
86953
|
switch (node.kind) {
|
|
86881
86954
|
case 270 /* SyntaxKind.ImportClause */:
|
|
@@ -87035,14 +87108,15 @@ var ts;
|
|
|
87035
87108
|
if (node.moduleReference.kind !== 280 /* SyntaxKind.ExternalModuleReference */) {
|
|
87036
87109
|
var target = resolveAlias(getSymbolOfNode(node));
|
|
87037
87110
|
if (target !== unknownSymbol) {
|
|
87038
|
-
|
|
87111
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
87112
|
+
if (targetFlags & 111551 /* SymbolFlags.Value */) {
|
|
87039
87113
|
// Target is a value symbol, check that it is not hidden by a local declaration with the same name
|
|
87040
87114
|
var moduleName = ts.getFirstIdentifier(node.moduleReference);
|
|
87041
87115
|
if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
|
|
87042
87116
|
error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
|
|
87043
87117
|
}
|
|
87044
87118
|
}
|
|
87045
|
-
if (
|
|
87119
|
+
if (targetFlags & 788968 /* SymbolFlags.Type */) {
|
|
87046
87120
|
checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
|
|
87047
87121
|
}
|
|
87048
87122
|
}
|
|
@@ -87181,7 +87255,7 @@ var ts;
|
|
|
87181
87255
|
markExportAsReferenced(node);
|
|
87182
87256
|
}
|
|
87183
87257
|
var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
|
|
87184
|
-
if (!target || target
|
|
87258
|
+
if (!target || getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87185
87259
|
checkExpressionCached(node.propertyName || node.name);
|
|
87186
87260
|
}
|
|
87187
87261
|
}
|
|
@@ -87228,7 +87302,7 @@ var ts;
|
|
|
87228
87302
|
markAliasReferenced(sym, id);
|
|
87229
87303
|
// If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
|
|
87230
87304
|
var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
|
|
87231
|
-
if (target
|
|
87305
|
+
if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87232
87306
|
// However if it is a value, we need to check it's being used correctly
|
|
87233
87307
|
checkExpressionCached(node.expression);
|
|
87234
87308
|
}
|
|
@@ -88550,7 +88624,7 @@ var ts;
|
|
|
88550
88624
|
return symbolLinks.exportsSomeValue;
|
|
88551
88625
|
function isValue(s) {
|
|
88552
88626
|
s = resolveSymbol(s);
|
|
88553
|
-
return s && !!(s
|
|
88627
|
+
return s && !!(getAllSymbolFlags(s) & 111551 /* SymbolFlags.Value */);
|
|
88554
88628
|
}
|
|
88555
88629
|
}
|
|
88556
88630
|
function isNameOfModuleOrEnumDeclaration(node) {
|
|
@@ -88603,7 +88677,7 @@ var ts;
|
|
|
88603
88677
|
var symbol = getReferencedValueOrAliasSymbol(node);
|
|
88604
88678
|
// We should only get the declaration of an alias if there isn't a local value
|
|
88605
88679
|
// declaration for the symbol
|
|
88606
|
-
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
88680
|
+
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
|
|
88607
88681
|
return getDeclarationOfAliasSymbol(symbol);
|
|
88608
88682
|
}
|
|
88609
88683
|
}
|
|
@@ -88691,7 +88765,7 @@ var ts;
|
|
|
88691
88765
|
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
88692
88766
|
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
88693
88767
|
var symbol = getSymbolOfNode(node);
|
|
88694
|
-
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
|
|
88768
|
+
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */);
|
|
88695
88769
|
case 275 /* SyntaxKind.ExportDeclaration */:
|
|
88696
88770
|
var exportClause = node.exportClause;
|
|
88697
88771
|
return !!exportClause && (ts.isNamespaceExport(exportClause) ||
|
|
@@ -88713,6 +88787,7 @@ var ts;
|
|
|
88713
88787
|
return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
|
|
88714
88788
|
}
|
|
88715
88789
|
function isAliasResolvedToValue(symbol) {
|
|
88790
|
+
var _a;
|
|
88716
88791
|
if (!symbol) {
|
|
88717
88792
|
return false;
|
|
88718
88793
|
}
|
|
@@ -88722,7 +88797,7 @@ var ts;
|
|
|
88722
88797
|
}
|
|
88723
88798
|
// const enums and modules that contain only const enums are not considered values from the emit perspective
|
|
88724
88799
|
// unless 'preserveConstEnums' option is set to true
|
|
88725
|
-
return !!(target
|
|
88800
|
+
return !!(((_a = getAllSymbolFlags(target)) !== null && _a !== void 0 ? _a : -1) & 111551 /* SymbolFlags.Value */) &&
|
|
88726
88801
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
|
|
88727
88802
|
}
|
|
88728
88803
|
function isConstEnumOrConstEnumOnlyModule(s) {
|
|
@@ -88737,7 +88812,7 @@ var ts;
|
|
|
88737
88812
|
}
|
|
88738
88813
|
var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
|
|
88739
88814
|
if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
|
|
88740
|
-
target
|
|
88815
|
+
getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */ &&
|
|
88741
88816
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
88742
88817
|
// An `export import ... =` of a value symbol is always considered referenced
|
|
88743
88818
|
return true;
|
|
@@ -129193,6 +129268,12 @@ var ts;
|
|
|
129193
129268
|
SemanticClassificationFormat["Original"] = "original";
|
|
129194
129269
|
SemanticClassificationFormat["TwentyTwenty"] = "2020";
|
|
129195
129270
|
})(SemanticClassificationFormat = ts.SemanticClassificationFormat || (ts.SemanticClassificationFormat = {}));
|
|
129271
|
+
var OrganizeImportsMode;
|
|
129272
|
+
(function (OrganizeImportsMode) {
|
|
129273
|
+
OrganizeImportsMode["All"] = "All";
|
|
129274
|
+
OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
|
|
129275
|
+
OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
|
|
129276
|
+
})(OrganizeImportsMode = ts.OrganizeImportsMode || (ts.OrganizeImportsMode = {}));
|
|
129196
129277
|
var CompletionTriggerKind;
|
|
129197
129278
|
(function (CompletionTriggerKind) {
|
|
129198
129279
|
/** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */
|
|
@@ -144948,23 +145029,39 @@ var ts;
|
|
|
144948
145029
|
* 2) Coalescing imports from the same module
|
|
144949
145030
|
* 3) Sorting imports
|
|
144950
145031
|
*/
|
|
144951
|
-
function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
145032
|
+
function organizeImports(sourceFile, formatContext, host, program, preferences, mode) {
|
|
144952
145033
|
var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
|
|
144953
|
-
var
|
|
145034
|
+
var shouldSort = mode === "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ || mode === "All" /* OrganizeImportsMode.All */;
|
|
145035
|
+
var shouldCombine = shouldSort; // These are currently inseparable, but I draw a distinction for clarity and in case we add modes in the future.
|
|
145036
|
+
var shouldRemove = mode === "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */ || mode === "All" /* OrganizeImportsMode.All */;
|
|
145037
|
+
var maybeRemove = shouldRemove ? removeUnusedImports : ts.identity;
|
|
145038
|
+
var maybeCoalesce = shouldCombine ? coalesceImports : ts.identity;
|
|
145039
|
+
var processImportsOfSameModuleSpecifier = function (importGroup) {
|
|
145040
|
+
var processedDeclarations = maybeCoalesce(maybeRemove(importGroup, sourceFile, program));
|
|
145041
|
+
return shouldSort
|
|
145042
|
+
? ts.stableSort(processedDeclarations, function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); })
|
|
145043
|
+
: processedDeclarations;
|
|
145044
|
+
};
|
|
144954
145045
|
// All of the old ImportDeclarations in the file, in syntactic order.
|
|
144955
145046
|
var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
|
|
144956
|
-
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144957
|
-
//
|
|
144958
|
-
|
|
144959
|
-
|
|
145047
|
+
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
|
|
145048
|
+
// Exports are always used
|
|
145049
|
+
if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
|
|
145050
|
+
// All of the old ExportDeclarations in the file, in syntactic order.
|
|
145051
|
+
var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
|
|
145052
|
+
organizeImportsWorker(topLevelExportDecls, coalesceExports);
|
|
145053
|
+
}
|
|
144960
145054
|
for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) {
|
|
144961
145055
|
var ambientModule = _a[_i];
|
|
144962
145056
|
if (!ambientModule.body)
|
|
144963
145057
|
continue;
|
|
144964
145058
|
var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
|
|
144965
|
-
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144966
|
-
|
|
144967
|
-
|
|
145059
|
+
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
|
|
145060
|
+
// Exports are always used
|
|
145061
|
+
if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
|
|
145062
|
+
var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
|
|
145063
|
+
organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
|
|
145064
|
+
}
|
|
144968
145065
|
}
|
|
144969
145066
|
return changeTracker.getChanges();
|
|
144970
145067
|
function organizeImportsWorker(oldImportDecls, coalesce) {
|
|
@@ -144977,8 +145074,12 @@ var ts;
|
|
|
144977
145074
|
// Consider: we could do a more careful check that this trivia is actually a header,
|
|
144978
145075
|
// but the consequences of being wrong are very minor.
|
|
144979
145076
|
ts.suppressLeadingTrivia(oldImportDecls[0]);
|
|
144980
|
-
var oldImportGroups =
|
|
144981
|
-
|
|
145077
|
+
var oldImportGroups = shouldCombine
|
|
145078
|
+
? ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); })
|
|
145079
|
+
: [oldImportDecls];
|
|
145080
|
+
var sortedImportGroups = shouldSort
|
|
145081
|
+
? ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); })
|
|
145082
|
+
: oldImportGroups;
|
|
144982
145083
|
var newImportDecls = ts.flatMap(sortedImportGroups, function (importGroup) {
|
|
144983
145084
|
return getExternalModuleName(importGroup[0].moduleSpecifier)
|
|
144984
145085
|
? coalesce(importGroup)
|
|
@@ -145042,11 +145143,7 @@ var ts;
|
|
|
145042
145143
|
}
|
|
145043
145144
|
return false;
|
|
145044
145145
|
}
|
|
145045
|
-
function removeUnusedImports(oldImports, sourceFile, program
|
|
145046
|
-
// As a precaution, consider unused import detection to be destructive (GH #43051)
|
|
145047
|
-
if (skipDestructiveCodeActions) {
|
|
145048
|
-
return oldImports;
|
|
145049
|
-
}
|
|
145146
|
+
function removeUnusedImports(oldImports, sourceFile, program) {
|
|
145050
145147
|
var typeChecker = program.getTypeChecker();
|
|
145051
145148
|
var compilerOptions = program.getCompilerOptions();
|
|
145052
145149
|
var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
|
|
@@ -154079,6 +154176,15 @@ var ts;
|
|
|
154079
154176
|
});
|
|
154080
154177
|
}
|
|
154081
154178
|
function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
|
|
154179
|
+
if (ts.isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
|
|
154180
|
+
var exprType = checker.getTypeAtLocation(insertionSite);
|
|
154181
|
+
var asyncIter = checker.getAsyncIterableType();
|
|
154182
|
+
if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
|
|
154183
|
+
var forOf = insertionSite.parent;
|
|
154184
|
+
changeTracker.replaceNode(sourceFile, forOf, ts.factory.updateForOfStatement(forOf, ts.factory.createToken(133 /* SyntaxKind.AwaitKeyword */), forOf.initializer, forOf.expression, forOf.statement));
|
|
154185
|
+
return;
|
|
154186
|
+
}
|
|
154187
|
+
}
|
|
154082
154188
|
if (ts.isBinaryExpression(insertionSite)) {
|
|
154083
154189
|
for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) {
|
|
154084
154190
|
var side = _a[_i];
|
|
@@ -169434,12 +169540,14 @@ var ts;
|
|
|
169434
169540
|
return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
|
|
169435
169541
|
}
|
|
169436
169542
|
function organizeImports(args, formatOptions, preferences) {
|
|
169543
|
+
var _a;
|
|
169437
169544
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
169438
169545
|
synchronizeHostData();
|
|
169439
169546
|
ts.Debug.assert(args.type === "file");
|
|
169440
169547
|
var sourceFile = getValidSourceFile(args.fileName);
|
|
169441
169548
|
var formatContext = ts.formatting.getFormatContext(formatOptions, host);
|
|
169442
|
-
|
|
169549
|
+
var mode = (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : "All" /* OrganizeImportsMode.All */);
|
|
169550
|
+
return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, mode);
|
|
169443
169551
|
}
|
|
169444
169552
|
function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
|
|
169445
169553
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
@@ -6032,8 +6032,15 @@ declare namespace ts {
|
|
|
6032
6032
|
type: "file";
|
|
6033
6033
|
fileName: string;
|
|
6034
6034
|
}
|
|
6035
|
+
enum OrganizeImportsMode {
|
|
6036
|
+
All = "All",
|
|
6037
|
+
SortAndCombine = "SortAndCombine",
|
|
6038
|
+
RemoveUnused = "RemoveUnused"
|
|
6039
|
+
}
|
|
6035
6040
|
interface OrganizeImportsArgs extends CombinedCodeFixScope {
|
|
6041
|
+
/** @deprecated Use `mode` instead */
|
|
6036
6042
|
skipDestructiveCodeActions?: boolean;
|
|
6043
|
+
mode?: OrganizeImportsMode;
|
|
6037
6044
|
}
|
|
6038
6045
|
type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#" | " ";
|
|
6039
6046
|
enum CompletionTriggerKind {
|