mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00: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:
1 parent
c08308a0f1
commit
bcc93f2c08
4 files changed
+41
-17
No files matched your search
@@ -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