Closed
Description
This issue is just for improving Typescript experience. There is no functional changes intended.
When working with Typescript, using Transition.params()
usually feels a bit clunky. A piece of code to illustrate the issue:
let toParams = transition.params();
console.log(toParams.id); // Warning; "prop id does not exist on type.."
console.log(toParams['id']); // ugly workaround
Both of the options above leaves the user with no intellisense in their editor. There is solution to the above, which is to cast params to interface/type, but this is messier (especially in one-liners):
let toParams = transition.params() as MyStateParams;
console.log(toParams.id); // yay!
console.log((transition.params() as MyStateParams).id); // not very pretty...
Ideally, I would like to be able to do this:
let toParams = transition.params<MyStateParams>();
console.log(toParams.id);
console.log(transition.params<MyStateParams>().id); // feels better than casting
Metadata
Metadata
Assignees
Labels
No labels