Description
🔎 Search Terms
Lexical environment is not suspended
🕗 Version & Regression Information
- This is a crash (assert error)
4.9.5
I try to use the master bransh, and have the same problem
⏯ Playground Link
No response
💻 Code
function f(): {get a(): void} | void {}
🙁 Actual behavior
function f(): {get a(): void} | void {}
this code won't report error in playground, but if we parse this code and use visitEachChild to visit each node with transform context we will have crash like
Error: Debug Failure. False expression: Lexical environment is suspended.
the test code:
const ts = require("typescript")
function test2() {
const sourceCode = "function f(): {get a(): void} | void {}";
const result = ts.transpileModule(sourceCode, {
transformers: {before: [createVisiter] }
})
console.log(result.outputText);
}
function createVisiter(context) {
return (node) => visit(node);
function visit(node) {
return ts.visitEachChild(node, visit, context);
}
}
test2()
🙂 Expected behavior
don't have assert error when we visitEachChild
Additional information about the issue
seems the reason is that we set lexicalEnvironmentSuspended
as true after visit ParameterList, and before visit FunctionBody. But if we have something between ParameterList and FunctionBody and need check lexicalEnvironmentSuspended
, we will have assert error. like get/set accessor
so if we add a objectliteral type with get/set accessor as the return type of a function or method or get/set accessor, we will have crash when we use visitEachChild to visit the nodes
Is it a bug? or I use something wrong?