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

Alpha.4 has many TS7006 error "implicitly has an any type" #2693

Closed
okunokentaro opened this issue Apr 14, 2016 · 8 comments
Closed

Alpha.4 has many TS7006 error "implicitly has an any type" #2693

okunokentaro opened this issue Apr 14, 2016 · 8 comments
Milestone

Comments

@okunokentaro
Copy link

Hi.

In alpha.4 & TS 1.8.9 "moduleResolution": "node", "noImplicitAny": true

node_modules/angular-ui-router/commonjs/common/common.d.ts(13,37): error TS7006: Parameter 'X' implicitly has an 'any' type.
node_modules/angular-ui-router/commonjs/common/common.d.ts(163,63): error TS7006: Parameter 'T' implicitly has an 'any' type.
node_modules/angular-ui-router/commonjs/common/common.d.ts(163,66): error TS7006: Parameter 'key' implicitly has an 'any' type.
node_modules/angular-ui-router/commonjs/common/common.d.ts(165,71): error TS7006: Parameter 'T' implicitly has an 'any' type.
node_modules/angular-ui-router/commonjs/common/common.d.ts(165,74): error TS7006: Parameter 'key' implicitly has an 'any' type.
node_modules/angular-ui-router/commonjs/common/hof.d.ts(113,27): error TS7006: Parameter 'ctor' implicitly has an 'any' type.
node_modules/angular-ui-router/commonjs/common/hof.d.ts(113,37): error TS7006: Parameter 'x' implicitly has an 'any' type.
node_modules/angular-ui-router/commonjs/common/hof.d.ts(115,27): error TS7006: Parameter 'comp' implicitly has an 'any' type.
node_modules/angular-ui-router/commonjs/common/hof.d.ts(115,37): error TS7006: Parameter 'x' implicitly has an 'any' type.
node_modules/angular-ui-router/commonjs/ng1/viewDirective.d.ts(10,9): error TS7010: 'resolve', which lacks return-type annotation, implicitly has an 'any' return type.
node_modules/angular-ui-router/commonjs/state/stateBuilder.d.ts(3,54): error TS7006: Parameter 'parent' implicitly has an 'any' type.
node_modules/angular-ui-router/commonjs/transition/transitionService.d.ts(75,35): error TS7006: Parameter 'error' implicitly has an 'any' type.

I encountered many TS7006 errors. please describes any correctly. thanks.

@majo44
Copy link

majo44 commented Apr 14, 2016

+1

In general current package structure do not fallow the "moduleResolution" : "node" rules. And is hard to integrate into the ts projects . Please look at structure of angular2. In general on root folder we should have what we currently have in commonjs folder. Bundles you can put in bundles (release) sub folder. and in same place you can put the bundled d.ts (just use tsc --module system -- outFile ... and tsc will generate the combined .d.ts)

@eddiemonge eddiemonge added the 1.0 label Apr 20, 2016
@christopherthielen
Copy link
Contributor

@armorik83 @majo44

Which package are you both referring to... the ng1 package?

We now publish angular-ui-router, ui-router-ng2 and ui-router-core to npm. You should use npm install --save angular-ui-router@next. The package's main: points to the release/angular-ui-router.js bundle, and typings: points to the typescript definitions.

Then use import {Thing} from "angular-ui-router"; Your Typescript compatible IDE should find the typings automatically.

screen shot 2016-05-12 at 3 17 04 pm

@christopherthielen
Copy link
Contributor

Closing as wontfix because typescript 2.0 has an option to skip lib checks

microsoft/TypeScript#8735

@christopherthielen christopherthielen removed this from the 1.0.0-alpha.6 milestone Jun 24, 2016
@johnnyreilly
Copy link
Contributor

johnnyreilly commented Jun 26, 2016

Hey @christopherthielen ,

Unfortunately not fixing this issue means that users of the latest router will have to be on TypeScript 2.0 and have that option set given that using noImplicitAny is pretty commonplace. That's a real shame and a slight barrier to entry.

Would you be open to PRs to resolve this?

I can provide a PR which will resolve this issue. It's just a case of taking a trip through the code and adding to method signatures an any annotation per parameter where there is no annotation at all at present. It's very quick to do and I'd be happy to do it for you.

If you decided to upgrade the types to something more specific over time that would be completely open to you. Just to be clear: the only code change would be the adding of any type annotations to method signatures. No more than that.

@johnnyreilly
Copy link
Contributor

So I got bold @christopherthielen - I've made a PR that makes ui-router noImplicitAny compliant. I hope this works for you?

@johnnyreilly
Copy link
Contributor

Awesome!

@dballesteros7
Copy link

dballesteros7 commented Aug 17, 2016

@christopherthielen This not only produced error in the declaration files from ui-router but also in your own code if you do for example:

import {StateParams} from 'angular-ui-router'; class MyController($stateParams:StateParams) { let x = $stateParams['param']; }
This throws on $stateParams being an implicity any even with --skipLibCheck, with this fix the problem is gone. Is there a nightly build one can use? or could we have a release with this fix in. Thanks!

@clembou
Copy link

clembou commented Jan 12, 2017

FYI I think noImplicitAny compatibility is broken again in 1.0.0-rc.1:

ERROR in E:\repos\resgroup\smart-ui\node_modules\ui-router-core\lib\resolve\resolveContext.d.ts
(7,22): error TS7005: Variable 'NATIVE_INJECTOR_TOKEN' implicitly has an 'any' type.

ERROR in E:\repos\resgroup\smart-ui\node_modules\ui-router-core\lib\transition\transitionHook.d.ts
(13,37): error TS7006: Parameter 'error' implicitly has an 'any' type.

ERROR in E:\repos\resgroup\smart-ui\node_modules\ui-router-core\lib\common\common.d.ts
(361,31): error TS7006: Parameter 'a' implicitly has an 'any' type.

ERROR in E:\repos\resgroup\smart-ui\node_modules\ui-router-core\lib\common\common.d.ts
(361,34): error TS7006: Parameter 'b' implicitly has an 'any' type.

using --noLibChecks as a workaround works as expected.

@christopherthielen christopherthielen added this to the 1.0.0-rc.2 milestone Jan 12, 2017
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

7 participants