AlexxNB / tinro

Highly declarative, tiny, dependency free router for Svelte's web applications.
MIT License
669 stars 30 forks source link

Typescript error when using `Route` props with `let:` directive: "Property 'params' does not exist on type '{}'" #41

Closed sangxxh closed 3 years ago

sangxxh commented 3 years ago

I set up the project using https://github.com/sveltejs/template with Typescript enabled.

Using tinro's Parameters example from README.md:

    <Route path="/books/:author/*" let:params>
        Books by {params.author}
        <Route path="/:genre" let:params>
            Books by {params.author} in category {params.genre}
        </Route>
    </Route>

let:params in Typescript yield error:

Property 'params' does not exist on type '{}'. ts(2339)

tinro

The same error yields if using any other props (path, fallback, etc.)

AlexxNB commented 3 years ago

Added definition for let:params variable in 0.4.11

But I have no issues with other attributes. All works as expected for me. I use clean default typescript template with your code.

sangxxh commented 3 years ago

Thanks @AlexxNB . let:params is working.

For others, what I meant is, for example, using let:path will yield the same error. But I guess you don't intend to expose them as slot props? I don't use them anyway and I think this issue can be closed, just wanna confirm first.

AlexxNB commented 3 years ago

Expoosed only params right now. (I'll add more route data info soon). path, fallback - it is Route properties, not variables.