Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug: Enums values passed to a number or string primitive cause infinite | (enum) additions #2024

Closed
3 tasks done
JoshuaKGoldberg opened this issue Nov 30, 2024 · 1 comment · Fixed by #2025
Closed
3 tasks done
Assignees
Labels
fixer: incomplete types status: accepting prs Please, send a pull request to resolve this! 🙏 type: bug Something isn't working :( 🐛

Comments

@JoshuaKGoldberg
Copy link
Owner

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

Given code like this:

enum Value {
    A,
    B,
}

function withValue(value: string) {}

withValue(Value.A);
withValue(Value.B);

Actual

enum Value {
    A,
    B,
}

function withValue(value: string | Value | Value | Value | Value ...) {}

withValue(Value.A);
withValue(Value.B);

Additional Info

Discovered while investigating #2014.

💖

@JoshuaKGoldberg JoshuaKGoldberg added type: bug Something isn't working :( 🐛 status: accepting prs Please, send a pull request to resolve this! 🙏 fixer: incomplete types labels Nov 30, 2024
@JoshuaKGoldberg JoshuaKGoldberg self-assigned this Nov 30, 2024
JoshuaKGoldberg added a commit that referenced this issue Nov 30, 2024
## PR Checklist

- [x] Addresses an existing open issue: fixes #2024
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/TypeStat/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/TypeStat/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

Previously, types collection included both _flags_ (`ts.TypeFlags`
numbers) and the actual _types_ (`ts.Type` objects). I don't remember
why I separated the two. Everything is capturable by _types_, and
`checker.isTypeAssignableTo` only applies on _types_.

This removes the _flags_ and goes with just _types_. Doing so fixes the
bug around enums not being captured (because of bypassing assignability
checking).
Copy link

🎉 This is included in version v0.8.2 🎉

The release is available on:

Cheers! 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixer: incomplete types status: accepting prs Please, send a pull request to resolve this! 🙏 type: bug Something isn't working :( 🐛
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant