Skip to content

Typings error when using onEnter in state declaration #3260

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

Closed
AntiAsko opened this issue Jan 12, 2017 · 4 comments
Closed

Typings error when using onEnter in state declaration #3260

AntiAsko opened this issue Jan 12, 2017 · 4 comments
Milestone

Comments

@AntiAsko
Copy link

I'm creating a state in Typescript like this:

 state: {
            name: 'mainState.import',
            url: '/import',
            reloadOnSearch: false,
  onEnter: (['$uibModal', (uibModal: ng.ui.bootstrap.IModalService) => {
                let modalOptions: any = {
                    headerText: 'Import State goes here'
                };
                ...
                uibModal.open(modalConfig);

            }])
}

While it works fine I get a typescript compilation error:

[0] (14,14): error TS2322: Type '({ name: string; icon: string; keyboardShortcut: string; state: { name: string; component: string...' is not assignable to type 'ISidebarPage[]'.
[0]   Type '{ name: string; icon: string; keyboardShortcut: string; state: { name: string; component: string;...' is not assignable to type 'ISidebarPage'.
[0]     Type '{ name: string; icon: string; accessibleForRoles: string[]; state: { name: string; url: string; r...' is not assignable to type 'ISidebarPage'.
[0]       Types of property 'state' are incompatible.
[0]         Type '{ name: string; url: string; reloadOnSearch: boolean; onEnter: (string | ((uibModal: IModalServic...' is not assignable to type 'StateDeclaration & { component?: string; template?: string; }'.
[0]           Type '{ name: string; url: string; reloadOnSearch: boolean; onEnter: (string | ((uibModal: IModalServic...' is not assignable to type 'StateDeclaration'.
[0]             Types of property 'onEnter' are incompatible.
[0]               Type '(string | ((uibModal: IModalService) => void))[]' is not assignable to type 'TransitionStateHookFn'.
[0]                 Type '(string | ((uibModal: IModalService) => void))[]' provides no match for the signature '(transition: Transition, state: State): boolean | TargetState | void | Promise<boolean | TargetState | void>'

Is this some sort of bug with the typings?

@christopherthielen
Copy link
Contributor

that should be fixed by #3076
What version of angular-ui-router are you using?

@AntiAsko
Copy link
Author

I'm using 1.0.0-rc.1 which should be the latest right? And I still see the error

@christopherthielen
Copy link
Contributor

Yep rc.1 is latest. I'll take a look and see if there's still a problem

@christopherthielen christopherthielen added this to the 1.0.0-rc.2 milestone Jan 12, 2017
@dartzki
Copy link

dartzki commented Mar 2, 2017

#3076 did not add typings for inline-annotated functions - those are still missing

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

No branches or pull requests

3 participants