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

Remove readonly from RequestInit typings #1445

Closed
NMinhNguyen opened this issue May 16, 2022 · 2 comments · Fixed by #1446
Closed

Remove readonly from RequestInit typings #1445

NMinhNguyen opened this issue May 16, 2022 · 2 comments · Fixed by #1446
Labels
bug Something isn't working

Comments

@NMinhNguyen
Copy link
Contributor

NMinhNguyen commented May 16, 2022

Bug Description

It'd be good to remove readonly modifier from RequestInit typings to match https://github.com/microsoft/TypeScript/blob/95731f03979985609c9fd662f179be5b9cea3470/lib/lib.dom.d.ts#L1470. This would allow for RequestInit objects to be conditionally mutated like so https://github.com/ferdikoomen/openapi-typescript-codegen/blob/0f11ea84a9ca9867bb72700f468fa21d8085ce86/src/templates/core/fetch/sendRequest.hbs#L20

I'm happy to raise a PR for this if there are no objections.

Reproducible By

If you try to mutate a RequestInit object, TypeScript will say something like:

Cannot assign to 'credentials' because it is a read-only property. ts(2540)

Expected Behavior

No error.

Logs & Screenshots

Environment

Additional context

@NMinhNguyen NMinhNguyen added the bug Something isn't working label May 16, 2022
@KhafraDev
Copy link
Member

PR welcome, make sure to include tests. We use tsd for testing types.

@NMinhNguyen
Copy link
Contributor Author

Thanks @KhafraDev, let me know if the test in #1446 isn't enough and I'll see what I can do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants