eslint-plugin-absolute 0.11.0-beta.0 → 0.11.0-beta.1

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.
Files changed (2) hide show
  1. package/dist/index.js +13 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3653,6 +3653,17 @@ var noRedundantTypeAnnotation = createRule({
3653
3653
  return {};
3654
3654
  }
3655
3655
  const stringify = (type) => tsChecker.typeToString(type, undefined, ts2.TypeFormatFlags.NoTruncation | ts2.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope);
3656
+ const leansOnContextualInference = (initNode) => {
3657
+ const callLike = ts2.isCallExpression(initNode) || ts2.isNewExpression(initNode) ? initNode : null;
3658
+ if (!callLike)
3659
+ return false;
3660
+ if (callLike.typeArguments && callLike.typeArguments.length > 0) {
3661
+ return false;
3662
+ }
3663
+ const calleeType = tsChecker.getTypeAtLocation(callLike.expression);
3664
+ const signatures = ts2.isNewExpression(callLike) ? calleeType.getConstructSignatures() : calleeType.getCallSignatures();
3665
+ return signatures.some((signature) => (signature.getTypeParameters()?.length ?? 0) > 0);
3666
+ };
3656
3667
  return {
3657
3668
  VariableDeclarator(node) {
3658
3669
  if (node.id.type !== "Identifier")
@@ -3670,6 +3681,8 @@ var noRedundantTypeAnnotation = createRule({
3670
3681
  return;
3671
3682
  if (!ts2.isTypeNode(annotationTSNode))
3672
3683
  return;
3684
+ if (leansOnContextualInference(initTSNode))
3685
+ return;
3673
3686
  const annotationType = tsChecker.getTypeFromTypeNode(annotationTSNode);
3674
3687
  const initType = tsChecker.getTypeAtLocation(initTSNode);
3675
3688
  const aliasSymbol = ts2.isTypeReferenceNode(annotationTSNode) ? tsChecker.getSymbolAtLocation(annotationTSNode.typeName) : undefined;
package/package.json CHANGED
@@ -40,5 +40,5 @@
40
40
  "typecheck": "bun run tsc --noEmit"
41
41
  },
42
42
  "type": "module",
43
- "version": "0.11.0-beta.0"
43
+ "version": "0.11.0-beta.1"
44
44
  }