router
router copied to clipboard
Route parameters have incorrect type
The Vaadin Router Docs says:
Named parameters are accessible by a string key, such as
location.params.id
orlocation.params['id']
.
Issue
The type of the parameter returned by location.params.id
is a string[]
, whereas the actual parameter is a string
if you inspect it in the browser.
I'm unsure if this is a documentation or implementation issue
The TS type is actually ParamValue
which is defined as:
type ParamValue = string | string[];
There is support for "repeat params" so for a path
of '/:a*'
the location.params.a
will be a string array e.g. when matching route /1/2/3
it will be ['1', '2', '3']
. So that's why the type is essentially string | string[]
and it seems correct to me.
Sounds like more of a documentation issue then. Would be helpful to have 2 concrete examples of how to access a plain string parameter and an array