|
export function findFirstNodeAbove<T extends ts.Node>(node: ts.Node, callback: (n: ts.Node) => n is T): T | undefined { |
|
let current = node; |
|
while (current.parent) { |
|
if (callback(current.parent)) { |
|
return current.parent; |
|
} else { |
|
current = current.parent; |
|
} |
|
} |
|
} |
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);
}
}
}
TypeScriptToLua/src/transformation/utils/typescript/index.ts
Lines 16 to 25 in 6fb39b6
currentmay be aSynthesizednode and has no parent attribute. This causeisInAsyncFunctionreturn false incorrectly.a possible fix: