demo/typescript.js
function getThrowStatementOwner(throwStatement) {
                    var child = throwStatement;
                    while (child.parent) {
                        var parent_12 = child.parent;
                        if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248 /* SourceFile */) {
                            return parent_12;
                        }
                        // A throw-statement is only owned by a try-statement if the try-statement has
                        // a catch clause, and if the throw-statement occurs within the try block.
                        if (parent_12.kind === 209 /* TryStatement */) {
                            var tryStatement = parent_12;
                            if (tryStatement.tryBlock === child && tryStatement.catchClause) {
                                return child;
                            }
                        }
                        child = parent_12;
                    }
                    return undefined;
                }
function getThrowStatementOwner(throwStatement) {
                    var child = throwStatement;
                    while (child.parent) {
                        var parent_12 = child.parent;
                        if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248 /* SourceFile */) {
                            return parent_12;
                        }
                        // A throw-statement is only owned by a try-statement if the try-statement has
                        // a catch clause, and if the throw-statement occurs within the try block.
                        if (parent_12.kind === 209 /* TryStatement */) {
                            var tryStatement = parent_12;
                            if (tryStatement.tryBlock === child && tryStatement.catchClause) {
                                return child;
                            }
                        }
                        child = parent_12;
                    }
                    return undefined;
                }
For lack of a better name, this function takes a throw statement and returns the
nearest ancestor that is a try-block (whose try statement has a catch clause),
function-block, or source file.