Skip to content

angular 1 StateProvider.state function should expect Ng1StateDeclaration parameter #3001

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
AkosLukacs opened this issue Sep 15, 2016 · 2 comments

Comments

@AkosLukacs
Copy link

I'm using TypeScript, after switching to ß2 $stateProvider.state() expects StateDeclaration parameter type, that doesn't have a template property for example. Therefore the following code doesn't compile (did work with ß1).

import * as uir from 'angular-ui-router';

//...

myModule.config(['$stateProvider', '$urlRouterProvider',
  ($stateProvider: uir.StateProvider, $urlRouterProvider: uir.UrlRouterProvider) => {

    $stateProvider
      .state('x', { url: '/x', template: '<p>x</p>' })     
  }]);

The compilation error:

Argument of type '{ url: string; template: string; }' is not assignable to parameter of type 'StateDeclaration'.
Object literal may only specify known properties, and 'template' does not exist in type 'StateDeclaration'.

There is an Ng1StateDeclaration interface, so came up with a temporary workaround for myself:

  export interface NG1StateProvider extends uir.StateProvider {
    state(name: string, definition: uir.Ng1StateDeclaration): NG1StateProvider;
    state(definition: uir.Ng1StateDeclaration): NG1StateProvider;
  }
@christopherthielen christopherthielen added this to the 1.0.0-final milestone Sep 17, 2016
@AkosLukacs
Copy link
Author

Great, thanks!

@asulykos
Copy link

Szia Luke!
Küldj légyszi egy elérhetőséget, december 2-án gimis osztálytalálkozó lesz.
(Írtam a luke kukac luke pont hu-ra is, de nem válaszoltál.)

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

No branches or pull requests

3 participants