refactor(coral): Remove type casting in useSearchParams
- 主要语言
- Java
- 星标
- 195
- 派生
- 77
- 平均合并
- 8 天 9 小时
- 30 天内合并 PR
- 1
描述
# 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
贡献指南
评估
这个 Issue 还没有评估数据。