-
Notifications
You must be signed in to change notification settings - Fork 53
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
Access to this.location: Property 'location' does not exist #404
Comments
Looks like an interface or a mixin is missing that would make all router-added properties and callbacks known to TypeScript. What do you think of a syntax like below? class PageHome extends RouterView(LitElement) {
...
} |
Makes sense! |
Any news here? Thanks in advance! 😄 |
Having this problem too, any update? |
Hi everybody, here is a PR that adds with this change, for using import {Router} from '@vaadin/router';
class MyView extends HTMLElement {
connectedCallback() {
this.location;
}
}
interface MyView extends Router.View {} Also, inline casting could be used if merging is not desired: import {Router} from '@vaadin/router';
class MyView extends HTMLElement {
connectedCallback() {
(this as Router.View).location;
}
} Mind that accessing |
I have also considered a mixin function like so: class PageHome extends RouterView(LitElement) {
...
} the thing is, this compiles the function call to JS, so it requires the implementation. We could a trivial one, but I doubt that it brings any value to have this in runtime: export const RouterView = (superClass) => superClass; |
The docs says that we can access to
this.location
to get the route parameters:https://vaadin.github.io/vaadin-router/vaadin-router/#/classes/Router/demos/demo/index.html
And it works.
But when using TypeScript, I get an error:
The text was updated successfully, but these errors were encountered: