typescript 4.9.0-dev.20220928 → 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.
@@ -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 = "".concat(ts.versionMajorMinor, ".0-dev.20220928");
92
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220930");
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -3195,11 +3195,13 @@ var ts;
3195
3195
  // > alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers
3196
3196
  // > MUST NOT include leading zeroes.
3197
3197
  var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
3198
+ var prereleasePartRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)$/i;
3198
3199
  // https://semver.org/#spec-item-10
3199
3200
  // > Build metadata MAY be denoted by appending a plus sign and a series of dot separated
3200
3201
  // > identifiers immediately following the patch or pre-release version. Identifiers MUST
3201
3202
  // > comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty.
3202
3203
  var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
3204
+ var buildPartRegExp = /^[a-z0-9-]+$/i;
3203
3205
  // https://semver.org/#spec-item-9
3204
3206
  // > Numeric identifiers MUST NOT include leading zeroes.
3205
3207
  var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
@@ -3219,13 +3221,15 @@ var ts;
3219
3221
  ts.Debug.assert(major >= 0, "Invalid argument: major");
3220
3222
  ts.Debug.assert(minor >= 0, "Invalid argument: minor");
3221
3223
  ts.Debug.assert(patch >= 0, "Invalid argument: patch");
3222
- ts.Debug.assert(!prerelease || prereleaseRegExp.test(prerelease), "Invalid argument: prerelease");
3223
- ts.Debug.assert(!build || buildRegExp.test(build), "Invalid argument: build");
3224
+ var prereleaseArray = prerelease ? ts.isArray(prerelease) ? prerelease : prerelease.split(".") : ts.emptyArray;
3225
+ var buildArray = build ? ts.isArray(build) ? build : build.split(".") : ts.emptyArray;
3226
+ ts.Debug.assert(ts.every(prereleaseArray, function (s) { return prereleasePartRegExp.test(s); }), "Invalid argument: prerelease");
3227
+ ts.Debug.assert(ts.every(buildArray, function (s) { return buildPartRegExp.test(s); }), "Invalid argument: build");
3224
3228
  this.major = major;
3225
3229
  this.minor = minor;
3226
3230
  this.patch = patch;
3227
- this.prerelease = prerelease ? prerelease.split(".") : ts.emptyArray;
3228
- this.build = build ? build.split(".") : ts.emptyArray;
3231
+ this.prerelease = prereleaseArray;
3232
+ this.build = buildArray;
3229
3233
  }
3230
3234
  Version.tryParse = function (text) {
3231
3235
  var result = tryParseComponents(text);
@@ -3264,6 +3268,10 @@ var ts;
3264
3268
  default: return ts.Debug.assertNever(field);
3265
3269
  }
3266
3270
  };
3271
+ Version.prototype.with = function (fields) {
3272
+ var _a = fields.major, major = _a === void 0 ? this.major : _a, _b = fields.minor, minor = _b === void 0 ? this.minor : _b, _c = fields.patch, patch = _c === void 0 ? this.patch : _c, _d = fields.prerelease, prerelease = _d === void 0 ? this.prerelease : _d, _e = fields.build, build = _e === void 0 ? this.build : _e;
3273
+ return new Version(major, minor, patch, prerelease, build);
3274
+ };
3267
3275
  Version.prototype.toString = function () {
3268
3276
  var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch);
3269
3277
  if (ts.some(this.prerelease))
@@ -3272,7 +3280,7 @@ var ts;
3272
3280
  result += "+".concat(this.build.join("."));
3273
3281
  return result;
3274
3282
  };
3275
- Version.zero = new Version(0, 0, 0);
3283
+ Version.zero = new Version(0, 0, 0, ["0"]);
3276
3284
  return Version;
3277
3285
  }());
3278
3286
  ts.Version = Version;
@@ -3355,6 +3363,10 @@ var ts;
3355
3363
  }
3356
3364
  return undefined;
3357
3365
  };
3366
+ /**
3367
+ * Tests whether a version matches the range. This is equivalent to `satisfies(version, range, { includePrerelease: true })`.
3368
+ * in `node-semver`.
3369
+ */
3358
3370
  VersionRange.prototype.test = function (version) {
3359
3371
  if (typeof version === "string")
3360
3372
  version = new Version(version);
@@ -3465,19 +3477,20 @@ var ts;
3465
3477
  break;
3466
3478
  case "<":
3467
3479
  case ">=":
3468
- comparators.push(createComparator(operator, version));
3480
+ comparators.push(isWildcard(minor) || isWildcard(patch) ? createComparator(operator, version.with({ prerelease: "0" })) :
3481
+ createComparator(operator, version));
3469
3482
  break;
3470
3483
  case "<=":
3471
3484
  case ">":
3472
- comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
3473
- isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
3485
+ comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major").with({ prerelease: "0" })) :
3486
+ isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor").with({ prerelease: "0" })) :
3474
3487
  createComparator(operator, version));
3475
3488
  break;
3476
3489
  case "=":
3477
3490
  case undefined:
3478
3491
  if (isWildcard(minor) || isWildcard(patch)) {
3479
- comparators.push(createComparator(">=", version));
3480
- comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
3492
+ comparators.push(createComparator(">=", version.with({ prerelease: "0" })));
3493
+ comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor").with({ prerelease: "0" })));
3481
3494
  }
3482
3495
  else {
3483
3496
  comparators.push(createComparator("=", version));
@@ -49465,6 +49478,12 @@ var ts;
49465
49478
  getOptionalType: function () { return optionalType; },
49466
49479
  getPromiseType: function () { return getGlobalPromiseType(/*reportErrors*/ false); },
49467
49480
  getPromiseLikeType: function () { return getGlobalPromiseLikeType(/*reportErrors*/ false); },
49481
+ getAsyncIterableType: function () {
49482
+ var type = getGlobalAsyncIterableType(/*reportErrors*/ false);
49483
+ if (type === emptyGenericType)
49484
+ return undefined;
49485
+ return type;
49486
+ },
49468
49487
  isSymbolAccessible: isSymbolAccessible,
49469
49488
  isArrayType: isArrayType,
49470
49489
  isTupleType: isTupleType,
@@ -50302,9 +50321,9 @@ var ts;
50302
50321
  return symbol;
50303
50322
  }
50304
50323
  if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
50305
- var target = resolveAlias(symbol);
50306
- // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors
50307
- if (target === unknownSymbol || target.flags & meaning) {
50324
+ var targetFlags = getAllSymbolFlags(symbol);
50325
+ // `targetFlags` will be `SymbolFlags.All` if an error occurred in alias resolution; this avoids cascading errors
50326
+ if (targetFlags & meaning) {
50308
50327
  return symbol;
50309
50328
  }
50310
50329
  }
@@ -50937,8 +50956,8 @@ var ts;
50937
50956
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
50938
50957
  !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
50939
50958
  !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
50959
+ !checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) &&
50940
50960
  !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
50941
- !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
50942
50961
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
50943
50962
  var suggestion = void 0;
50944
50963
  var suggestedLib = void 0;
@@ -51025,7 +51044,7 @@ var ts;
51025
51044
  }
51026
51045
  }
51027
51046
  if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
51028
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
51047
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result, 111551 /* SymbolFlags.Value */);
51029
51048
  if (typeOnlyDeclaration) {
51030
51049
  var message = typeOnlyDeclaration.kind === 278 /* SyntaxKind.ExportSpecifier */
51031
51050
  ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
@@ -51188,7 +51207,7 @@ var ts;
51188
51207
  return false;
51189
51208
  }
51190
51209
  function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
51191
- if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) {
51210
+ if (meaning & 111551 /* SymbolFlags.Value */) {
51192
51211
  if (isPrimitiveTypeName(name)) {
51193
51212
  if (isExtendedByInterface(errorLocation)) {
51194
51213
  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));
@@ -51199,7 +51218,8 @@ var ts;
51199
51218
  return true;
51200
51219
  }
51201
51220
  var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51202
- if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) {
51221
+ var allFlags = symbol && getAllSymbolFlags(symbol);
51222
+ if (symbol && allFlags !== undefined && !(allFlags & 111551 /* SymbolFlags.Value */)) {
51203
51223
  var rawName = ts.unescapeLeadingUnderscores(name);
51204
51224
  if (isES2015OrLaterConstructorName(name)) {
51205
51225
  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);
@@ -51247,16 +51267,16 @@ var ts;
51247
51267
  }
51248
51268
  return false;
51249
51269
  }
51250
- function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) {
51251
- if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) {
51252
- var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51270
+ function checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) {
51271
+ if (meaning & (111551 /* SymbolFlags.Value */ & ~788968 /* SymbolFlags.Type */)) {
51272
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51253
51273
  if (symbol) {
51254
51274
  error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
51255
51275
  return true;
51256
51276
  }
51257
51277
  }
51258
- else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) {
51259
- var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51278
+ else if (meaning & (788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */)) {
51279
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 1536 /* SymbolFlags.Module */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51260
51280
  if (symbol) {
51261
51281
  error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
51262
51282
  return true;
@@ -51846,6 +51866,52 @@ var ts;
51846
51866
  }
51847
51867
  return undefined;
51848
51868
  }
51869
+ /**
51870
+ * Gets combined flags of a `symbol` and all alias targets it resolves to. `resolveAlias`
51871
+ * is typically recursive over chains of aliases, but stops mid-chain if an alias is merged
51872
+ * with another exported symbol, e.g.
51873
+ * ```ts
51874
+ * // a.ts
51875
+ * export const a = 0;
51876
+ * // b.ts
51877
+ * export { a } from "./a";
51878
+ * export type a = number;
51879
+ * // c.ts
51880
+ * import { a } from "./b";
51881
+ * ```
51882
+ * Calling `resolveAlias` on the `a` in c.ts would stop at the merged symbol exported
51883
+ * from b.ts, even though there is still more alias to resolve. Consequently, if we were
51884
+ * trying to determine if the `a` in c.ts has a value meaning, looking at the flags on
51885
+ * the local symbol and on the symbol returned by `resolveAlias` is not enough.
51886
+ * @returns SymbolFlags.All if `symbol` is an alias that ultimately resolves to `unknown`;
51887
+ * combined flags of all alias targets otherwise.
51888
+ */
51889
+ function getAllSymbolFlags(symbol) {
51890
+ var flags = symbol.flags;
51891
+ var seenSymbols;
51892
+ while (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
51893
+ var target = resolveAlias(symbol);
51894
+ if (target === unknownSymbol) {
51895
+ return 67108863 /* SymbolFlags.All */;
51896
+ }
51897
+ // Optimizations - try to avoid creating or adding to
51898
+ // `seenSymbols` if possible
51899
+ if (target === symbol || (seenSymbols === null || seenSymbols === void 0 ? void 0 : seenSymbols.has(target))) {
51900
+ break;
51901
+ }
51902
+ if (target.flags & 2097152 /* SymbolFlags.Alias */) {
51903
+ if (seenSymbols) {
51904
+ seenSymbols.add(target);
51905
+ }
51906
+ else {
51907
+ seenSymbols = new ts.Set([symbol, target]);
51908
+ }
51909
+ }
51910
+ flags |= target.flags;
51911
+ symbol = target;
51912
+ }
51913
+ return flags;
51914
+ }
51849
51915
  /**
51850
51916
  * Marks a symbol as type-only if its declaration is syntactically type-only.
51851
51917
  * If it is not itself marked type-only, but resolves to a type-only alias
@@ -51891,19 +51957,25 @@ var ts;
51891
51957
  return !!aliasDeclarationLinks.typeOnlyDeclaration;
51892
51958
  }
51893
51959
  /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */
51894
- function getTypeOnlyAliasDeclaration(symbol) {
51960
+ function getTypeOnlyAliasDeclaration(symbol, include) {
51895
51961
  if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) {
51896
51962
  return undefined;
51897
51963
  }
51898
51964
  var links = getSymbolLinks(symbol);
51899
- return links.typeOnlyDeclaration || undefined;
51965
+ if (include === undefined) {
51966
+ return links.typeOnlyDeclaration || undefined;
51967
+ }
51968
+ if (links.typeOnlyDeclaration) {
51969
+ return getAllSymbolFlags(resolveAlias(links.typeOnlyDeclaration.symbol)) & include ? links.typeOnlyDeclaration : undefined;
51970
+ }
51971
+ return undefined;
51900
51972
  }
51901
51973
  function markExportAsReferenced(node) {
51902
51974
  var symbol = getSymbolOfNode(node);
51903
51975
  var target = resolveAlias(symbol);
51904
51976
  if (target) {
51905
51977
  var markAlias = target === unknownSymbol ||
51906
- ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
51978
+ ((getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */));
51907
51979
  if (markAlias) {
51908
51980
  markAliasSymbolAsReferenced(symbol);
51909
51981
  }
@@ -51923,8 +51995,7 @@ var ts;
51923
51995
  // This way a chain of imports can be elided if ultimately the final input is only used in a type
51924
51996
  // position.
51925
51997
  if (ts.isInternalModuleImportEqualsDeclaration(node)) {
51926
- var target = resolveSymbol(symbol);
51927
- if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
51998
+ if (getAllSymbolFlags(resolveSymbol(symbol)) & 111551 /* SymbolFlags.Value */) {
51928
51999
  // import foo = <symbol>
51929
52000
  checkExpressionCached(node.moduleReference);
51930
52001
  }
@@ -52746,7 +52817,7 @@ var ts;
52746
52817
  }
52747
52818
  function symbolIsValue(symbol, includeTypeOnlyMembers) {
52748
52819
  return !!(symbol.flags & 111551 /* SymbolFlags.Value */ ||
52749
- symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
52820
+ symbol.flags & 2097152 /* SymbolFlags.Alias */ && getAllSymbolFlags(symbol) & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
52750
52821
  }
52751
52822
  function findConstructorDeclaration(node) {
52752
52823
  var members = node.members;
@@ -53015,8 +53086,10 @@ var ts;
53015
53086
  return true;
53016
53087
  }
53017
53088
  // Qualify if the symbol from symbol table has same meaning as expected
53018
- symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
53019
- if (symbolFromSymbolTable.flags & meaning) {
53089
+ var shouldResolveAlias = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */));
53090
+ symbolFromSymbolTable = shouldResolveAlias ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
53091
+ var flags = shouldResolveAlias ? getAllSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
53092
+ if (flags & meaning) {
53020
53093
  qualify = true;
53021
53094
  return true;
53022
53095
  }
@@ -55673,7 +55746,7 @@ var ts;
55673
55746
  return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
55674
55747
  }
55675
55748
  function isTypeOnlyNamespace(symbol) {
55676
- return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); });
55749
+ return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(getAllSymbolFlags(resolveSymbol(m)) & 111551 /* SymbolFlags.Value */); });
55677
55750
  }
