typescript 4.8.0-dev.20220508 → 4.8.0-dev.20220511

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 CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.8";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220508";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220511";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -5578,6 +5578,7 @@ var ts;
5578
5578
  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."),
5579
5579
  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."),
5580
5580
  Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require: diag(1456, ts.DiagnosticCategory.Error, "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456", "Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`."),
5581
+ Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk: diag(1457, ts.DiagnosticCategory.Message, "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457", "Matched by default include pattern '**/*'"),
5581
5582
  The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
5582
5583
  Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
5583
5584
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
@@ -10664,6 +10665,16 @@ var ts;
10664
10665
  return node.kind === 324 || node.kind === 325 || node.kind === 326;
10665
10666
  }
10666
10667
  ts.isJSDocLinkLike = isJSDocLinkLike;
10668
+ function hasRestParameter(s) {
10669
+ var last = ts.lastOrUndefined(s.parameters);
10670
+ return !!last && isRestParameter(last);
10671
+ }
10672
+ ts.hasRestParameter = hasRestParameter;
10673
+ function isRestParameter(node) {
10674
+ var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
10675
+ return node.dotDotDotToken !== undefined || !!type && type.kind === 318;
10676
+ }
10677
+ ts.isRestParameter = isRestParameter;
10667
10678
  })(ts || (ts = {}));
10668
10679
  var ts;
10669
10680
  (function (ts) {
@@ -13158,16 +13169,6 @@ var ts;
13158
13169
  return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; });
13159
13170
  }
13160
13171
  ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc;
13161
- function hasRestParameter(s) {
13162
- var last = ts.lastOrUndefined(s.parameters);
13163
- return !!last && isRestParameter(last);
13164
- }
13165
- ts.hasRestParameter = hasRestParameter;
13166
- function isRestParameter(node) {
13167
- var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
13168
- return node.dotDotDotToken !== undefined || !!type && type.kind === 318;
13169
- }
13170
- ts.isRestParameter = isRestParameter;
13171
13172
  function hasTypeArguments(node) {
13172
13173
  return !!node.typeArguments;
13173
13174
  }
@@ -27695,6 +27696,9 @@ var ts;
27695
27696
  return 1;
27696
27697
  }
27697
27698
  if (ts.isModifierKind(second) && second !== 131 && lookAhead(nextTokenIsIdentifier)) {
27699
+ if (nextToken() === 127) {
27700
+ return 0;
27701
+ }
27698
27702
  return 1;
27699
27703
  }
27700
27704
  if (!isIdentifier() && second !== 108) {
@@ -33357,7 +33361,7 @@ var ts;
33357
33361
  return undefined;
33358
33362
  if (ts.length(specs) !== 1)
33359
33363
  return specs;
33360
- if (specs[0] === "**/*")
33364
+ if (specs[0] === ts.defaultIncludeSpec)
33361
33365
  return undefined;
33362
33366
  return specs;
33363
33367
  }
@@ -33591,6 +33595,7 @@ var ts;
33591
33595
  function directoryOfCombinedPath(fileName, basePath) {
33592
33596
  return ts.getDirectoryPath(ts.getNormalizedAbsolutePath(fileName, basePath));
33593
33597
  }
33598
+ ts.defaultIncludeSpec = "**/*";
33594
33599
  function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache) {
33595
33600
  if (existingOptions === void 0) { existingOptions = {}; }
33596
33601
  if (resolutionStack === void 0) { resolutionStack = []; }
@@ -33643,6 +33648,7 @@ var ts;
33643
33648
  }
33644
33649
  var includeSpecs = toPropValue(getSpecsFromRaw("include"));
33645
33650
  var excludeOfRaw = getSpecsFromRaw("exclude");
33651
+ var isDefaultIncludeSpec = false;
33646
33652
  var excludeSpecs = toPropValue(excludeOfRaw);
33647
33653
  if (excludeOfRaw === "no-prop" && raw.compilerOptions) {
33648
33654
  var outDir = raw.compilerOptions.outDir;
@@ -33652,7 +33658,8 @@ var ts;
33652
33658
  }
33653
33659
  }
33654
33660
  if (filesSpecs === undefined && includeSpecs === undefined) {
33655
- includeSpecs = ["**/*"];
33661
+ includeSpecs = [ts.defaultIncludeSpec];
33662
+ isDefaultIncludeSpec = true;
33656
33663
  }
33657
33664
  var validatedIncludeSpecs, validatedExcludeSpecs;
33658
33665
  if (includeSpecs) {
@@ -33669,6 +33676,7 @@ var ts;
33669
33676
  validatedIncludeSpecs: validatedIncludeSpecs,
33670
33677
  validatedExcludeSpecs: validatedExcludeSpecs,
33671
33678
  pathPatterns: undefined,
33679
+ isDefaultIncludeSpec: isDefaultIncludeSpec,
33672
33680
  };
33673
33681
  }
33674
33682
  function getFileNames(basePath) {
@@ -54508,6 +54516,18 @@ var ts;
54508
54516
  }
54509
54517
  }
54510
54518
  }
54519
+ if (relation === comparableRelation && sourceFlags & 262144) {
54520
+ var constraint = getConstraintOfTypeParameter(source);
54521
+ if (constraint && hasNonCircularBaseConstraint(source)) {
54522
+ while (constraint && constraint.flags & 262144) {
54523
+ if (result = isRelatedTo(constraint, target, 1, false)) {
54524
+ return result;
54525
+ }
54526
+ constraint = getConstraintOfTypeParameter(constraint);
54527
+ }
54528
+ }
54529
+ return 0;
54530
+ }
54511
54531
  }
54512
54532
  else if (targetFlags & 4194304) {
54513
54533
  var targetType_1 = target.type;
@@ -54658,18 +54678,18 @@ var ts;
54658
54678
  }
54659
54679
  if (sourceFlags & 8650752) {
54660
54680
  if (!(sourceFlags & 8388608 && targetFlags & 8388608)) {
54661
- var constraint = getConstraintOfType(source);
54662
- if (!constraint || (sourceFlags & 262144 && constraint.flags & 1)) {
54681
+ var constraint = getConstraintOfType(source) || unknownType;
54682
+ if (!getConstraintOfType(source) || (sourceFlags & 262144 && constraint.flags & 1)) {
54663
54683
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864), 3)) {
54664
54684
  resetErrorInfo(saveErrorInfo);
54665
54685
  return result;
54666
54686
  }
54667
54687
  }
54668
- else if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
54688
+ if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
54669
54689
  resetErrorInfo(saveErrorInfo);
54670
54690
  return result;
54671
54691
  }
54672
- else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(targetFlags & sourceFlags & 262144), undefined, intersectionState)) {
54692
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144), undefined, intersectionState)) {
54673
54693
  resetErrorInfo(saveErrorInfo);
54674
54694
  return result;
54675
54695
  }
@@ -60523,7 +60543,25 @@ var ts;
60523
60543
  }
60524
60544
  function getTypeOfPropertyOfContextualType(type, name, nameType) {
60525
60545
  return mapType(type, function (t) {
60526
- var _a;
60546
+ if (t.flags & 2097152) {
60547
+ var intersection = t;
60548
+ var newTypes = ts.mapDefined(intersection.types, getTypeOfConcretePropertyOfContextualType);
60549
+ if (newTypes.length > 0) {
60550
+ return getIntersectionType(newTypes);
60551
+ }
60552
+ newTypes = ts.mapDefined(intersection.types, getTypeOfApplicableIndexInfoOfContextualType);
60553
+ if (newTypes.length > 0) {
60554
+ return getIntersectionType(newTypes);
60555
+ }
60556
+ return undefined;
60557
+ }
60558
+ var concretePropertyType = getTypeOfConcretePropertyOfContextualType(t);
60559
+ if (concretePropertyType) {
60560
+ return concretePropertyType;
60561
+ }
60562
+ return getTypeOfApplicableIndexInfoOfContextualType(t);
60563
+ }, true);
60564
+ function getTypeOfConcretePropertyOfContextualType(t) {
60527
60565
  if (isGenericMappedType(t) && !t.declaration.nameType) {
60528
60566
  var constraint = getConstraintTypeFromMappedType(t);
60529
60567
  var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
@@ -60531,8 +60569,9 @@ var ts;
60531
60569
  if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
60532
60570
  return substituteIndexedMappedType(t, propertyNameType);
60533
60571
  }
60572
+ return undefined;
60534
60573
  }
60535
- else if (t.flags & 3670016) {
60574
+ if (t.flags & 3670016) {
60536
60575
  var prop = getPropertyOfType(t, name);
60537
60576
  if (prop) {
60538
60577
  return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
@@ -60543,10 +60582,16 @@ var ts;
60543
60582
  return restType;
60544
60583
  }
60545
60584
  }
60546
- return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
60547
60585
  }
60548
60586
  return undefined;
60549
- }, true);
60587
+ }
60588
+ function getTypeOfApplicableIndexInfoOfContextualType(t) {
60589
+ var _a;
60590
+ if (!(t.flags & 3670016)) {
60591
+ return undefined;
60592
+ }
60593
+ return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
60594
+ }
60550
60595
  }
60551
60596
  function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
60552
60597
  ts.Debug.assert(ts.isObjectLiteralMethod(node));
@@ -67924,7 +67969,7 @@ var ts;
67924
67969
  var promisedType = getPromisedTypeOfPromise(type, errorNode);
67925
67970
  return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
67926
67971
  }
67927
- function getPromisedTypeOfPromise(type, errorNode) {
67972
+ function getPromisedTypeOfPromise(type, errorNode, thisTypeForErrorOut) {
67928
67973
  if (isTypeAny(type)) {
67929
67974
  return undefined;
67930
67975
  }
@@ -67949,7 +67994,29 @@ var ts;
67949
67994
  }
67950
67995
  return undefined;
67951
67996
  }
