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

Enforce readonly properties immutability #6005

Open
galargh opened this issue Nov 28, 2024 · 0 comments
Open

Enforce readonly properties immutability #6005

galargh opened this issue Nov 28, 2024 · 0 comments
Labels
status:ready This issue is ready to be worked on v-next A Hardhat v3 development task
Milestone

Comments

@galargh
Copy link
Member

galargh commented Nov 28, 2024

This issue captures the 2nd part of the work identified in the following conversation https://nomicfoundation.slack.com/?redir=%2Farchives%2FC03P6B72ZHU%2Fp1732272638933179%3Fname%3DC03P6B72ZHU%26perma%3D1732272638933179. I think it might make the most sense to add it to the backlog for now.

In the following snippet:

interface Foo {
	readonly bar: Bar;
}

the property bar is readonly, but it is not immutable. To enforce immutability on the type level, it would have to be wrapped in a Readonly utility type like so:

interface Foo {
	readonly bar: Readonly<Bar>;
}

The latter is most often the desired behaviour as showcase by #5971, for example.

I propose enforcing that all non-primitive types found next to the class/object/interface readonly properties are wrapped in the Readonly utility type.

An example of one possible implementation of this rule can be found at #6006

@galargh galargh added status:ready This issue is ready to be worked on v-next A Hardhat v3 development task labels Nov 28, 2024
@github-project-automation github-project-automation bot moved this to Backlog in Hardhat Nov 28, 2024
@kanej kanej moved this from Backlog to To-do in Hardhat Dec 2, 2024
@kanej kanej added this to the Public Alpha milestone Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on v-next A Hardhat v3 development task
Projects
Status: To-do
Development

No branches or pull requests

2 participants