From 2fa3d94c92b4b49b1f362a431a494835b01b307d Mon Sep 17 00:00:00 2001 From: Daniel Espeset Date: Mon, 24 Jul 2017 13:03:04 -0400 Subject: [PATCH] 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. --- types/estree/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/estree/index.d.ts b/types/estree/index.d.ts index 64731a6895..23c5b19f86 100644 --- a/types/estree/index.d.ts +++ b/types/estree/index.d.ts @@ -58,6 +58,7 @@ export interface Program extends BaseNode { type: "Program"; sourceType: "script" | "module"; body: Array; + comments?: Array; } interface BaseFunction extends BaseNode { @@ -89,6 +90,7 @@ export interface EmptyStatement extends BaseStatement { export interface BlockStatement extends BaseStatement { type: "BlockStatement"; body: Array; + innerComments?: Array; } export interface ExpressionStatement extends BaseStatement {