-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: streamline type collection by removing 'flags' (#2025)
## 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).
- Loading branch information
1 parent
dde3e63
commit 29822a8
Showing
12 changed files
with
170 additions
and
157 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,15 @@ | ||
import ts from "typescript"; | ||
|
||
import { isNotUndefined, uniquify } from "../../shared/arrays.js"; | ||
import { uniquify } from "../../shared/arrays.js"; | ||
import { FileMutationsRequest } from "../../shared/fileMutator.js"; | ||
import { getApplicableTypeAliases } from "./aliases.js"; | ||
|
||
export const joinIntoType = ( | ||
flags: ReadonlySet<ts.TypeFlags>, | ||
types: ReadonlySet<ts.Type>, | ||
request: FileMutationsRequest, | ||
) => { | ||
const alias = getApplicableTypeAliases(request); | ||
|
||
return uniquify( | ||
...Array.from(types) | ||
.map((type) => request.services.printers.type(type)) | ||
.map((type) => (type.includes("=>") ? `(${type})` : type)), | ||
...Array.from(flags) | ||
.map((flag) => alias.get(flag)) | ||
.filter(isNotUndefined), | ||
).join(" | "); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.