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

AuthorizeStep shows TSC errors like Property 'auth' does not exist on type 'RouteConfig'. #265

Closed
HIRANO-Satoshi opened this issue Dec 23, 2015 · 5 comments · Fixed by #269

Comments

@HIRANO-Satoshi
Copy link
Contributor

There is the following code in the cheat sheet (typescript). I have similar code borrowed from the cheat sheet.

http://aurelia.io/docs.html#/aurelia/framework/1.0.0-beta.1.0.6/doc/article/cheat-sheet

class AuthorizeStep {
  run(navigationInstruction: NavigationInstruction, next: Function): Promise<any> {
    if (navigationInstruction.getAllInstructions().some(i => i.config.auth)) {
      var isLoggedIn = /* insert magic here */false;
      if (!isLoggedIn) {
        return next.cancel(new Redirect('login'));
      }
    }

    return next();
  }
}

tsc shows the following errors.

Property 'auth' does not exist on type 'RouteConfig'.
Property 'cancel' does not exist on type 'Function'.

How do I fix?

@bryanrsmith
Copy link
Contributor

Looks like we need to adjust the type annotations on the next parameter. It's a function with a cancel property tacked on, but it's declared as a function right now.

@HIRANO-Satoshi
Copy link
Contributor Author

I see.

@bryanrsmith
Copy link
Contributor

@cmichaelgraham I believe that this line needs to use a type annotation like

run(instruction: NavigationInstruction, next: { (): Promise, cancel: (result: any) => Promise, reject: (result: any) => Promise, complete: (result: any) => Promise }): void;

but the dts generator doesn't appear to support it. Is this something we can add easily, or is there alternative syntax that might work?

@bryanrsmith
Copy link
Contributor

Thanks, @cmichaelgraham. Looks like your change worked great.

@HIRANO-Satoshi
Copy link
Contributor Author

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants