3 ms·
The only things that put me off about typescript are: a) The lack of a proper 'is' keyword. The current behaviour around this is mental. b) The unneeded compl
by knocte 8y ago
The only things that put me off about typescript are:
a) The lack of a proper 'is' keyword. The current behaviour around this is mental.
b) The unneeded complexity that the recent releases have brought to the typing system.
- Double_a_92 8y agoTo be fair, checking objects with "is" is somewhat of an antipattern.
- Too 8y agoDo you mean instanceof? The javascript operator still works as before? Though typescript is designed around interfaces/ducktyping, which is almost the opposite of instanceof; as long as a type satisfies the interface constraints it walks like a duck and should be sufficient.
- mathw 8y agoMaybe they should have had a "quackslike" operator :)
- sime2009 8y agoTypeScript does support writing "quacksLike" functions. The feature is "type guards" and it lets you write a boolean function to test the type of an argument, and TS's flow control code understands it at compile time. const something: Animal = ... if (isDuck(something)) { someThing.quack(); // TS can OK this }