Choice of type constraint keyword: where vs extends

Topics: Language Specification
Jun 28, 2013 at 6:14 PM
The keyword used in TypeScript 0.9 for generic type constraint is "extends" (like Java's) instead of "where" (in C#). What is the reason for choosing "extends"? In my opinion, "where" is clearer in expressing the constraint, especially when there are more than 1.
Jun 29, 2013 at 6:02 PM
Edited Jun 29, 2013 at 6:22 PM
I agree, this is much more familiar to me, and much cleaner. where really does express it better
where T: SomeClass
And IMO:

And in many more cases I would like to change things to look like C# (instead of module: namespace; instead of extends: :, instead of import: using)...

I would really like it, but I don't think they will change that...

And customizing the compiler to recognize these syntax would be a bad idea, the code would not be in the right syntax for others...
Jun 30, 2013 at 9:12 AM
I figure the reason is probably because it more closely maps the JavaScript code. The Typescript team does not like to inject their own code into your files, so they make their standards as close to JavaScript as possible.

In (the CommonJS) JavaScript specification module.exports is already specified, however the where keyword is not, so my guess is that they chose to go with what is already in a specification rather than inventing their own new way of importing stuff.