55678
55751
  function serializeModule(symbol, symbolName, modifierFlags) {
55679
55752
  var members = getNamespaceMembersForSerialization(symbol);
@@ -57893,7 +57966,7 @@ var ts;
57893
57966
  links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
57894
57967
  : isDuplicatedCommonJSExport(symbol.declarations) ? autoType
57895
57968
  : declaredType ? declaredType
57896
- : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
57969
+ : getAllSymbolFlags(targetSymbol) & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
57897
57970
  : errorType;
57898
57971
  }
57899
57972
  return links.type;
@@ -60246,7 +60319,7 @@ var ts;
60246
60319
  var indexTypes;
60247
60320
  var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
60248
60321
  // Flags we want to propagate to the result if they exist in all source symbols
60249
- var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */;
60322
+ var optionalFlag;
60250
60323
  var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
60251
60324
  var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
60252
60325
  var mergedInstantiations = false;
@@ -60257,11 +60330,14 @@ var ts;
60257
60330
  var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
60258
60331
  var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
60259
60332
  if (prop) {
60260
- if (isUnion) {
60261
- optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
60262
- }
60263
- else {
60264
- optionalFlag &= prop.flags;
60333
+ if (prop.flags & 106500 /* SymbolFlags.ClassMember */) {
60334
+ optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : (optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */);
60335
+ if (isUnion) {
60336
+ optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
60337
+ }
60338
+ else {
60339
+ optionalFlag &= prop.flags;
60340
+ }
60265
60341
  }
60266
60342
  if (!singleProp) {
60267
60343
  singleProp = prop;
@@ -60380,7 +60456,7 @@ var ts;
60380
60456
  propTypes.push(type);
60381
60457
  }
60382
60458
  ts.addRange(propTypes, indexTypes);
60383
- var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags);
60459
+ var result = createSymbol(4 /* SymbolFlags.Property */ | (optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : 0), name, syntheticFlag | checkFlags);
60384
60460
  result.containingType = containingType;
60385
60461
  if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
60386
60462
  result.valueDeclaration = firstValueDeclaration;
@@ -66991,7 +67067,7 @@ var ts;
66991
67067
  // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
66992
67068
  var constraint = getConstraintOfTypeParameter(source);
66993
67069
  if (constraint && hasNonCircularBaseConstraint(source)) {
66994
- while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) {
67070
+ while (constraint && someType(constraint, function (c) { return !!(c.flags & 262144 /* TypeFlags.TypeParameter */); })) {
66995
67071
  if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) {
66996
67072
  return result;
66997
67073
  }
@@ -67647,7 +67723,7 @@ var ts;
67647
67723
  return 0 /* Ternary.False */;
67648
67724
  }
67649
67725
  // When checking for comparability, be more lenient with optional properties.
67650
- if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
67726
+ if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && targetProp.flags & 106500 /* SymbolFlags.ClassMember */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
67651
67727
  // TypeScript 1.0 spec (April 2014): 3.8.3
67652
67728
  // S is a subtype of a type T, and T is a supertype of S if ...
67653
67729
  // S' and T are object types and, for each member M in T..
@@ -72919,9 +72995,9 @@ var ts;
72919
72995
  });
