Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working with Transition.params is unwieldy #16

Closed
csvn opened this issue Dec 19, 2016 · 0 comments
Closed

Working with Transition.params is unwieldy #16

csvn opened this issue Dec 19, 2016 · 0 comments

Comments

@csvn
Copy link
Contributor

csvn commented Dec 19, 2016

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant