My wish list for the Holidays

Topics: General
Nov 27, 2012 at 3:12 PM

To learn TypeScript and to refresh my JavaScript I decided to port an old game of mine that was originally written in C# and later ported to Android/Java. Here is some feedback on TS after using it daily for a month.
I really like TS and the VS integration, the preview has its issues but I know this is just a beta version.
Wish list #1 – Having to type “this” within class scoped code is driving me crazy.
Wish list #2 – conditional compilation = support for #if #else. I would really like to be able to automatically remove debug code when compiling for release.
Wish list #3 – generics
Wish list #4 – iterators - the C# “yield” feature to write iterators
Wish list #5 – partial classes – so used from C# to split larger classes into smaller chunks – for example, I like to place every interface a class implements in its own file.
Wish list #6 - VS support for TS libraries ala C# (and please get rid of the XML syntax for referencing files) My style is to place every class in its own TS file and use the tsc feature to combine all files into one js file. To not go crazy I make every ts file include all other ts files by referencing a “project.ts” file.
Wish list #7 - Constructor overloading
Wish list #8 - Method overloading
Wish list #9 – Extension methods (for extending system classes like HtmlElement, String and Date)
Wish list #10 – Support for "protected" as well as "internal"
The ported game can be found at http://www.BackSpinSoftware.com/PlayWithFIAR (Only works in ES5 browsers)

---bjorn

Coordinator
Nov 27, 2012 at 4:00 PM

Thanks for the feedback.

There are feature requests in the issue tracker for many of these (eg Generics: http://typescript.codeplex.com/workitem/185 and protected: http://typescript.codeplex.com/workitem/125).  If you have time, please vote on those issues and help out by adding good motivating examples in the comments.

 

Nov 28, 2012 at 9:43 AM

 

> Having to type “this” within class scoped code is driving me crazy.

Assuming the context is class MyClass {   private myProp = 10;  myMethod(){  myProp = 11; // instead of this.myProp = 11    } }

Prefixing fields with "this" is not entirely unreasonable. In fact it is enforced by certain systems such as StyleCop (rule SA1101). See also the discussion on stackoverflow. Quote from the accepted (though not top voted) answer: 

It can make code clearer at a glance. When you use this, it's easier to:

  • Tell static and instance members apart. (And distinguish instance methods from delegates.)
  • Distinguish instance members from local variables and parameters (without using a naming convention).

 

> partial classes – so used from C# to split larger classes into smaller chunks – for example, I like to place every interface a class implements in its own file.

Partial classes should ideally only be used to separate auto-generated code from user-written code - not for splitting up a large class into smaller chunks.

 

Noel