mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 20:44:53 -05:00
Loosen restriction on usages in innermost scope
Now that we're smarter about where we declare the extracted local, we can ignore usage problems in the innermost script - it'll always have access to the same symbols as the extracted expression.
This commit is contained in:
@@ -1349,7 +1349,10 @@ namespace ts.refactor.extractSymbol {
|
||||
for (let i = 0; i < scopes.length; i++) {
|
||||
if (!isReadonlyArray(targetRange.range)) {
|
||||
const scopeUsages = usagesPerScope[i];
|
||||
if (scopeUsages.usages.size > 0 || scopeUsages.typeParameterUsages.size > 0) {
|
||||
// Special case: in the innermost scope, all usages are available.
|
||||
// (The computed value reflects the value at the top-level of the scope, but the
|
||||
// local will actually be declared at the same level as the extracted expression).
|
||||
if (i > 0 && (scopeUsages.usages.size > 0 || scopeUsages.typeParameterUsages.size > 0)) {
|
||||
constantErrorsPerScope[i].push(createDiagnosticForNode(targetRange.range, Messages.CannotAccessVariablesFromNestedScopes));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user