-
Notifications
You must be signed in to change notification settings - Fork 14
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
Prefer ReadOnly<T> over readonly keyword #58
Comments
So if I understand you are proposing to use:
Or perhaps:
The second option would not give an interface but instead a type I think. Is there a shorter way to write it and still use an interface? |
I actually prefer types over interfaces in my code, so I'm not very familiar with how this would work on interfaces. I'm not sure if there's a way to create mapped interfaces (a la mapped types). Maybe it would make sense to use this rule only for types? |
Yes, I think making a new rule that only apply for types would make the most sense. Something like So the rule would check for type alias declarations ( So it would warn for this case:
But ignore this case:
Is there more cases we need to check for? |
type Identity<T> = T;
export interface Bar extends Identity<{foo: string}> {} should also be check, no? |
I think this looks pretty readable. At least when there are a lot of properties. Compare to how it currently looks:
|
Using
Readonly<T>
is much more readable than marking every property asreadonly
.The text was updated successfully, but these errors were encountered: