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

HttpParams fromObject should accept ReadonlyArray<string> #28452

Closed
jinder opened this issue Jan 30, 2019 · 3 comments
Closed

HttpParams fromObject should accept ReadonlyArray<string> #28452

jinder opened this issue Jan 30, 2019 · 3 comments

Comments

@jinder
Copy link

jinder commented Jan 30, 2019

🚀 feature request

Relevant Package

@angular/common/http

Description

The type definition for HttpParamsOptions fromObject property only accepts string and string[]. If using immutable types, such as ReadonlyArray, you must create a new array unnecessarily to satisfy the type.

Describe the solution you'd like

Please change the type to the following (which is backwards compatible):

    fromObject?: {
        [param: string]: string | string[] | ReadonlyArray<string>;
    };
@ngbot ngbot bot added this to the needsTriage milestone Jan 30, 2019
@alan-mroczek
Copy link

Hi @jinder. How about without second array, just by casting types:

fromObject: { yourParamName: ['example', 'example2'] as string[] }

I can create PR with that change, because it shouldn't be that hard to implement, but I'm not sure if it's needed.

@jinder
Copy link
Author

jinder commented Jan 31, 2019

@alan-mroczek I think it's poor practice to cast a immutable type to a mutable one (and preferable to slice it if need be).

Angular's API surface should really use immutable types where possible (i.e. where it is not mutating them), as they are subset of the mutable version.

@ngbot ngbot bot modified the milestones: needsTriage, Backlog Apr 23, 2019
MansourFall added a commit to MansourFall/angular that referenced this issue Jun 15, 2019
MansourFall added a commit to MansourFall/angular that referenced this issue Jun 15, 2019
MansourFall added a commit to MansourFall/angular that referenced this issue Jun 15, 2019
MansourFall added a commit to MansourFall/angular that referenced this issue Jun 15, 2019
MansourFall added a commit to MansourFall/angular that referenced this issue Jul 30, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants