Expands support for Esprima comments (#18182)

Adds an optional `comments` field to the `Program`, which will be present 
if the AST is created with Esprima using the `{ comments: true }` option.

Adds an optional `innerComments` field to `BlockStatement` which will be
present if the AST is created with Esprima using the `{ attachComments: true }`
option, given the following code:

```.js
function foo(n) {
    // comments in an empty block are `innerComments`
}
```

Note that though these fields are not specified in the ESTree specification
they extend the support already present in this set of types for 
`trailingComments` and `leadingComments`, which are also unspecified.
This commit is contained in:
Daniel Espeset
2017-07-24 10:03:04 -07:00
committed by Andy
parent 67a886f023
commit 2fa3d94c92
+2
View File
@@ -58,6 +58,7 @@ export interface Program extends BaseNode {
type: "Program";
sourceType: "script" | "module";
body: Array<Statement | ModuleDeclaration>;
comments?: Array<Comment>;
}
interface BaseFunction extends BaseNode {
@@ -89,6 +90,7 @@ export interface EmptyStatement extends BaseStatement {
export interface BlockStatement extends BaseStatement {
type: "BlockStatement";
body: Array<Statement>;
innerComments?: Array<Comment>;
}
export interface ExpressionStatement extends BaseStatement {