This project is read-only.

Compiler can't handle String vs. string very well

Topics: Language Specification
Nov 16, 2012 at 9:56 PM
Edited Nov 16, 2012 at 9:58 PM

I accidentally tried to overload a method as follows - note the incorrect use of uppercase "String".

public static getKeyCode(value: String): number;

Everything was building fine until I tried to call the method, e.g. StringUtility.getKeyCode("a"); Suddenly the compiler would fail with exit code 1, but with no useful error message at all. After quite awhile, I finally realized my mistake:

public static getKeyCode(value: string): number;

Now everything compiles and runs fine, but I found that to be a tricky bug to track down, especially since String is a valid type. I would've at least expected an error message complaining about me using the wrong type.

Nov 20, 2012 at 4:01 PM

Failing without an error message is definitely a bug.  Copying this over to the issue tracker.

Nov 20, 2012 at 4:01 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.