You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the problem is here with this logic. It's not safe to say that you can remove types always from const. It's fine for primitive types like string, number or boolean. But for arrays, maps or sets it may not be safe.
constgetNoInferableTypeVariableDeclarationMutation=(node: InferableVariableDeclaration,request: FileMutationsRequest,)=>{if(// `const` variables should always have their declarations removedtsutils.isNodeFlagSet(node.parent,ts.NodeFlags.Const)||// `let` variables should have only uninformative declarations removeddeclaredInitializedTypeNodeIsRedundant(request,node.type,node.initializer)){returncreateTypeRemovalMutation(request,node);}returnundefined;};
The text was updated successfully, but these errors were encountered:
JoshuaKGoldberg
changed the title
🐛 Bug: noInferableTypes removes types where it's not safe
🐛 Bug: noInferableTypes removes types from consts where it's not safe
Apr 1, 2024
<!-- 👋 Hi, thanks for sending a PR to TypeStat! 💖.
Please fill out all fields below and make sure each item is true and [x]
checked.
Otherwise we may not be able to review your PR. -->
## PR Checklist
- [x] Addresses an existing open issue: fixes#1498
- [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
<!-- Description of what is changed and how the code change does that.
-->
It's not safe to remove type from const always. I think the mutation
tests agree with me. Some things are marked as "non-inferable" but still
their types were removed.
Co-authored-by: JoshuaKGoldberg <JoshuaKGoldberg>
Bug Report Checklist
main
branch of the repository.Expected
Keep there types
Actual
This is the current output
Additional Info
Continuing dogfooding this repo to TypeStat
typestat.json
I think the problem is here with this logic. It's not safe to say that you can remove types always from
const
. It's fine for primitive types like string, number or boolean. But for arrays, maps or sets it may not be safe.The text was updated successfully, but these errors were encountered: