'How does React Router infer strongly typed arguments from path string?

(This is a question for understanding the workings, not a "how do I..." question)

When working with React Router I've realized that Vscode IntelliSense can suggest me strongly-typed parameters when I type them in a route like this:

<Route path='/users/:userId?' render={props => <UserManager selectedId={props.}/>} />

When I type props.match.params., whenever I have in path string as :text goes as a strongly typed parameter from inside the string to the params as a strongly typed property (and an optional parameter if there is a question mark as in my case):

enter image description here

How can Vscode/TypeScript/React Router generate a strongly typed argument from a bare user-entered string?



Sources

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

Source: Stack Overflow

Solution Source