Skip to content

Add readonly support #230

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

Closed

Conversation

mattroberts297
Copy link

Because I wanted to enforce some immutability

PS Thanks for the awesome library / tool

Because I wanted to enforce some immutability
@jameswilddev
Copy link

This looks like it would resolve #131, excepting the use of ReadOnlyArray. Do you know if it would also turn { [k: string]: T } into { readonly [k: string]: T}?

@bcherny
Copy link
Owner

bcherny commented Jun 15, 2019

Looks good, but I'd love if you could iterate on this a bit more before we merge it (also, sorry for the delay in getting to this!).

  1. Please rename the option to --readonly.
  2. Could you make sure it also makes index signatures (as @jameswilddev noted), array types, tuple types, and referenced types readonly?
  3. Please also update README.md to document this.

Copy link
Owner

@bcherny bcherny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to take a look once you have a chance to address the above feedback.

@jonaskello
Copy link

I'm also looking for this function, is someone still working on it?

@mattroberts297
Copy link
Author

I stopped working on this PR because I moved away from the language (as opposed to the library) for a time. Thanks for the feedback and apologies for not addressing it.

@codingismy11to7
Copy link

I'm guessing this PR will probably get closed, but just wanted to chime in that I'd additionally expect

export type X = Base & {
  field: type
};

to output as

export type X = Base & Readonly<{
  field: type
}>;

which this code doesn't seem to address

@bcherny
Copy link
Owner

bcherny commented May 15, 2022

#412

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants