fix(compiler): correct return in getOptional
MODIFY
internal/compiler/lib/VisitorState.ts
internal/compiler/lib/VisitorState.ts
@@ -72,10 +72,9 @@ export default class VisitorState<State extends UnknownObject>
public getOptional(find?: FindState<State>): undefined | State {
const index = this.getIndex(find);
if (index === -1) {
- throw new Error("VisitorState: Could not find stack");
- } else {
- return this.stack[index][0];
+ return undefined;
}
+ return this.stack[index][0];
}
public get(find?: FindState<State>): State {

fix(compiler): correct return in getOptional (#1527)