mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-13 22:00:59 -05:00
fix(42678): detect access to uninitialized variable in IIFE (#42776)
* fix(42678): detect access to uninitialized variable in IIFE * improve performance * Add missing space to match coding guidelines * simplify the implementation Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
This commit is contained in:
@@ -2536,10 +2536,12 @@ namespace ts {
|
||||
|
||||
/* Starting from 'initial' node walk up the parent chain until 'stopAt' node is reached.
|
||||
* If at any point current node is equal to 'parent' node - return true.
|
||||
* If current node is an IIFE, continue walking up.
|
||||
* Return false if 'stopAt' node is reached or isFunctionLike(current) === true.
|
||||
*/
|
||||
function isSameScopeDescendentOf(initial: Node, parent: Node | undefined, stopAt: Node): boolean {
|
||||
return !!parent && !!findAncestor(initial, n => n === stopAt || isFunctionLike(n) ? "quit" : n === parent);
|
||||
return !!parent && !!findAncestor(initial, n => n === parent
|
||||
|| (n === stopAt || isFunctionLike(n) && !getImmediatelyInvokedFunctionExpression(n) ? "quit" : false));
|
||||
}
|
||||
|
||||
function getAnyImportSyntax(node: Node): AnyImportSyntax | undefined {
|
||||
|
||||
Reference in New Issue
Block a user