mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 12:11:47 +00:00
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:
Vendored
+2
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user