"It is a feature not a bug". Having to declare local variables in the scope 
that contains all the code that’s going to use them allows you to control what 
the variables are exposed to, it prevents you from writing or reading someone 
else’s variable, and it serves as documentation.

Agus
On May 28, 2020, 2:37 PM -0300, Mohsen Azimi <[email protected]>, wrote:
> Hi,
>
> I was looking at our test code and noticed we do this variable declaration 
> gymnastic to get it to work:
>
> describe('thing', () => {
> let thing: Thing;
> beforeEach(() => {
> thing = new Thing()
> })
> it('does one thing', () => {
> thing.oneThing()
> })
> it('does other things', () => {
> thing.otherThings()
> })
> })
>
> To me, the declaration of thing and binding it in the beforeEach block seemed 
> kind of weird. In an ideal world I would declare thing in my beforeEach block 
> and via language features communicate that scope of beforeEach's callback and 
> describe's callback above should be the same.
>
> Has this come up before? Has there been proposals to address this issue?
> --
> Mohsen Azimi
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to