72920
72996
  }
72921
72997
  function markAliasReferenced(symbol, location) {
72922
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
72998
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
72923
72999
  var target = resolveAlias(symbol);
72924
- if (target.flags & 111551 /* SymbolFlags.Value */) {
73000
+ if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
72925
73001
  // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
72926
73002
  // (because the const enum value will not be inlined), or if (2) the alias is an export
72927
73003
  // of a const enum declaration that will be preserved.
@@ -78813,7 +78889,7 @@ var ts;
78813
78889
  if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
78814
78890
  symbol = resolveAlias(symbol);
78815
78891
  }
78816
- return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
78892
+ return !!(symbol && (getAllSymbolFlags(symbol) & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
78817
78893
  }
78818
78894
  return false;
78819
78895
  }
@@ -84988,7 +85064,16 @@ var ts;
84988
85064
  var message = allowAsyncIterables
84989
85065
  ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
84990
85066
  : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
84991
- return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
85067
+ var suggestAwait =
85068
+ // for (const x of Promise<...>) or [...Promise<...>]
85069
+ !!getAwaitedTypeOfPromise(type)
85070
+ // for (const x of AsyncIterable<...>)
85071
+ || (!allowAsyncIterables &&
85072
+ ts.isForOfStatement(errorNode.parent) &&
85073
+ errorNode.parent.expression === errorNode &&
85074
+ getGlobalAsyncIterableType(/** reportErrors */ false) !== emptyGenericType &&
85075
+ isTypeAssignableTo(type, getGlobalAsyncIterableType(/** reportErrors */ false)));
85076
+ return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
84992
85077
  }
84993
85078
  /**
84994
85079
  * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
@@ -86839,10 +86924,11 @@ var ts;
86839
86924
  }
86840
86925
  return;
86841
86926
  }
86927
+ var targetFlags = getAllSymbolFlags(target);
86842
86928
  var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
86843
86929
  (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
86844
86930
  (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
86845
- if (target.flags & excludedMeanings) {
86931
+ if (targetFlags & excludedMeanings) {
86846
86932
  var message = node.kind === 278 /* SyntaxKind.ExportSpecifier */ ?
86847
86933
  ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
86848
86934
  ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
@@ -86852,7 +86938,7 @@ var ts;
86852
86938
  && !ts.isTypeOnlyImportOrExportDeclaration(node)
86853
86939
  && !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
86854
86940
  var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
86855
- var isType = !(target.flags & 111551 /* SymbolFlags.Value */);
86941
+ var isType = !(targetFlags & 111551 /* SymbolFlags.Value */);
86856
86942
  if (isType || typeOnlyAlias) {
86857
86943
  switch (node.kind) {
86858
86944
  case 270 /* SyntaxKind.ImportClause */:
@@ -87012,14 +87098,15 @@ var ts;
87012
87098
  if (node.moduleReference.kind !== 280 /* SyntaxKind.ExternalModuleReference */) {
87013
87099
  var target = resolveAlias(getSymbolOfNode(node));
87014
87100
  if (target !== unknownSymbol) {
87015
- if (target.flags & 111551 /* SymbolFlags.Value */) {
87101
+ var targetFlags = getAllSymbolFlags(target);
87102
+ if (targetFlags & 111551 /* SymbolFlags.Value */) {
87016
87103
  // Target is a value symbol, check that it is not hidden by a local declaration with the same name
87017
87104
  var moduleName = ts.getFirstIdentifier(node.moduleReference);
87018
87105
  if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
87019
87106
  error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
87020
87107
  }
87021
87108
  }
87022
- if (target.flags & 788968 /* SymbolFlags.Type */) {
87109
+ if (targetFlags & 788968 /* SymbolFlags.Type */) {
87023
87110
  checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
87024
87111
  }
87025
87112
  }
@@ -87158,7 +87245,7 @@ var ts;
87158
87245
  markExportAsReferenced(node);
87159
87246
  }
87160
87247
  var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
87161
- if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
87248
+ if (!target || getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
87162
87249
  checkExpressionCached(node.propertyName || node.name);
87163
87250
  }
87164
87251
  }
@@ -87205,7 +87292,7 @@ var ts;
87205
87292
  markAliasReferenced(sym, id);
87206
87293
  // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
87207
87294
  var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
87208
- if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
87295
+ if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
87209
87296
  // However if it is a value, we need to check it's being used correctly
87210
87297
  checkExpressionCached(node.expression);
87211
87298
  }
@@ -88527,7 +88614,7 @@ var ts;
88527
88614
  return symbolLinks.exportsSomeValue;
88528
88615
  function isValue(s) {
88529
88616
  s = resolveSymbol(s);
88530
- return s && !!(s.flags & 111551 /* SymbolFlags.Value */);
88617
+ return s && !!(getAllSymbolFlags(s) & 111551 /* SymbolFlags.Value */);
88531
88618
  }
88532
88619
  }
88533
88620
  function isNameOfModuleOrEnumDeclaration(node) {
@@ -88580,7 +88667,7 @@ var ts;
88580
88667
  var symbol = getReferencedValueOrAliasSymbol(node);
88581
88668
  // We should only get the declaration of an alias if there isn't a local value
88582
88669
  // declaration for the symbol
88583
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
88670
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
88584
88671
  return getDeclarationOfAliasSymbol(symbol);
88585
88672
  }
88586
88673
  }
@@ -88668,7 +88755,7 @@ var ts;
88668
88755
  case 273 /* SyntaxKind.ImportSpecifier */:
88669
88756
  case 278 /* SyntaxKind.ExportSpecifier */:
88670
88757
  var symbol = getSymbolOfNode(node);
88671
- return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
88758
+ return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */);
88672
88759
  case 275 /* SyntaxKind.ExportDeclaration */:
88673
88760
  var exportClause = node.exportClause;
88674
88761
  return !!exportClause && (ts.isNamespaceExport(exportClause) ||
@@ -88690,6 +88777,7 @@ var ts;
88690
88777
  return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
88691
88778
  }
88692
88779
  function isAliasResolvedToValue(symbol) {
88780
+ var _a;
88693
88781
  if (!symbol) {
88694
88782
  return false;
88695
88783
  }
@@ -88699,7 +88787,7 @@ var ts;
88699
88787
  }
88700
88788
  // const enums and modules that contain only const enums are not considered values from the emit perspective
88701
88789
  // unless 'preserveConstEnums' option is set to true
88702
- return !!(target.flags & 111551 /* SymbolFlags.Value */) &&
88790
+ return !!(((_a = getAllSymbolFlags(target)) !== null && _a !== void 0 ? _a : -1) & 111551 /* SymbolFlags.Value */) &&
88703
88791
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
88704
88792
  }
88705
88793
  function isConstEnumOrConstEnumOnlyModule(s) {
@@ -88714,7 +88802,7 @@ var ts;
88714
88802
  }
88715
88803
  var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
88716
88804
  if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
88717
- target.flags & 111551 /* SymbolFlags.Value */ &&
88805
+ getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */ &&
88718
88806
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
88719
88807
  // An `export import ... =` of a value symbol is always considered referenced
88720
88808
  return 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.9.0-dev.20220928",
5
+ "version": "4.9.0-dev.20220930",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -89,7 +89,7 @@
89
89
  "ms": "^2.1.3",
90
90
  "node-fetch": "^2.6.7",
91
91
  "source-map-support": "latest",
92
- "typescript": "^4.8.3",
92
+ "typescript": "^4.8.4",
93
93
  "vinyl": "latest",
94
94
  "which": "^2.0.2",
95
95
  "xml2js": "^0.4.23"