JoshuaKGoldberg / JoshuaKGoldberg/TypeStat

🚀 Feature: Add (back) type aliasing

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

Description

## 🚀 Feature Request

It's sometimes useful to replace added TypeScript types with other strings. Most commonly, some conversions use a type like `type $AnyTodoFixMeTS49 = any;` instead of `any` to make it clear that the `any` should be fixed up eventually.

### Existing Behavior

TypeStat does not support these kinds of aliases.

### Change Proposal

Let's add in a new option with a name like ... `typeAliases`, perhaps? Maybe it could be a `Record` keying aliases (strings, allowing for stringified regular expressions) to their replacement?

```json
{
"typeAliases": {
"any": "$AnyTodoFixMeTS49",
"/Promise.+/": "Promise$1 /* todo: just use a Promise? */"
}
}
```

### Additional Information

TypeStat actually used to have this! I'd removed the feature in https://github.com/JoshuaKGoldberg/TypeStat/issues/793 (and docs in https://github.com/JoshuaKGoldberg/TypeStat/commit/eedded466a213d851e7494b3636a32753f577d5b) #765 easier. But now that #765 is done, it'd be useful to add this option back.

Thanks @tannerlinsley for reminding me of this!

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.