What parse returns
parse returns an object. It always has two keys: the node, and where the parse stopped.
const { node, end } = source.parse();node is the tree. Every node in it has start and end, offsets into the text you gave the Source. The end beside node is the offset where the parse stopped reading. For a whole program that is the end of the text.
These pages call that object the answer.
Options
Each option adds one key to the answer, or one property to the nodes. A key is present only when its option is on.
locationsputsloc, with line and column, on every node.commentsaddscomments, every comment in source order, and putsleadingComments,trailingCommentsandinnerCommentson the nodes.scopesaddsscopes,bindingsandreferences, and lets you ask any node what it declares or refers to. See Scopes.errorRecoveryaddserrorsand returns a tree instead of throwing. See Errors.typescriptreads TypeScript.typescript: 'erase'also removes it, and addstypescript, the list of what could not be removed. See TypeScript.parenthesizedputsparenthesized: trueon every node that was written in parentheses.sourceType: 'module'reads strict code, withimport,exportand top-levelawait.scopes, on a file read with a grammar, also addsroots, one entry per piece of JavaScript in it. See Parsing with a grammar.
Every option, with its type and default, is in the reference.
Positions
Offsets are UTF-16, the way JavaScript strings count. They are offsets into the whole text, however small a piece you parsed, so nothing has to be added to them. The answer's end is past any closing parentheses around the node and any comment after it.