Skip to content

Comments

feat(ts): set columns type as readonly#358

Merged
wdavidw merged 1 commit intoadaltas:masterfrom
blemoine:patch-1
Mar 15, 2024
Merged

feat(ts): set columns type as readonly#358
wdavidw merged 1 commit intoadaltas:masterfrom
blemoine:patch-1

Conversation

@blemoine
Copy link
Contributor

The goal is for stringify to support values declared as const.

eg.

const columns = ['name', 'age'] as const

stringify({columns})

As this array has no reasons to be mutated by stringify it's simpler to set it as readonly.

The goal is for stringify to support values declared `as const`. 

eg.
```
const columns = ['name', 'age'] as const

stringify({columns})
```

As this array has no reasons to be mutated by `stringify` it's simpler to set it as `readonly`.
@wdavidw
Copy link
Member

wdavidw commented Aug 16, 2022

This is pretty much the case for every option. Not sure it provide much value.

@blemoine
Copy link
Contributor Author

blemoine commented Aug 16, 2022

If you try the following code

const columns = ['name', 'age'] as const

stringify({columns})

without this PR patch, it won't compile - even though it's perfectly valid at runtime.

@ViniciusLovato
Copy link

Recently, I encountered the same problem. It would be helpful to support values declared as const.

@wdavidw
Copy link
Member

wdavidw commented Aug 25, 2023

Then I propose to update this PR to apply const to every option.

@yoursunny
Copy link

The Input type should be readonly too.

@wdavidw wdavidw merged commit 44f2e7c into adaltas:master Mar 15, 2024
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