You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Types are checked, but TypeScript has a structural type system. That means that some value is assignable to a type if it has (at least) all the properties of that type. Thus an object that has at least 0 properties is assignable to Biff. Every object has at least 0 properties, so the type Biff is basically equal to any. If you change Biff to:
Right, so even string and number are assignable to a type with an empty interface - yeah, I forget that's how this works and get confused sometimes because the type system syntax is so similar to other languages where this is not the case. Thanks!
Example:
The closures passed as arguments in the two calls at the end, do not appear to get type-checked.
It's pretty plain that these closures will not be invoked with suitable arguments, yet the code appears to compile with no complaints.
How come this doesn't get type-checked?
The text was updated successfully, but these errors were encountered: