refactor(coral): Remove type casting in useSearchParams
- Ngôn ngữ chính
- Java
- Star
- 195
- Fork
- 77
- Merge trung bình
- 8 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 1
Mô tả
# What is currently missing?
Currently, we do `as Type` type casting in some of our use of `searchParmas.get`: https://github.com/Aiven-Open/klaw/blob/main/coral/src/app/features/components/filters/useFiltersContext.tsx#L71-L89
This is actually a potential source of bugs for people entering search params directly in the URL: if they enter a value that is incorrect, we won't know about it, and will send wrong values as part of our API requests, which would result in an error:

# How could this be improved?
- remove type casting
- add typeguards to ascertain the type of the search params we get, for example:
```ts
const isRequestStatus = (param: string | null): param is RequestStatus => {
return param !== null && statusList.includes(param)
}
```
# Is this a feature you would work on yourself?
* [ ] I plan to open a pull request for this feature
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.