After Updating to Angular 2 RC I got the following error:
error TS7008: Member 'summary' implicitly has an 'any' type.
in this line:
@Input() summary;
what's wrong?
Edit: Ok, seem like I get this error on ANY of my public variables.
Perhaps you changed the value of the noImplicitAny
attribute in your TypeScript compiler configuration... See the tsconfig.json file:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false // <-----
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
You could try to add a type on your property. Something like:
@Input() summary:string;
This question already has correct answers, however to clarify and fully explain:
Solution 1 - Set this in your tsconfig.json:
"noImplicitAny": false
Solution 2 Define the type for your variable like this:
@Input() summary:string;
Explanation:
If you are converting plain JavaScript to TypeScript, you won't have any types assigned to your variables (or parameters) - since strict typing is what gives TypeScript its name.
In this case, when you have something like this variable (which has no type assigned):
@Input() summary;
Then TypeScript will implicitly assume that your variable has a type of 'Any' (i.e. it assumes that the variable can hold a value of any type). Furthermore, if you have the following set in your tsconfig.json:
{
"compilerOptions": {
...
"noImplicitAny": true,
}
}
... then this tells the TypeScript compiler to throw errors if a variable or parameter implicitly has the 'Any' type. So, you can use the 1st solution to ignore all 'implicit any' errors, or use the 2nd solution (supply a type), and 'any' will not be implied.
Reference for TypeScript compiler options:
https://www.typescriptlang.org/docs/handbook/compiler-options.html
just comment out this "noImplicitAny": false
in tsconfig
and it will work
In Angular 12+ "strict": false,
in tsconfig.json worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With