microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101k stars 12.48k forks source link

noImplicitAny rule applied to external packages #8883

Closed johnnyreilly closed 8 years ago

johnnyreilly commented 8 years ago

I was trying out the new angular ui router which has been ported to TypeScript and ships with definitions in the box. However, it looks like the compiler rules for my own project are being applied to the angular ui router project as well.

TypeScript Version:

1.8.10

Code

import { StateProvider } from "angular-ui-router";

Using this tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "module": "es2015",
    "moduleResolution": "node",
    "noEmitOnError": true,
    "noImplicitAny": true,
    "preserveConstEnums": true,
    "removeComments": false,
    "sourceMap": true,
    "suppressImplicitAnyIndexErrors": true,
    "target": "es2015"
  }
}

Expected behavior: StateProvider is pulled in and can be used. No errors.

Actual behavior: It errors with:

ERROR in C:\source\poorclaresarundel\PoorClaresAngular\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.

ERROR in C:\source\poorclaresarundel\PoorClaresAngular\node_modules\angular-ui-router\commonjs\common\hof.d.ts
(113,27): error TS7006: Parameter 'ctor' implicitly has an 'any' type.

ERROR in C:\source\poorclaresarundel\PoorClaresAngular\node_modules\angular-ui-router\commonjs\common\hof.d.ts
(113,37): error TS7006: Parameter 'x' implicitly has an 'any' type.

ERROR in C:\source\poorclaresarundel\PoorClaresAngular\node_modules\angular-ui-router\commonjs\common\hof.d.ts
(115,27): error TS7006: Parameter 'comp' implicitly has an 'any' type.

ERROR in C:\source\poorclaresarundel\PoorClaresAngular\node_modules\angular-ui-router\commonjs\common\hof.d.ts
(115,37): error TS7006: Parameter 'x' implicitly has an 'any' type.

ERROR in C:\source\poorclaresarundel\PoorClaresAngular\node_modules\angular-ui-router\commonjs\state\stateBuilder.d.ts
(3,54): error TS7006: Parameter 'parent' implicitly has an 'any' type.

ERROR in C:\source\poorclaresarundel\PoorClaresAngular\node_modules\angular-ui-router\commonjs\transition\transitionServ
ice.d.ts
(75,35): error TS7006: Parameter 'error' implicitly has an 'any' type.

ERROR in C:\source\poorclaresarundel\PoorClaresAngular\node_modules\angular-ui-router\commonjs\common\common.d.ts
(13,37): error TS7006: Parameter 'X' implicitly has an 'any' type.

ERROR in C:\source\poorclaresarundel\PoorClaresAngular\node_modules\angular-ui-router\commonjs\common\common.d.ts
(163,63): error TS7006: Parameter 'T' implicitly has an 'any' type.

ERROR in C:\source\poorclaresarundel\PoorClaresAngular\node_modules\angular-ui-router\commonjs\common\common.d.ts
(163,66): error TS7006: Parameter 'key' implicitly has an 'any' type.

ERROR in C:\source\poorclaresarundel\PoorClaresAngular\node_modules\angular-ui-router\commonjs\common\common.d.ts
(165,71): error TS7006: Parameter 'T' implicitly has an 'any' type.

ERROR in C:\source\poorclaresarundel\PoorClaresAngular\node_modules\angular-ui-router\commonjs\common\common.d.ts
(165,74): error TS7006: Parameter 'key' implicitly has an 'any' type.

All of these are external to my own project; I wouldn't have expected that this would be an issue. As it happens the good folks of angular ui router are planning to remedy this. But if, for whatever reason, they didn't then I'd either have to change the choices made in my own project to align with theirs or not use their project. Neither of those is great.

Would a compiler option that restricts applying these rules to external projects be something you might consider? Whilst packages that ship with typings in the box is at the moment relatively niche I can imagine that changing massively over time.

basarat commented 8 years ago

Would a compiler option that restricts applying these rules to external projects be something you might consider

I believe the newly introduced skipLibCheck option does exactly that :rose:

johnnyreilly commented 8 years ago

Thanks @basarat! - I hadn't heard of that option; is that part of 1.8 or is it slated for 2.0?

johnnyreilly commented 8 years ago

I see it - 2.0. thanks! https://github.com/Microsoft/TypeScript/wiki/Roadmap

johnnyreilly commented 8 years ago

Will close as it looks like this is resolved by https://github.com/Microsoft/TypeScript/pull/8735

basarat commented 8 years ago

@johnnyreilly :arrow_right_hook: I've made an alm release 0.0.87 that supports this option :rose:

johnnyreilly commented 8 years ago

I would expect nothing less :smile: :tulip: