WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Bug: return type duplicate infinite amount: | T #2015

@pjonsson

Description

@pjonsson

🐛 Bug Report

  • TypeStat version: 0.8.1
  • TypeScript version: 5.2
  • Node version: 20

Actual Behavior

Grabbing one from the pile here, this isn't the only one, but the rest look similar:

diff --git a/lib/Models/SelectableDimensions/SelectableDimensions.ts b/lib/Models/SelectableDimensions/SelectableDimensions.ts
index b36326626..1747314a8 100644
--- a/lib/Models/SelectableDimensions/SelectableDimensions.ts
+++ b/lib/Models/SelectableDimensions/SelectableDimensions.ts
@@ -19,7 +19,7 @@ export interface EnumDimensionOption<T = string> {
 }

 export interface EnumDimension<T = string> extends Dimension {
-  readonly options?: readonly EnumDimensionOption<T>[];
+  readonly options?: readonly EnumDimensionOption<T>[] | T | T;
   readonly selectedId?: T;
   readonly allowUndefined?: boolean;
   /** If true, then the user can set the value to arbitrary text */

I'm guessing this is related to #1447, but for a different type.

Expected Behavior

I'm not certain that the type on the interface originally is correct because TypeStat has found some similar type issues in other places (relating to promises), so it's quite possible that the interface should have the type EnumDimensionOption<T>[] | T. I expect TypeStat to stop adding | T after the first one is added though.

Is there a way to find the code point that caused TypeStat to add the type? I'm familiar with how Hindley-Milner type inference works, so I realize it might be hard to give a good code point, but a bad code point that at least was involved in constraining the type would still be better than the current "it's somewhere in the source code" black box.

Reproduction

Same as #2014.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: fixersAround how TypeStat fixes code.status: accepting prsPlease, send a pull request to resolve this! 🙏type: bugSomething isn't working :( 🐛

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions