Strange compiler problem

Topics: General, Language Specification
Dec 5, 2012 at 5:27 AM

Hi, i have these 2 (nearly identical modules in out typesafe project) both are basically the same, but one is using the function shorthand method.
when we run these through the compiler the first "ModOne" compiles correctly even thou me1 is not valid
the 2nd works correctly and gives us an error in the compiler.

anyone got ant thoughts as to why?


module ModOne { // Class export class DirectoryManager1 { AttachDeleteEvents2(): void { $('.ui-btn-delete').click((e) => { var d: number = SDAFewf1; var selectedIDs: number[] = me1.GetSelectedIDs() }); } } } module ModTwo { // Class export class DirectoryManager1 { AttachDeleteEvents2(): void { $('.ui-btn-delete').click(function (e) : void { var d: number = SDAFewf2; var selectedIDs: number[] = me2.GetSelectedIDs() }); } } }

Coordinator
Dec 5, 2012 at 5:31 PM

I'm not quite sure I follow.

In your example, are you saying that me1 should not be visible from the lambda in ModOne, but me2 should be visible from the function(e) in ModTwo? 

Dec 5, 2012 at 8:17 PM

No sorry i should have been clearer 

 

if you run tsc.exe against this TS file, the compiler misses the fact that SDAFewf1 and me1 do not exist in the current scope, the 2nd module both variables are flagged as errors correctly so using the short hand (e) => {} function must be at fault