67952
- var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152);
67997
+ var thisTypeForError;
67998
+ var candidates;
67999
+ for (var _i = 0, thenSignatures_1 = thenSignatures; _i < thenSignatures_1.length; _i++) {
68000
+ var thenSignature = thenSignatures_1[_i];
68001
+ var thisType = getThisTypeOfSignature(thenSignature);
68002
+ if (thisType && thisType !== voidType && !isTypeRelatedTo(type, thisType, subtypeRelation)) {
68003
+ thisTypeForError = thisType;
68004
+ }
68005
+ else {
68006
+ candidates = ts.append(candidates, thenSignature);
68007
+ }
68008
+ }
68009
+ if (!candidates) {
68010
+ ts.Debug.assertIsDefined(thisTypeForError);
68011
+ if (thisTypeForErrorOut) {
68012
+ thisTypeForErrorOut.value = thisTypeForError;
68013
+ }
68014
+ if (errorNode) {
68015
+ error(errorNode, ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1, typeToString(type), typeToString(thisTypeForError));
68016
+ }
68017
+ return undefined;
68018
+ }
68019
+ var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152);
67953
68020
  if (isTypeAny(onfulfilledParameterType)) {
67954
68021
  return undefined;
67955
68022
  }
@@ -68026,7 +68093,8 @@ var ts;
68026
68093
  var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias;
68027
68094
  return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper);
68028
68095
  }
68029
- var promisedType = getPromisedTypeOfPromise(type);
68096
+ var thisTypeForErrorOut = { value: undefined };
68097
+ var promisedType = getPromisedTypeOfPromise(type, undefined, thisTypeForErrorOut);
68030
68098
  if (promisedType) {
68031
68099
  if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) {
68032
68100
  if (errorNode) {
@@ -68045,7 +68113,12 @@ var ts;
68045
68113
  if (isThenableType(type)) {
68046
68114
  if (errorNode) {
68047
68115
  ts.Debug.assertIsDefined(diagnosticMessage);
68048
- error(errorNode, diagnosticMessage, arg0);
68116
+ var chain = void 0;
68117
+ if (thisTypeForErrorOut.value) {
68118
+ chain = ts.chainDiagnosticMessages(chain, ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1, typeToString(type), typeToString(thisTypeForErrorOut.value));
68119
+ }
68120
+ chain = ts.chainDiagnosticMessages(chain, diagnosticMessage, arg0);
68121
+ diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, chain));
68049
68122
  }
68050
68123
  return undefined;
68051
68124
  }
@@ -98108,7 +98181,7 @@ var ts;
98108
98181
  break;
98109
98182
  }
98110
98183
  var matchedByInclude = ts.getMatchedIncludeSpec(program, fileName);
98111
- if (!matchedByInclude)
98184
+ if (!matchedByInclude || !ts.isString(matchedByInclude))
98112
98185
  return undefined;
98113
98186
  configFileNode = ts.getTsConfigPropArrayElementValue(options.configFile, "include", matchedByInclude);
98114
98187
  message = ts.Diagnostics.File_is_matched_by_include_pattern_specified_here;
@@ -101158,6 +101231,8 @@ var ts;
101158
101231
  if (ts.fileExtensionIsOneOf(fileName, [".json", ".mjs", ".cjs"]))
101159
101232
  return fileName;
101160
101233
  var noExtension = ts.removeFileExtension(fileName);
101234
+ if (fileName === noExtension)
101235
+ return fileName;
101161
101236
  if (ts.fileExtensionIsOneOf(fileName, [".d.mts", ".mts", ".d.cts", ".cts"]))
101162
101237
  return noExtension + getJSExtensionForFile(fileName, options);
101163
101238
  switch (ending) {
@@ -101428,6 +101503,8 @@ var ts;
101428
101503
  var configFile = program.getCompilerOptions().configFile;
101429
101504
  if (!((_a = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _a === void 0 ? void 0 : _a.validatedIncludeSpecs))
101430
101505
  return undefined;
101506
+ if (configFile.configFileSpecs.isDefaultIncludeSpec)
101507
+ return true;
101431
101508
  var isJsonFile = ts.fileExtensionIs(fileName, ".json");
101432
101509
  var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory()));
101433
101510
  var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames();
@@ -101492,9 +101569,11 @@ var ts;
101492
101569
  if (matchedByFiles)
101493
101570
  return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Part_of_files_list_in_tsconfig_json);
101494
101571
  var matchedByInclude = getMatchedIncludeSpec(program, fileName);
101495
- return matchedByInclude ?
101572
+ return ts.isString(matchedByInclude) ?
101496
101573
  ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Matched_by_include_pattern_0_in_1, matchedByInclude, toFileName(options.configFile, fileNameConvertor)) :
101497
- ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Root_file_specified_for_compilation);
101574
+ ts.chainDiagnosticMessages(undefined, matchedByInclude ?
101575
+ ts.Diagnostics.Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk :
101576
+ ts.Diagnostics.Root_file_specified_for_compilation);
101498
101577
  case ts.FileIncludeKind.SourceFromProjectReference:
101499
101578
  case ts.FileIncludeKind.OutputFromProjectReference:
101500
101579
  var isOutput = reason.kind === ts.FileIncludeKind.OutputFromProjectReference;