#Why Am I not getting error for adding any types.

8 messages · Page 1 of 1 (latest)

past trail
#
function add(a:any, b:any):number{
    return a+b;
}
var d =add('john','max');
console.log(d);

Not sure if I am crazy to expect and error here ? According to me I should to error even before running it. coz, cant add 2 any's to expect them to be number

woven nimbus
#

you don't expect anything with any. any disables typechecking

#

sounds like you're looking for the behavior of unknown

drowsy linden
#

well... i think unknown would type error here

#

generics wouldn't help either

woven nimbus
drowsy linden
#

right

#

but it'd still type error on add(1, 2)