'Is there way to type route.params in Vue.js?

I ran into a trouble while Typescriptizing my vue.js app. I try to pluck a parameter from route.params and assign it to a property of a reactive form. However, TypeScript gave me a warning that the type of parameter must be string|string[], so it can't be assigned to a string property. The only solution I came up with is the following :

form.productId = route.params.productId as string

I think it would be a better solution if I could type parameters of route.params, but I have no idea of how to do it. I would appreciate it if someone can help on this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source