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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible integration with type-fest ReadonlyDeep #350

Closed
rodrigofariow opened this issue Mar 31, 2022 · 3 comments
Closed

Possible integration with type-fest ReadonlyDeep #350

rodrigofariow opened this issue Mar 31, 2022 · 3 comments
Labels
Status: Triage This issue needs to be triaged. Type: Idea Marks an idea, which might be accepted and implemented.

Comments

@rodrigofariow
Copy link

rodrigofariow commented Mar 31, 2022

Hey there!

First of all, I would like to say that this plugin is super awesome and I'm hoping I can use it at work 馃

At work, we make usage of type-fest, in particular ReadonlyDeep utility type.
I would like to know if the maintainers would consider a possible integration (with functional/prefer-readonly-type, for instance), through a new option, that would make use of ReadonlyDeep utility for objects, arrays, etc instead of readonly on every property.

Motivation

When using the prefer-readonly-type rule, the types declaration (mainly for objects with many properties) tend to become somewhat cluttered with all the readonly properties, e.g:

type Props = {
  readonly header?: string
  readonly subContent?: string
  readonly title?: string
  readonly modalIcon?: JSX.Element
  readonly children?: React.ReactNode
  readonly isOpen?: boolean
  readonly hideCloseIcon?: boolean
  readonly onClose?: (event: React.MouseEvent) => void
  readonly onResult?: (value: boolean) => void
  readonly rejectLabel?: string
  readonly confirmLabel?: string
  readonly buttonStyle?: ButtonProps
  readonly hideTitle?: boolean
  readonly extraClassNames?: ModalProps['extraClassNames'] & {
    readonly buttonsClassName?: string
  }
}

Using ReadonlyDeep:

type Props = ReadonlyDeep<{
  header?: string
  subContent?: string
  title?: string
  modalIcon?: JSX.Element
  children?: React.ReactNode
  isOpen?: boolean
  hideCloseIcon?: boolean
  onClose?: (event: React.MouseEvent) => void
  onResult?: (value: boolean) => void
  rejectLabel?: string
  confirmLabel?: string
  buttonStyle?: ButtonProps
  hideTitle?: boolean
  extraClassNames?: ModalProps['extraClassNames'] & {
    buttonsClassName?: string
  }
}>

I know this would somewhat couple this plugin to type-fest and the implementation might be tricky but it would provide better ergonomics to use immutable types everywhere.

Is this something that makes sense for you to add or it's 100% out of scope?

Thank you for your time :)

@rodrigofariow rodrigofariow added Status: Triage This issue needs to be triaged. Type: Idea Marks an idea, which might be accepted and implemented. labels Mar 31, 2022
@RebeccaStevens
Copy link
Collaborator

Hey,

Currently the plain is for next major release of this plugin to address this sort of thing. However there is no time frame for when that might come out.

#259 and #317 are the start of addressing this.
I've also open an issue over on typescript-eslint that is related.

@rodrigofariow
Copy link
Author

Hey @RebeccaStevens ,

Thanks for the quick response.
Awesome stuff, glad it has gained some traction!

Closing the issue then since it's somewhat a duplicate.

Cheers!

@RebeccaStevens
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage This issue needs to be triaged. Type: Idea Marks an idea, which might be accepted and implemented.
Projects
None yet
Development

No branches or pull requests

2 participants