3 ms·
You're missing a key point here, this is JavaScript, so there is no type annotations. And even if there were and inference was available as well then in most of
by danielEM 4y ago
You're missing a key point here, this is JavaScript, so there is no type annotations. And even if there were and inference was available as well then in most of cases I don't think you would need to annotate a type of function, as at some point it would 'blow up your face' anyway when mismatch of types.
- WirelessGigabit 4y ago// bar.foo is number // getFoo() returns a number bar.foo += getFoo(); // getFoo() has a bug and now returns a string. Nothing fails. If getFoo() had a return type of number this wouldn’t be the case.
- IshKebab 4y agoJavaScript has type annotations, they're called Typescript. And this doesn't seem to be sold as an automated way to convert JS code to TS (which would be really useful). It seems like they intend for you to stick to pure JS code which makes no sense really. > at some point it would 'blow up your face' anyway I'm not sure exactly what you're saying but yes you do need to annotate the types of functions. Global type inference is possible but it has performance issues, makes type errors way harder to debug and obscures the intent of code. Types are a part of your interface. They should be stated, not inferred. I would rather things didn't blow my face up.