user3875721
user3875721

Reputation:

angular2 aot compile. What does implicitly has an 'any' type mean and how to correct it?

TypeScript compile

tsc -w -p  tsconfig-aot.json

get many error

app/admin/appeals_messages/appeals_messages.components.ts(22,5): error TS7008: Member 'userInfo' implicitly has an 'any' type. app/admin/appeals_messages/appeals_messages.components.ts(33,5): error TS7008: Member 'error' implicitly has an 'any' type. app/admin/appeals_messages/appeals_messages.components.ts(64,40): error TS2339: Property 'data' does not exist on type 'Params'. app/admin/appeals_messages/appeals_messages.components.ts(70,17): error TS7006: Parameter 'res' implicitly has an 'any' type.

.....

Why arise it's error? TypeScript is backward compatible with js language and in theory must skip its error because i write its code as js-code? Mabe have a way to collect it with its error, because tsc with out aot collect app and it work?

Help, please

Upvotes: 0

Views: 793

Answers (1)

FabianGosebrink
FabianGosebrink

Reputation: 337

The errors says nothing else than that the variable has no type declared. So Typescript is assuming that this is an "any" type which is why its "implicitly".

In your tsConfig.json is a line where you can configure the behaviour:

"noImplicitAny": false

But it would be better to give this variable a type or declare it as "any". Then its explicitly set and the error should be gone.

Upvotes: 4

Related Questions