You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm pretty sure that error reflects the behavior of our actual down level emit rather than the spec.
That's correct, but we already had that discussion in #22769. I'd argue that the emit should be changed to follow the spec. However, in #22769 (comment) there's the decision to change the lookup for ES6 and emit an error for ES5 and below (which means no change for that target).
That means it's still a bug if target is ES6 or above and still needs fixing.
TypeScript Version: 3.2.0-dev.20181101
Search Terms:
Code
Expected behavior:
No error.
baz
in the initializer references the outerlet baz = 2
.let baz = 1
is marked as unused.Actual behavior:
Error
Initializer of parameter 'bar' cannot reference identifier 'baz' declared after it.
At runtime: calling
foo()
returns2
, which shows that declarations in the function body are not in scope of parameter initializers.Note that other parameters are in scope and can be used inside other parameters' initializer.
Playground Link: https://agentcooper.github.io/typescript-play/#code/DYUwLgBARghgXhAvBATAbgFADMCuA7AYzAEsB7PCLU0gClgCckIaBKJAPmnjYG8MIBEAG4xGsBMgCMmQRHrgc9Cg1aYAvkA
Related Issues:
#22769
/cc @Kingwl maybe you want to give this a shot as well (I hope this doesn't cause as much trouble as the last one 😆)
The text was updated successfully, but these errors were encountered: