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

fix: streamline type collection by removing 'flags' #2025

Merged
merged 2 commits into from
Nov 30, 2024

Conversation

JoshuaKGoldberg
Copy link
Owner

PR Checklist

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

codecov bot commented Nov 30, 2024

Codecov Report

Attention: Patch coverage is 82.60870% with 8 lines in your changes missing coverage. Please review.

Project coverage is 80.04%. Comparing base (0d9c44e) to head (45087d8).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
src/mutations/creators.ts 38.46% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2025      +/-   ##
==========================================
- Coverage   80.25%   80.04%   -0.22%     
==========================================
  Files         172      171       -1     
  Lines       10825    10736      -89     
  Branches     1040     1030      -10     
==========================================
- Hits         8688     8594      -94     
- Misses       2132     2137       +5     
  Partials        5        5              
Flag Coverage Δ
mutation 74.24% <82.60%> (-0.44%) ⬇️
unit 28.87% <17.39%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JoshuaKGoldberg JoshuaKGoldberg merged commit 29822a8 into main Nov 30, 2024
12 of 13 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the streamline-collection-no-flags branch November 30, 2024 15:15
Copy link

🎉 This is included in version v0.8.2 🎉

The release is available on:

Cheers! 📦🚀

// The 'void' type shouldn't be assigned to anything, so we ignore it
if (assignedType.flags === ts.TypeFlags.Void) {
remainingMissingTypes.delete(assignedType);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the next if be converted to an else-if, or does isAssignedTypeMissingFromDeclared need to run for side-effects?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be a good first contribution for you 😄 do you see any buggy behavior from it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My primary concern was efficiency (it always starts with a single if-statement in a loop, but then one more if-statement is added, and then one more, and suddenly the short and fast loop is not so short and fast any longer).

But there's also a readability aspect, with an else-if it's clear that either isAssignedTypeMissingFromDeclared doesn't have any important side-effects, or that things are really intricate and any minor change might break things.

@pjonsson pjonsson mentioned this pull request Nov 30, 2024
3 tasks
JoshuaKGoldberg pushed a commit that referenced this pull request Nov 30, 2024
## PR Checklist

- [ ] Addresses an existing open issue: fixes #000
- [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

Make the case for the void type
mutually exclusive with the other
check in the loop.

Suggested in
#2025 (comment).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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