Skip to content

Working with Transition.params is unwieldy #16

Closed
@csvn

Description

@csvn

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions