+
Skip to content

Router Params type readonly #59953

Open
Open
@cubimon

Description

@cubimon

Which @angular/* package(s) are the source of the bug?

router

Is this a regression?

No

Description

On ActivatedRoute the params member of type Params is readonly, but its type doesn't specify that it is readonly, See Router shared.ts.

Check https://github.com/cubimon/angular-readonly-params/blob/master/src/app/app.component.ts, go to http://localhost:4200/test;a=b

Please provide a link to a minimal reproduction of the bug

https://github.com/cubimon/angular-readonly-params/blob/master/src/app/app.component.ts

Please provide the exception or error you saw

TypeError: Cannot assign to read only property 'id' of object '[object Object]'

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 18.2.14
Node: 18.20.6
Package Manager: npm 10.8.2
OS: win32 x64

Angular: 18.2.13
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1802.14
@angular-devkit/build-angular   18.2.14
@angular-devkit/core            18.2.14
@angular-devkit/schematics      18.2.14
@angular/cli                    18.2.14
@schematics/angular             18.2.14
rxjs                            7.8.1
typescript                      5.5.4
zone.js                         0.14.10

Anything else?

This is a minor issue that could be easily resolved by using readonly Keyword

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载