angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.53k stars 3k forks source link

Errors when building ui-router (Angular 2.0.0) #3007

Closed kolkov closed 8 years ago

kolkov commented 8 years ago
D:\!Projects\TypeScript\ui-router\ui-router>npm test

> ui-router@1.0.0-beta.2 test D:\!Projects\TypeScript\ui-router\ui-router
> npm run test:integrate

> ui-router@1.0.0-beta.2 test:integrate D:\!Projects\TypeScript\ui-router\ui-router
> tsc && npm run test:core && npm run test:ng12 && npm run test:ng13 && npm run test:ng14 && npm run test:ng15

src/common/common.ts(521,40): error TS2345: Argument of type 'Function' is not assignable to parameter of type '(value: any, index: number, array: any[]) => void'.
  Type 'Function' provides no match for the signature '(value: any, index: number, array: any[]): void'
src/common/predicates.ts(7,14): error TS4023: Exported variable 'isDefined' has or is using name 'Predicate' from external module "D:/!Projects/TypeScript/ui-router/ui-router/src/common/common" but cannot be named.
src/common/trace.ts(59,55): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
src/state/stateService.ts(299,73): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
src/state/stateService.ts(495,44): error TS2339: Property 'stack' does not exist on type 'string'.
src/state/stateService.ts(496,38): error TS2339: Property 'stack' does not exist on type 'string'.
...
kolkov commented 8 years ago

I have built my own version ui-router-ng2 for NG 2.0.0. It's working, but have some errors in tests, because I removed some code for overcome this errors:

src/common/common.ts(521,40): error TS2345: Argument of type 'Function' is not assignable to parameter of type '(value: any, index: number, array: any[]) => void'.
  Type 'Function' provides no match for the signature '(value: any, index: number, array: any[]): void'

I removed type Function from: function _forEach(obj: (any[]|any), cb, _this: Obj) {

src/common/predicates.ts(7,14): error TS4023: Exported variable 'isDefined' has or is using name 'Predicate' from external module "D:/!Projects/TypeScript/ui-router/ui-router/src/common/common" but cannot be named. https://github.com/Microsoft/TypeScript/issues/5711

I add unused import: import {Predicate} from "./common";

src/state/stateService.ts(299,74): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. https://github.com/Microsoft/TypeScript/issues/2775

I temporarily removed detail from error.detail in https://github.com/angular-ui/ui-router/blob/master/src/state/stateService.ts#L299

and stack from detail.stack https://github.com/angular-ui/ui-router/blob/master/src/state/stateService.ts#L495 https://github.com/angular-ui/ui-router/blob/master/src/state/stateService.ts#L496

Everything works as it should (tested on quickstart-ng2). I look forward to the new version soon! )))

christopherthielen commented 8 years ago

https://github.com/angular-ui/ui-router/commit/4ce27c92c7bef9986856d45ee2fa376eab3305e1

https://github.com/ui-router/quickstart-ng2/tree/beta.3-support

kolkov commented 8 years ago

Thanks! Fixed!