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

Argument of type 'readonly number[]' is not assignable to parameter of type 'any[]' #1059

Closed
horyzont85 opened this issue Jul 8, 2021 · 3 comments · Fixed by #1061
Closed

Comments

@horyzont85
Copy link

Describe the bug

When I use:
check("foo").isIn(myArray)
where myArray is readonly array then I got an error:

Argument of type 'readonly number[]' is not assignable to parameter of type 'any[]'.
The type 'readonly number[]' is 'readonly' and cannot be assigned to the mutable type 'any[]'.ts(2345)

Expected behavior

isIn shouldn't report an error for readonly arrays.

Express-validator version:

  • Version: 6.12.0
@fedeci
Copy link
Member

fedeci commented Jul 12, 2021

Hi @horyzont85, which version of typescript are you using? Could you share your tsconfig.json?

@gustavohenke
Copy link
Member

The bug makes sense to me -- we use readonly arrays all the time at work. readonly any[] is different from any[]:
https://www.typescriptlang.org/play?#code/MYewdgzgLgBAhgJwQLhggpnAJuANgT3jHwG0BdGAXhhIEYAaGAJkYGYyBuAKADMBXMMCgBLcDBwBlEAFt0UABbCwAcwAUSgA58oqOMXIBKGAG8Avl0ky5ilasQIDHIA

@gustavohenke
Copy link
Member

Fixed in v6.12.1.

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

Successfully merging a pull request may close this issue.

3 participants