-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: common/httpIssues related to HTTP and HTTP ClientIssues related to HTTP and HTTP Client
Milestone
Description
Bug Report
Affected Package
The issue is caused by package @angular/common/http
Is this a regression?
No
Description
From Angular version 12, the HttpParamsOptions allows number and boolean types in fromObject, introduced with commit #40663
When a new HttpParams object is created using that option, then the parameters are not converted to string, so when using the get and getAll methods the value does not match the expected string | null type.
This causes type errors and tests failing.
Check this comment for more info about the fix: #42637 (comment)
Minimal Reproduction
const params = new HttpParams({ fromObject: { numericParam: 5 } });
console.log(
typeof params.get('numericParam') === 'number', // true
params.get('numericParam') === '5', // false
// params.get('numericParam') === 5, // does not compile
);
Your Environment
Angular Version:
Angular CLI: 12.0.3
Node: 14.15.4
Package Manager: npm 6.14.10
OS: linux x64
Angular: 12.0.4
... animations, cdk, common, compiler, compiler-cli, core, forms
... localize, material, platform-browser
... platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1200.3
@angular-devkit/build-angular 12.0.3
@angular-devkit/core 12.0.3
@angular-devkit/schematics 12.0.3
@angular/cli 12.0.3
@angular/flex-layout 12.0.0-beta.34
@schematics/angular 12.0.3
rxjs 6.6.7
typescript 4.2.4Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: common/httpIssues related to HTTP and HTTP ClientIssues related to HTTP and HTTP Client