typescript 4.7.0-dev.20220329 → 4.7.0-dev.20220401

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 CHANGED
@@ -1723,6 +1723,10 @@ declare namespace ts.server.protocol {
1723
1723
  * Human-readable description of the `source`.
1724
1724
  */
1725
1725
  sourceDisplay?: SymbolDisplayPart[];
1726
+ /**
1727
+ * Additional details for the label.
1728
+ */
1729
+ labelDetails?: CompletionEntryLabelDetails;
1726
1730
  /**
1727
1731
  * If true, this completion should be highlighted as recommended. There will only be one of these.
1728
1732
  * This will be set when we know the user should write an expression with a certain type and that type is an enum or constructable class.
@@ -1751,6 +1755,20 @@ declare namespace ts.server.protocol {
1751
1755
  */
1752
1756
  data?: unknown;
1753
1757
  }
1758
+ interface CompletionEntryLabelDetails {
1759
+ /**
1760
+ * An optional string which is rendered less prominently directly after
1761
+ * {@link CompletionEntry.name name}, without any spacing. Should be
1762
+ * used for function signatures or type annotations.
1763
+ */
1764
+ detail?: string;
1765
+ /**
1766
+ * An optional string which is rendered less prominently after
1767
+ * {@link CompletionEntryLabelDetails.detail}. Should be used for fully qualified
1768
+ * names or file path.
1769
+ */
1770
+ description?: string;
1771
+ }
1754
1772
  /**
1755
1773
  * Additional completion entry details, available on demand
1756
1774
  */
@@ -2644,6 +2662,18 @@ declare namespace ts.server.protocol {
2644
2662
  * `class A { foo }`.
2645
2663
  */
2646
2664
  readonly includeCompletionsWithClassMemberSnippets?: boolean;
2665
+ /**
2666
+ * If enabled, object literal methods will have a method declaration completion entry in addition
2667
+ * to the regular completion entry containing just the method name.
2668
+ * E.g., `const objectLiteral: T = { f| }` could be completed to `const objectLiteral: T = { foo(): void {} }`,
2669
+ * in addition to `const objectLiteral: T = { foo }`.
2670
+ */
2671
+ readonly includeCompletionsWithObjectLiteralMethodSnippets?: boolean;
2672
+ /**
2673
+ * Indicates whether {@link CompletionEntry.labelDetails completion entry label details} are supported.
2674
+ * If not, contents of `labelDetails` may be included in the {@link CompletionEntry.name} property.
2675
+ */
2676
+ readonly useLabelDetailsInCompletionEntries?: boolean;
2647
2677
  readonly allowIncompleteCompletions?: boolean;
2648
2678
  readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative";
2649
2679
  /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */
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.7";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220329";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220401";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -6680,6 +6680,7 @@ var ts;
6680
6680
  An_expanded_version_of_this_information_showing_all_possible_compiler_options: diag(6928, ts.DiagnosticCategory.Message, "An_expanded_version_of_this_information_showing_all_possible_compiler_options_6928", "An expanded version of this information, showing all possible compiler options"),
6681
6681
  Compiles_the_current_project_with_additional_settings: diag(6929, ts.DiagnosticCategory.Message, "Compiles_the_current_project_with_additional_settings_6929", "Compiles the current project, with additional settings."),
6682
6682
  true_for_ES2022_and_above_including_ESNext: diag(6930, ts.DiagnosticCategory.Message, "true_for_ES2022_and_above_including_ESNext_6930", "`true` for ES2022 and above, including ESNext."),
6683
+ List_of_file_name_suffixes_to_search_when_resolving_a_module: diag(6931, ts.DiagnosticCategory.Error, "List_of_file_name_suffixes_to_search_when_resolving_a_module_6931", "List of file name suffixes to search when resolving a module."),
6683
6684
  Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."),
6684
6685
  Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."),
6685
6686
  Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."),
@@ -32051,6 +32052,18 @@ var ts;
32051
32052
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
32052
32053
  defaultValueDescription: false,
32053
32054
  },
32055
+ {
32056
+ name: "moduleSuffixes",
32057
+ type: "list",
32058
+ element: {
32059
+ name: "suffix",
32060
+ type: "string",
32061
+ },
32062
+ listPreserveFalsyValues: true,
32063
+ affectsModuleResolution: true,
32064
+ category: ts.Diagnostics.Modules,
32065
+ description: ts.Diagnostics.List_of_file_name_suffixes_to_search_when_resolving_a_module,
32066
+ },
32054
32067
  {
32055
32068
  name: "sourceRoot",
32056
32069
  type: "string",
@@ -33806,7 +33819,7 @@ var ts;
33806
33819
  if (option.type === "list") {
33807
33820
  var listOption_1 = option;
33808
33821
  if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) {
33809
- return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; });
33822
+ return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return listOption_1.listPreserveFalsyValues ? true : !!v; });
33810
33823
  }
33811
33824
  return value;
33812
33825
  }
@@ -33847,7 +33860,7 @@ var ts;
33847
33860
  }
33848
33861
  }
33849
33862
  function convertJsonOptionOfListType(option, values, basePath, errors) {
33850
- return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; });
33863
+ return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return option.listPreserveFalsyValues ? true : !!v; });
33851
33864
  }
33852
33865
  var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/;
33853
33866
  var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;
@@ -35180,6 +35193,15 @@ var ts;
35180
35193
  }
35181
35194
  }
35182
35195
  function tryFile(fileName, onlyRecordFailures, state) {
35196
+ var _a, _b;
35197
+ if (!((_a = state.compilerOptions.moduleSuffixes) === null || _a === void 0 ? void 0 : _a.length)) {
35198
+ return tryFileLookup(fileName, onlyRecordFailures, state);
35199
+ }
35200
+ var ext = (_b = ts.tryGetExtensionFromPath(fileName)) !== null && _b !== void 0 ? _b : "";
35201
+ var fileNameNoExtension = ext ? ts.removeExtension(fileName, ext) : fileName;
35202
+ return ts.forEach(state.compilerOptions.moduleSuffixes, function (suffix) { return tryFileLookup(fileNameNoExtension + suffix + ext, onlyRecordFailures, state); });
35203
+ }
35204
+ function tryFileLookup(fileName, onlyRecordFailures, state) {
35183
35205
  if (!onlyRecordFailures) {
35184
35206
  if (state.host.fileExists(fileName)) {
35185
35207
  if (state.traceEnabled) {
@@ -39074,26 +39096,10 @@ var ts;
39074
39096
  if (!node) {
39075
39097
  return undefined;
39076
39098
  }
39077
- var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
39078
- var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
39079
- if (contextFlags & 4 && containingCall) {
39080
- var toMarkSkip = node;
39081
- do {
39082
- getNodeLinks(toMarkSkip).skipDirectInference = true;
39083
- toMarkSkip = toMarkSkip.parent;
39084
- } while (toMarkSkip && toMarkSkip !== containingCall);
39085
- getNodeLinks(containingCall).resolvedSignature = undefined;
39086
- }
39087
- var result = getContextualType(node, contextFlags);
39088
- if (contextFlags & 4 && containingCall) {
39089
- var toMarkSkip = node;
39090
- do {
39091
- getNodeLinks(toMarkSkip).skipDirectInference = undefined;
39092
- toMarkSkip = toMarkSkip.parent;
39093
- } while (toMarkSkip && toMarkSkip !== containingCall);
39094
- getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
39099
+ if (contextFlags & 4) {
39100
+ return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); });
39095
39101
  }
39096
- return result;
39102
+ return getContextualType(node, contextFlags);
39097
39103
  },
39098
39104
  getContextualTypeForObjectLiteralElement: function (nodeIn) {
39099
39105
  var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
@@ -39113,6 +39119,9 @@ var ts;
39113
39119
  getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
39114
39120
  return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0);
39115
39121
  },
39122
+ getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) {
39123
+ return getResolvedSignatureWorker(call, candidatesOutArray, undefined, 32, editingArgument);
39124
+ },
39116
39125
  getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
39117
39126
  return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16);
39118
39127
  },
@@ -39259,10 +39268,34 @@ var ts;
39259
39268
  getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
39260
39269
  getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
39261
39270
  };
39262
- function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
39271
+ function runWithInferenceBlockedFromSourceNode(node, fn) {
39272
+ var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
39273
+ var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
39274
+ if (containingCall) {
39275
+ var toMarkSkip = node;
39276
+ do {
39277
+ getNodeLinks(toMarkSkip).skipDirectInference = true;
39278
+ toMarkSkip = toMarkSkip.parent;
39279
+ } while (toMarkSkip && toMarkSkip !== containingCall);
39280
+ getNodeLinks(containingCall).resolvedSignature = undefined;
39281
+ }
39282
+ var result = fn();
39283
+ if (containingCall) {
39284
+ var toMarkSkip = node;
39285
+ do {
39286
+ getNodeLinks(toMarkSkip).skipDirectInference = undefined;
39287
+ toMarkSkip = toMarkSkip.parent;
39288
+ } while (toMarkSkip && toMarkSkip !== containingCall);
39289
+ getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
39290
+ }
39291
+ return result;
39292
+ }
39293
+ function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode, editingArgument) {
39263
39294
  var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
39264
39295
  apparentArgumentCount = argumentCount;
39265
- var res = node ? getResolvedSignature(node, candidatesOutArray, checkMode) : undefined;
39296
+ var res = !node ? undefined :
39297
+ editingArgument ? runWithInferenceBlockedFromSourceNode(editingArgument, function () { return getResolvedSignature(node, candidatesOutArray, checkMode); }) :
39298
+ getResolvedSignature(node, candidatesOutArray, checkMode);
39266
39299
  apparentArgumentCount = undefined;
39267
39300
  return res;
39268
39301
  }
@@ -42898,7 +42931,13 @@ var ts;
42898
42931
  if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) {
42899
42932
  return node;
42900
42933
  }
42901
- return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext)), node);
42934
+ return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext, deepCloneOrReuseNodes)), node);
42935
+ }
42936
+ function deepCloneOrReuseNodes(nodes, visitor, test, start, count) {
42937
+ if (nodes && nodes.length === 0) {
42938
+ return ts.setTextRange(ts.factory.createNodeArray(undefined, nodes.hasTrailingComma), nodes);
42939
+ }
42940
+ return ts.visitNodes(nodes, visitor, test, start, count);
42902
42941
  }
42903
42942
  }
42904
42943
  function createTypeNodeFromObjectType(type) {
@@ -45444,7 +45483,7 @@ var ts;
45444
45483
  return type.flags & (128 | 256) ? "" + type.value : undefined;
45445
45484
  }
45446
45485
  function getTypeForBindingElement(declaration) {
45447
- var checkMode = declaration.dotDotDotToken ? 32 : 0;
45486
+ var checkMode = declaration.dotDotDotToken ? 64 : 0;
45448
45487
  var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
45449
45488
  return parentType && getBindingElementTypeFromParentType(declaration, parentType);
45450
45489
  }
@@ -56885,7 +56924,7 @@ var ts;
56885
56924
  for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
56886
56925
  var targetProp = properties_3[_i];
56887
56926
  var sourceProp = getPropertyOfType(source, targetProp.escapedName);
56888
- if (sourceProp) {
56927
+ if (sourceProp && !ts.some(sourceProp.declarations, hasSkipDirectInferenceFlag)) {
56889
56928
  inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
56890
56929
  }
56891
56930
  }
@@ -59075,7 +59114,7 @@ var ts;
59075
59114
  function hasContextualTypeWithNoGenericTypes(node, checkMode) {
59076
59115
  var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
59077
59116
  !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
59078
- (checkMode && checkMode & 32 ?
59117
+ (checkMode && checkMode & 64 ?
59079
59118
  getContextualType(node, 8)
59080
59119
  : getContextualType(node));
59081
59120
  return contextualType && !isGenericType(contextualType);
@@ -59143,7 +59182,7 @@ var ts;
59143
59182
  if (func.parameters.length >= 2 && isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
59144
59183
  var contextualSignature = getContextualSignature(func);
59145
59184
  if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) {
59146
- var restType = getTypeOfSymbol(contextualSignature.parameters[0]);
59185
+ var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0]));
59147
59186
  if (restType.flags & 1048576 && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) {
59148
59187
  var narrowedType = getFlowTypeOfReference(func, restType, restType, undefined, location.flowNode);
59149
59188
  var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0);
@@ -59799,7 +59838,7 @@ var ts;
59799
59838
  var parent = declaration.parent.parent;
59800
59839
  var name = declaration.propertyName || declaration.name;
59801
59840
  var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
59802
- parent.kind !== 203 && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 : 0);
59841
+ parent.kind !== 203 && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 : 0);
59803
59842
  if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
59804
59843
  return undefined;
59805
59844
  if (parent.name.kind === 202) {
@@ -60224,7 +60263,10 @@ var ts;
60224
60263
  return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
60225
60264
  }
60226
60265
  if (inferenceContext.returnMapper) {
60227
- return instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
60266
+ var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
60267
+ return type.flags & 1048576 && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
60268
+ filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
60269
+ type;
60228
60270
  }
60229
60271
  }
60230
60272
  }
@@ -62397,7 +62439,7 @@ var ts;
62397
62439
  }
62398
62440
  for (var i = 0; i < argCount; i++) {
62399
62441
  var arg = args[i];
62400
- if (arg.kind !== 227) {
62442
+ if (arg.kind !== 227 && !(checkMode & 32 && hasSkipDirectInferenceFlag(arg))) {
62401
62443
  var paramType = getTypeAtPosition(signature, i);
62402
62444
  var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
62403
62445
  inferTypes(context.inferences, argType, paramType);
@@ -62978,7 +63020,7 @@ var ts;
62978
63020
  }
62979
63021
  }
62980
63022
  }
62981
- return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
63023
+ return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
62982
63024
  function addImplementationSuccessElaboration(failed, diagnostic) {
62983
63025
  var _a, _b;
62984
63026
  var oldCandidatesForArgumentError = candidatesForArgumentError;
@@ -63069,11 +63111,11 @@ var ts;
63069
63111
  return undefined;
63070
63112
  }
63071
63113
  }
63072
- function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
63114
+ function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray, checkMode) {
63073
63115
  ts.Debug.assert(candidates.length > 0);
63074
63116
  checkNodeDeferred(node);
63075
63117
  return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
63076
- ? pickLongestCandidateSignature(node, candidates, args)
63118
+ ? pickLongestCandidateSignature(node, candidates, args, checkMode)
63077
63119
  : createUnionOfSignaturesForOverloadFailure(candidates);
63078
63120
  }
63079
63121
  function createUnionOfSignaturesForOverloadFailure(candidates) {
@@ -63116,7 +63158,7 @@ var ts;
63116
63158
  function createCombinedSymbolForOverloadFailure(sources, type) {
63117
63159
  return createSymbolWithType(ts.first(sources), type);
63118
63160
  }
63119
- function pickLongestCandidateSignature(node, candidates, args) {
63161
+ function pickLongestCandidateSignature(node, candidates, args, checkMode) {
63120
63162
  var bestIndex = getLongestCandidateIndex(candidates, apparentArgumentCount === undefined ? args.length : apparentArgumentCount);
63121
63163
  var candidate = candidates[bestIndex];
63122
63164
  var typeParameters = candidate.typeParameters;
@@ -63126,7 +63168,7 @@ var ts;
63126
63168
  var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
63127
63169
  var instantiated = typeArgumentNodes
63128
63170
  ? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
63129
- : inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
63171
+ : inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode);
63130
63172
  candidates[bestIndex] = instantiated;
63131
63173
  return instantiated;
63132
63174
  }
@@ -63140,9 +63182,9 @@ var ts;
63140
63182
  }
63141
63183
  return typeArguments;
63142
63184
  }
63143
- function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
63185
+ function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) {
63144
63186
  var inferenceContext = createInferenceContext(typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
63145
- var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 | 8, inferenceContext);
63187
+ var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 | 8, inferenceContext);
63146
63188
  return createSignatureInstantiation(candidate, typeArgumentTypes);
63147
63189
  }
63148
63190
  function getLongestCandidateIndex(candidates, argsCount) {
@@ -68399,7 +68441,7 @@ var ts;
68399
68441
  checkComputedPropertyName(node.propertyName);
68400
68442
  }
68401
68443
  var parent = node.parent.parent;
68402
- var parentCheckMode = node.dotDotDotToken ? 32 : 0;
68444
+ var parentCheckMode = node.dotDotDotToken ? 64 : 0;
68403
68445
  var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
68404
68446
  var name = node.propertyName || node.name;
68405
68447
  if (parentType && !ts.isBindingPattern(name)) {
@@ -91370,6 +91412,7 @@ var ts;
91370
91412
  writeLine();
91371
91413
  decreaseIndent();
91372
91414
  }
91415
+ emitList(node, node.members, 2);
91373
91416
  writePunctuation("}");
91374
91417
  }
91375
91418
  function emitLiteralType(node) {
@@ -96343,6 +96386,13 @@ var ts;
96343
96386
  return "skip";
96344
96387
  }
96345
96388
  break;
96389
+ case 270:
96390
+ case 275:
96391
+ if (node.isTypeOnly) {
96392
+ diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type"));
96393
+ return "skip";
96394
+ }
96395
+ break;
96346
96396
  case 265:
96347
96397
  diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
96348
96398
  return "skip";