From 0e30ec708895417852c2cef31aa0b88ffe093537 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Tue, 4 Jun 2019 22:50:23 +0900 Subject: [PATCH 1/5] add Dynamic Imports and BigInt as ES2020 --- es2020.md | 48 +++++++++++++++++++++++++++++++ experimental/import-expression.md | 13 --------- 2 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 es2020.md delete mode 100644 experimental/import-expression.md diff --git a/es2020.md b/es2020.md new file mode 100644 index 0000000..8dcf8df --- /dev/null +++ b/es2020.md @@ -0,0 +1,48 @@ +This document specifies the extensions to the core ESTree AST types to support the ES2020 grammar. + +# Literal + +```js +extend interface Literal <: Expression { + type: "Literal"; + value: string | boolean | null | number | RegExp | bigint; +} +``` + +- `value` property can be a `BitInt` value to represent `BitInt` literals + such as `100n`. + +## BigIntLiteral + +```js +interface BigIntLiteral <: Literal { + bigint: string; +} +``` + +- `bigint` property is the string representation of the `BitInt` value. + It includes the suffix `n`. +- In environments that don't support `BitInt` values, `value` property will be + `null` as the `BigInt` value can't be represented natively. + +# Expressions + +## CallExpression + +```js +interface Import <: Node { + type: "Import"; +} +``` + +```js +extend interface CallExpression <: Expression { + callee: Expression | Super | Import; +} +``` + +- `callee` property can be an `Import` node to represent dynamic import syntax. + E.g. `import(source)`. +- If the `callee` property was an `Import` node, `arguments` property must be an + array that that length is `1`. The first element represents the importing + source. diff --git a/experimental/import-expression.md b/experimental/import-expression.md deleted file mode 100644 index 2d5122d..0000000 --- a/experimental/import-expression.md +++ /dev/null @@ -1,13 +0,0 @@ -# [Dynamic Import Expression](https://github.com/domenic/proposal-dynamic-import) - -## Import - -```js -interface Import <: Node { - type: "Import"; -} - -interface CallExpression <: Expression { - callee: Expression | Super | Import; -} -``` From 189782183eb43aa16da1f8829a8465d348f6a1af Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Wed, 5 Jun 2019 07:07:22 +0900 Subject: [PATCH 2/5] fix typos --- es2020.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/es2020.md b/es2020.md index 8dcf8df..4c7c2fb 100644 --- a/es2020.md +++ b/es2020.md @@ -9,7 +9,7 @@ extend interface Literal <: Expression { } ``` -- `value` property can be a `BitInt` value to represent `BitInt` literals +- `value` property can be a `BigInt` value to represent `BigInt` literals such as `100n`. ## BigIntLiteral @@ -20,9 +20,9 @@ interface BigIntLiteral <: Literal { } ``` -- `bigint` property is the string representation of the `BitInt` value. +- `bigint` property is the string representation of the `BigInt` value. It includes the suffix `n`. -- In environments that don't support `BitInt` values, `value` property will be +- In environments that don't support `BigInt` values, `value` property will be `null` as the `BigInt` value can't be represented natively. # Expressions From 62859d78bbebe3176a7c99ab68bca1cce85a5c18 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Wed, 5 Jun 2019 08:18:24 +0900 Subject: [PATCH 3/5] make `bigint` property not including `n` --- es2020.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/es2020.md b/es2020.md index 4c7c2fb..e1df9ff 100644 --- a/es2020.md +++ b/es2020.md @@ -21,7 +21,7 @@ interface BigIntLiteral <: Literal { ``` - `bigint` property is the string representation of the `BigInt` value. - It includes the suffix `n`. + It doesn't include the suffix `n`. - In environments that don't support `BigInt` values, `value` property will be `null` as the `BigInt` value can't be represented natively. From a7ed03d1a59982e956823fb084072ba1848fa137 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Wed, 5 Jun 2019 17:37:35 +0900 Subject: [PATCH 4/5] change dynamic imports AST --- es2020.md | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/es2020.md b/es2020.md index e1df9ff..7796222 100644 --- a/es2020.md +++ b/es2020.md @@ -27,22 +27,17 @@ interface BigIntLiteral <: Literal { # Expressions -## CallExpression +## ImportExpression ```js -interface Import <: Node { - type: "Import"; +interface ImportExpression <: Expression { + type: "ImportExpression"; + source: Expression; } ``` -```js -extend interface CallExpression <: Expression { - callee: Expression | Super | Import; -} -``` +- `ImportExpression` node represents Dynamic Imports such as `import(source)`. + The `source` property is the importing source as similar to [ImprotDeclaration] + node, but it can be an arbitrary expression node. -- `callee` property can be an `Import` node to represent dynamic import syntax. - E.g. `import(source)`. -- If the `callee` property was an `Import` node, `arguments` property must be an - array that that length is `1`. The first element represents the importing - source. +[ImprotDeclaration]: es2015.md#importdeclaration From 167a8a804373d026155039114e7353ad5c16a1f0 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Wed, 12 Jun 2019 02:56:42 +0900 Subject: [PATCH 5/5] fix typo --- es2020.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/es2020.md b/es2020.md index 7796222..8cefd9e 100644 --- a/es2020.md +++ b/es2020.md @@ -37,7 +37,7 @@ interface ImportExpression <: Expression { ``` - `ImportExpression` node represents Dynamic Imports such as `import(source)`. - The `source` property is the importing source as similar to [ImprotDeclaration] + The `source` property is the importing source as similar to [ImportExpression] node, but it can be an arbitrary expression node. -[ImprotDeclaration]: es2015.md#importdeclaration +[ImportExpression]: es2015.md#importdeclaration