findFirstNodeAbove should check original node · Issue #1622 · TypeScriptToLua/TypeScriptToLua · GitHub
Skip to content

findFirstNodeAbove should check original node #1622

Closed

Description

@pilaoda

current may be a Synthesized node and has no parent attribute. This cause isInAsyncFunction return false incorrectly.

a possible fix:

export function findFirstNodeAbove<T extends ts.Node>(node: ts.Node, callback: (n: ts.Node) => n is T): T | undefined {
    let current = ts.getOriginalNode(node);
    while (current.parent) {
        if (callback(current.parent)) {
            return current.parent;
        } else {
            current = ts.getOriginalNode(current.parent);
        }
    }
}

Activity

  1. RealColdFry commented on Apr 16, 2026

    @RealColdFry
    Contributor

    looking for more synth node leaks...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions