Closed
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Link to the rule's documentation
https://typescript-eslint.io/rules/consistent-type-assertions/
Description
With the objectLiteralTypeAssertions
option turned on, we can suggest code changes to either swap to a type annotation or to use satisfies.
Since these both change TypeScript's behaviour, I thought it would be better to have them as suggestions instead of autofixes.
Fail
const x = { ... } as T;
Pass
const x: T = { ... }; // autofix for variable declarators
const x = { ... } satisfies T; // autofix for TypeScript 4.9+
Additional Info
Happy to open a PR. I've previously implemented this in a Microsoft repo and would like to bring it upstream.