Skip to content

Nested params typescript #365

@XpamAmAdEuS

Description

@XpamAmAdEuS

Describe the bug

All working very nice when params are at last place and typescript not complain.

const { navigate, search: { musicView }, } = router.useMatch('/admin/music/list');

function navigateToMusicId(id: EntityId) { navigate({ to: '/admin/music/:musicId', params: { musicId: id } }); }

Problem comes if using params in middle of route,
TS2339: Property 'customerId' does not exist on type 'Record '.
but params are there and working as they should.

const { navigate, params: { customerId, customerTitle }, search: { sitesView }, } = router.useMatch('/customer/:customerId/:customerTitle/sites/list');

Anotther issue its about using Link or navigate when params are in middle then we get route without params /customer/:customerId/:customerTitle/sites/wizard

function navigateToWizard(customerId,customerTitle) { navigate({ to:/customer/:customerId/:customerTitle/sites/wizard, params: { customerId: customerId,customerTitle: customerTitle } }); }
this generate link as without values

/customer/:customerId/:customerTitle/sites/wizard

but passing param values directly working

const navigateToWizard = () => { // @ts-ignore navigate({ to:/customer/${customerId}/${customerTitle}/sites/wizard, }); };

Your Example Website or App

Steps to Reproduce the Bug or Issue

Expected behavior

Typescript not complain and params can be in middle

Screenshots or Videos

No response

Platform

Additional context

sry for my bad english and no example app

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