typescript 4.7.0-dev.20220329 → 4.7.0-dev.20220330

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
@@ -2644,6 +2644,13 @@ declare namespace ts.server.protocol {
2644
2644
  * `class A { foo }`.
2645
2645
  */
2646
2646
  readonly includeCompletionsWithClassMemberSnippets?: boolean;
2647
+ /**
2648
+ * If enabled, object literal methods will have a method declaration completion entry in addition
2649
+ * to the regular completion entry containing just the method name.
2650
+ * E.g., `const objectLiteral: T = { f| }` could be completed to `const objectLiteral: T = { foo(): void {} }`,
2651
+ * in addition to `const objectLiteral: T = { foo }`.
2652
+ */
2653
+ readonly includeCompletionsWithObjectLiteralMethodSnippets?: boolean;
2647
2654
  readonly allowIncompleteCompletions?: boolean;
2648
2655
  readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative";
2649
2656
  /** 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.20220330";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -39074,26 +39074,10 @@ var ts;
39074
39074
  if (!node) {
39075
39075
  return undefined;
39076
39076
  }
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;
39077
+ if (contextFlags & 4) {
39078
+ return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); });
39095
39079
  }
39096
- return result;
39080
+ return getContextualType(node, contextFlags);
39097
39081
  },
39098
39082
  getContextualTypeForObjectLiteralElement: function (nodeIn) {
39099
39083
  var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
@@ -39113,6 +39097,9 @@ var ts;
39113
39097
  getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
39114
39098
  return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0);
39115
39099
  },
39100
+ getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) {
39101
+ return getResolvedSignatureWorker(call, candidatesOutArray, undefined, 32, editingArgument);
39102
+ },
39116
39103
  getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
39117
39104
  return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16);
39118
39105
  },
@@ -39259,10 +39246,34 @@ var ts;
39259
39246
  getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
39260
39247
  getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
39261
39248
  };
39262
- function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
39249
+ function runWithInferenceBlockedFromSourceNode(node, fn) {
39250
+ var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
39251
+ var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
39252
+ if (containingCall) {
39253
+ var toMarkSkip = node;
39254
+ do {
39255
+ getNodeLinks(toMarkSkip).skipDirectInference = true;
39256
+ toMarkSkip = toMarkSkip.parent;
39257
+ } while (toMarkSkip && toMarkSkip !== containingCall);
39258
+ getNodeLinks(containingCall).resolvedSignature = undefined;
39259
+ }
39260
+ var result = fn();
39261
+ if (containingCall) {
39262
+ var toMarkSkip = node;
39263
+ do {
39264
+ getNodeLinks(toMarkSkip).skipDirectInference = undefined;
39265
+ toMarkSkip = toMarkSkip.parent;
39266
+ } while (toMarkSkip && toMarkSkip !== containingCall);
39267
+ getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
39268
+ }
39269
+ return result;
39270
+ }
39271
+ function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode, editingArgument) {
39263
39272
  var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
39264
39273
  apparentArgumentCount = argumentCount;
39265
- var res = node ? getResolvedSignature(node, candidatesOutArray, checkMode) : undefined;
39274
+ var res = !node ? undefined :
39275
+ editingArgument ? runWithInferenceBlockedFromSourceNode(editingArgument, function () { return getResolvedSignature(node, candidatesOutArray, checkMode); }) :
39276
+ getResolvedSignature(node, candidatesOutArray, checkMode);
39266
39277
  apparentArgumentCount = undefined;
39267
39278
  return res;
39268
39279
  }
@@ -45444,7 +45455,7 @@ var ts;
45444
45455
  return type.flags & (128 | 256) ? "" + type.value : undefined;
45445
45456
  }
45446
45457
  function getTypeForBindingElement(declaration) {
45447
- var checkMode = declaration.dotDotDotToken ? 32 : 0;
45458
+ var checkMode = declaration.dotDotDotToken ? 64 : 0;
45448
45459
  var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
45449
45460
  return parentType && getBindingElementTypeFromParentType(declaration, parentType);
45450
45461
  }
@@ -56885,7 +56896,7 @@ var ts;
56885
56896
  for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
56886
56897
  var targetProp = properties_3[_i];
56887
56898
  var sourceProp = getPropertyOfType(source, targetProp.escapedName);
56888
- if (sourceProp) {
56899
+ if (sourceProp && !ts.some(sourceProp.declarations, hasSkipDirectInferenceFlag)) {
56889
56900
  inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
56890
56901
  }
56891
56902
  }
@@ -59075,7 +59086,7 @@ var ts;
59075
59086
  function hasContextualTypeWithNoGenericTypes(node, checkMode) {
59076
59087
  var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
59077
59088
  !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
59078
- (checkMode && checkMode & 32 ?
59089
+ (checkMode && checkMode & 64 ?
59079
59090
  getContextualType(node, 8)
59080
59091
  : getContextualType(node));
59081
59092
  return contextualType && !isGenericType(contextualType);
@@ -59799,7 +59810,7 @@ var ts;
59799
59810
  var parent = declaration.parent.parent;
59800
59811
  var name = declaration.propertyName || declaration.name;
59801
59812
  var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
59802
- parent.kind !== 203 && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 : 0);
59813
+ parent.kind !== 203 && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 : 0);
59803
59814
  if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
59804
59815
  return undefined;
59805
59816
  if (parent.name.kind === 202) {
@@ -62397,7 +62408,7 @@ var ts;
62397
62408
  }
62398
62409
  for (var i = 0; i < argCount; i++) {
62399
62410
  var arg = args[i];
62400
- if (arg.kind !== 227) {
62411
+ if (arg.kind !== 227 && !(checkMode & 32 && hasSkipDirectInferenceFlag(arg))) {
62401
62412
  var paramType = getTypeAtPosition(signature, i);
62402
62413
  var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
62403
62414
  inferTypes(context.inferences, argType, paramType);
@@ -62978,7 +62989,7 @@ var ts;
62978
62989
  }
62979
62990
  }
62980
62991
  }
62981
- return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
62992
+ return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
62982
62993
  function addImplementationSuccessElaboration(failed, diagnostic) {
62983
62994
  var _a, _b;
62984
62995
  var oldCandidatesForArgumentError = candidatesForArgumentError;
@@ -63069,11 +63080,11 @@ var ts;
63069
63080
  return undefined;
63070
63081
  }
63071
63082
  }
63072
- function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
63083
+ function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray, checkMode) {
63073
63084
  ts.Debug.assert(candidates.length > 0);
63074
63085
  checkNodeDeferred(node);
63075
63086
  return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
63076
- ? pickLongestCandidateSignature(node, candidates, args)
63087
+ ? pickLongestCandidateSignature(node, candidates, args, checkMode)
63077
63088
  : createUnionOfSignaturesForOverloadFailure(candidates);
63078
63089
  }
63079
63090
  function createUnionOfSignaturesForOverloadFailure(candidates) {
@@ -63116,7 +63127,7 @@ var ts;
63116
63127
  function createCombinedSymbolForOverloadFailure(sources, type) {
63117
63128
  return createSymbolWithType(ts.first(sources), type);
63118
63129
  }
63119
- function pickLongestCandidateSignature(node, candidates, args) {
63130
+ function pickLongestCandidateSignature(node, candidates, args, checkMode) {
63120
63131
  var bestIndex = getLongestCandidateIndex(candidates, apparentArgumentCount === undefined ? args.length : apparentArgumentCount);
63121
63132
  var candidate = candidates[bestIndex];
63122
63133
  var typeParameters = candidate.typeParameters;
@@ -63126,7 +63137,7 @@ var ts;
63126
63137
  var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
63127
63138
  var instantiated = typeArgumentNodes
63128
63139
  ? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
63129
- : inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
63140
+ : inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode);
63130
63141
  candidates[bestIndex] = instantiated;
63131
63142
  return instantiated;
63132
63143
  }
@@ -63140,9 +63151,9 @@ var ts;
63140
63151
  }
63141
63152
  return typeArguments;
63142
63153
  }
63143
- function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
63154
+ function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) {
63144
63155
  var inferenceContext = createInferenceContext(typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
63145
- var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 | 8, inferenceContext);
63156
+ var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 | 8, inferenceContext);
63146
63157
  return createSignatureInstantiation(candidate, typeArgumentTypes);
63147
63158
  }
63148
63159
  function getLongestCandidateIndex(candidates, argsCount) {
@@ -68399,7 +68410,7 @@ var ts;
68399
68410
  checkComputedPropertyName(node.propertyName);
68400
68411
  }
68401
68412
  var parent = node.parent.parent;
68402
- var parentCheckMode = node.dotDotDotToken ? 32 : 0;
68413
+ var parentCheckMode = node.dotDotDotToken ? 64 : 0;
68403
68414
  var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
68404
68415
  var name = node.propertyName || node.name;
68405
68416
  if (parentType && !ts.isBindingPattern(name)) {
@@ -96343,6 +96354,13 @@ var ts;
96343
96354
  return "skip";
96344
96355
  }
96345
96356
  break;
96357
+ case 270:
96358
+ case 275:
96359
+ if (node.isTypeOnly) {
96360
+ diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type"));
96361
+ return "skip";
96362
+ }
96363
+ break;
96346
96364
  case 265:
96347
96365
  diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
96348
96366
  return "skip";