JoshuaKGoldberg / JoshuaKGoldberg/TypeStat

Bug: return type duplicate infinite amount: | T

Open
#2,015 3 comments 0 reactions 0 assignees View on GitHub
area: fixers status: accepting prs type: bug
Dominant language
TypeScript
Stars
2.3k
Forks
47
Avg merge
15h 55m
Merged PRs (30d)
21

Description

### 🐛 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:

```patch
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 {
}

export interface EnumDimension extends Dimension {
- readonly options?: readonly EnumDimensionOption[];
+ readonly options?: readonly EnumDimensionOption[] | 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`. 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.