Skip to content
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-type] Support Readonly<T> #51

Closed
ulrichb opened this issue Jul 29, 2019 · 9 comments · Fixed by #480
Closed

[prefer-readonly-type] Support Readonly<T> #51

ulrichb opened this issue Jul 29, 2019 · 9 comments · Fixed by #480
Labels
Accepted This issue or PR has been accepted. Status: In Progress Issue is currently being resolved by a developer. Type: Enhancement Enhancement of the code, not introducing new features.

Comments

@ulrichb
Copy link
Contributor

ulrichb commented Jul 29, 2019

Support the following case (at the moment functional/prefer-readonly-type gets emitted):

type MyType = Readonly<{ a: string, b: number }>;

This is a prerequisite for #32 (which is about a fixer to Readonly<T> if I understand it correctly); but the validation can implemented before.

@RebeccaStevens RebeccaStevens added Type: Enhancement Enhancement of the code, not introducing new features. Up For Grabs labels Jul 30, 2019
@kevinbarabash
Copy link

I'm interested in taking this on.

@RebeccaStevens
Copy link
Collaborator

RebeccaStevens commented Dec 28, 2019

@kevinbarabash it's yours 😄.

Edit: removed the rest of this comment as it was irrelevant to this issue.
Moved it to here: #32 (comment)

@kevinbarabash
Copy link

Thanks. I'll start work on this this weekend.

@RebeccaStevens
Copy link
Collaborator

@kevinbarabash How you going with this?

@kevinbarabash
Copy link

I ended up getting side-tracked by something else and have put my TypeScript development on hold.

@kevinbarabash kevinbarabash removed their assignment Mar 1, 2020
@ColemanGariety
Copy link

+1 for this. Having to put the readonly modifier before every single key decreases readability. And this rule is critical.

@safareli
Copy link

safareli commented May 3, 2020

+1

@adrian-gierakowski
Copy link

Just wanted to point out that https://typescript-eslint.io/rules/prefer-readonly-parameter-types works with Readonly as well as ReadonlyDeep from https://github.com/sindresorhus/type-fest, so maybe we could borrow from it's implementation

@RebeccaStevens
Copy link
Collaborator

@adrian-gierakowski I've actually been working over there helping with that rule. I've also since extracted out the relevant bits and improved upon them in a new lib called is-immutable-type. v5 of this lib (currently in beta) uses that library and resolves this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted This issue or PR has been accepted. Status: In Progress Issue is currently being resolved by a developer. Type: Enhancement Enhancement of the code, not introducing new features.
Projects
None yet
6 participants