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鈥檒l 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 · 2 comments

Comments

@jinder
Copy link

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

This comment has been minimized.

Copy link

commented Jan 30, 2019

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

This comment has been minimized.

Copy link
Author

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

@mhevery mhevery closed this in f5bec3f Aug 30, 2019

mhevery added a commit that referenced this issue Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can鈥檛 perform that action at this time.