Skip to content

Commit ad102e1

Browse files
authored
chore: prelease 15.0.0-rc.2 (#334)
## Build - Update package to prelease version `15.0.0-rc.2` ## Documentation - Log prerelease `15.0.0-rc.2` changes
2 parents da2646d + fc115bf commit ad102e1

File tree

2 files changed

+98
-1
lines changed

2 files changed

+98
-1
lines changed

CHANGELOG.md

+97
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,102 @@
11
# Router Component Store changelog
22

3+
## 15.0.0-rc.2 (2025-02-12)
4+
5+
### Features
6+
7+
- Use `StrictQueryParams` for query parameters instead of `StrictRouteParams` ([#331](https://github.com/ngworker/router-component-store/pull/331))
8+
9+
Array query parameters like `?size=m&size=l&size=xl` are now correctly resolved to `readonly string[]` instead of `string`.
10+
11+
**BREAKING CHANGES**
12+
13+
**`RouterStore#queryParams$` and `MinimalActivatedRouteSnapshot#queryParams` use `StrictQueryParams`**
14+
15+
`RouterStore#queryParams$` and `MinimalActivatedRouteSnapshot#queryParams` use `StrictQueryParams` instead of `StrictRouteParams`. Members are of type `string | readonly string[] | undefined` instead of `string | undefined`.
16+
17+
The TypeScript compiler will fail to compile code that does not handle the string array type.
18+
19+
BEFORE:
20+
21+
```typescript
22+
// shirts.component.ts
23+
// (...)
24+
import { RouterStore } from '@ngworker/router-component-store';
25+
26+
@Component({
27+
// (...)
28+
})
29+
export class ShirtsComponent {
30+
#routerStore = inject(RouterStore);
31+
32+
size$: Observable<string> = this.#routerStore.queryParams$.pipe(
33+
map((params) => params['size'])
34+
);
35+
}
36+
```
37+
38+
AFTER:
39+
40+
```typescript
41+
// shirts.component.ts
42+
// (...)
43+
import { RouterStore } from '@ngworker/router-component-store';
44+
45+
@Component({
46+
// (...)
47+
})
48+
export class ShirtsComponent {
49+
#routerStore = inject(RouterStore);
50+
51+
size$: Observable<readonly string[]> = this.#routerStore.queryParams$.pipe(
52+
map((params) => params['size']),
53+
map((size) => (Array.isArray(size) ? size : [size]))
54+
);
55+
}
56+
```
57+
58+
**`RouterStore#selectQueryParam` use `StrictQueryParams`**
59+
60+
`RouterStore#selectQueryParam` use `StrictQueryParams` instead of `StrictRouteParams`. The returned value is of type `string | readonly string[] | undefined` instead of `string | undefined`.
61+
62+
The TypeScript compiler will fail to compile code that does not handle the string array type.
63+
64+
BEFORE:
65+
66+
```typescript
67+
// shirts.component.ts
68+
// (...)
69+
import { RouterStore } from '@ngworker/router-component-store';
70+
71+
@Component({
72+
// (...)
73+
})
74+
export class ShirtsComponent {
75+
#routerStore = inject(RouterStore);
76+
77+
size$: Observable<string> = this.#routerStore.selectQueryParam('size');
78+
}
79+
```
80+
81+
AFTER:
82+
83+
```typescript
84+
// shirts.component.ts
85+
// (...)
86+
import { RouterStore } from '@ngworker/router-component-store';
87+
88+
@Component({
89+
// (...)
90+
})
91+
export class ShirtsComponent {
92+
#routerStore = inject(RouterStore);
93+
94+
size$: Observable<readonly string[]> = this.#routerStore
95+
.selectQueryParam('size')
96+
.pipe(map((size) => (Array.isArray(size) ? size : [size])));
97+
}
98+
```
99+
3100
## 15.0.0-rc.1 (2024-09-17)
4101

5102
### Refactors

packages/router-component-store/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ngworker/router-component-store",
3-
"version": "15.0.0-rc.1",
3+
"version": "15.0.0-rc.2",
44
"description": "A strictly typed lightweight alternative to NgRx Router Store (@ngrx/router-store) and ActivatedRoute",
55
"license": "MIT",
66
"peerDependencies": {

0 commit comments

Comments
 (0)