I have a function which only accepts a number variable.
function add(n1: number) {
return n1 + n1;
}
And I initialize an any variable and assign it a string of '5'
let number1;
number1 = '5';
I was wondering, why doesn't it show an error when I want to pass a string to the function?
console.log(add(number1));
(Of course it outputs 55, because the string is concatenated.)
noImplicitAnyselected. Go into the config and de-select it and the behavior you describe is observed.