V
V
Vitaly2016-07-06 16:55:07
JavaScript
Vitaly, 2016-07-06 16:55:07

How can I set typescript to skip the "any" type?

All the best!
I began to slowly write my first application in angular 2 with typescript.
I already understood typescript very meticulous :) Now I want to connect someone else's component (for uploading files) to my application, where the any type is used , but the compiler does not allow it :(

app/upload.component.ts(24,16): error TS7006: Parameter 'data' implicitly has an 'any' type.
node_modules/ng2-uploader/src/directives/ng-file-drop.ts(21,39): error TS7006: Parameter 'data' implicitly has an 'any' type.
node_modules/ng2-uploader/src/directives/ng-file-drop.ts(29,53): error TS7006: Parameter 'e' implicitly has an 'any' type.
node_modules/ng2-uploader/src/directives/ng-file-drop.ts(41,58): error TS7006: Parameter 'e' implicitly has an 'any' type.
node_modules/ng2-uploader/src/directives/ng-file-drop.ts(46,57): error TS7006: Parameter 'e' implicitly has an 'any' type.
node_modules/ng2-uploader/src/directives/ng-file-select.ts(21,39): error TS7006: Parameter 'data' implicitly has an 'any' type.

I'm using the "base" hero tour, and the application starts with the standard config:
"start": "tsc  && concurrently \"tsc -w\" \"lite-server\" "

Tell me what needs to be corrected in order for the compiler to miss this type?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2016-07-06
@Scorpiored88

The TypeScript compiler has a noImplicitAny flag that controls how the case when no type is specified is handled. In your case, the parameter does not have a type specified and noImplicitAny is enabled, so TypeScript swears.
Put in tsconfig.json in compiler options "noImplicitAny": false

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question