├── .eslintrc.js ├── .gitattributes ├── .github └── workflows │ └── check.yml ├── .gitignore ├── LICENSE ├── README.md ├── checked.js ├── gen ├── checked.d.ts ├── checked.js ├── index.d.ts └── index.js ├── package-lock.json ├── package.json ├── scripts ├── generate-checked.js ├── generate-dts.js └── generate.js └── test ├── .eslintrc.js ├── basic.js └── tsconfig.json /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: 'eslint:recommended', 3 | env: { 4 | es6: true, 5 | node: true, 6 | browser: false, 7 | }, 8 | parserOptions: { 9 | sourceType: 'module', 10 | }, 11 | plugins: [], 12 | rules: { 13 | 'arrow-parens': ['error', 'as-needed'], 14 | 'array-bracket-spacing': ['error', 'never'], 15 | 'brace-style': ['error', '1tbs'], 16 | 'camelcase': 'error', 17 | 'comma-dangle': ['error', 'always-multiline'], 18 | 'comma-spacing': ['error', { before: false, after: true }], 19 | 'comma-style': ['error', 'last'], 20 | 'computed-property-spacing': ['error', 'never'], 21 | 'consistent-return': 'error', 22 | 'consistent-this': ['error', 'self'], 23 | 'curly': ['error', 'multi-line'], 24 | 'dot-notation': 'error', 25 | 'eol-last': 'error', 26 | 'eqeqeq': ['error', 'smart'], 27 | 'guard-for-in': 'error', 28 | 'indent': ['error', 2, { SwitchCase: 1, VariableDeclarator: { var: 2, let: 2, const: 3 } }], 29 | 'key-spacing': ['error', { beforeColon: false, afterColon: true }], 30 | 'keyword-spacing': 'error', 31 | 'max-len': ['warn', 120], 32 | 'no-alert': 'error', 33 | 'no-caller': 'error', 34 | 'no-catch-shadow': 'error', 35 | 'no-console': 'warn', 36 | 'no-else-return': 'error', 37 | 'no-empty': ['error', { allowEmptyCatch: true }], 38 | 'no-eval': 'error', 39 | 'no-extend-native': 'error', 40 | 'no-extra-bind': 'error', 41 | 'no-extra-parens': 'warn', 42 | 'no-fallthrough': 'error', 43 | 'no-floating-decimal': 'error', 44 | 'no-implied-eval': 'error', 45 | 'no-inner-declarations': ['error', 'both'], 46 | 'no-lonely-if': 'error', 47 | 'no-loop-func': 'error', 48 | 'no-mixed-spaces-and-tabs': 'error', 49 | 'no-multi-spaces': 'error', 50 | 'no-multiple-empty-lines': ['error', { max: 2 }], 51 | 'no-negated-condition': 'error', 52 | 'no-param-reassign': 'warn', 53 | 'no-redeclare': 'error', 54 | 'no-return-assign': 'error', 55 | 'no-self-compare': 'error', 56 | 'no-sequences': 'error', 57 | 'no-shadow-restricted-names': 'error', 58 | 'no-spaced-func': 'error', 59 | 'no-trailing-spaces': 'error', 60 | 'no-undef': 'error', 61 | 'no-undefined': 'error', 62 | 'no-underscore-dangle': 'off', 63 | 'no-unused-vars': ['error', { vars: 'all', args: 'after-used' }], 64 | 'no-use-before-define': ['error', 'nofunc'], 65 | 'no-useless-call': 'error', 66 | 'no-useless-escape': 'error', 67 | 'no-var': 'error', 68 | 'no-warning-comments': 'off', 69 | 'no-with': 'error', 70 | 'object-curly-spacing': ['error', 'always'], 71 | 'object-shorthand': ['error', 'always'], 72 | 'prefer-arrow-callback': ['error'], 73 | 'quotes': ['error', 'single'], 74 | 'semi': ['error', 'always'], 75 | 'semi-spacing': ['error', { before: false, after: true }], 76 | 'space-before-blocks': 'error', 77 | 'space-before-function-paren': ['error', { anonymous: 'always', named: 'never' }], 78 | 'space-in-parens': 'error', 79 | 'space-infix-ops': 'error', 80 | 'space-unary-ops': 'error', 81 | 'spaced-comment': ['warn', 'always', { block: { markers: ['!'], exceptions: ['*'] } }], 82 | 'strict': 'off', 83 | 'valid-jsdoc': 'warn', 84 | 'wrap-iife': ['error', 'outside'], 85 | 'yoda': ['error', 'never'], 86 | }, 87 | }; 88 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | gen/* linguist-generated=true 2 | -------------------------------------------------------------------------------- /.github/workflows/check.yml: -------------------------------------------------------------------------------- 1 | name: check 2 | 3 | on: 4 | push: 5 | branches: 6 | - es2019 7 | pull_request: 8 | 9 | jobs: 10 | pre: 11 | name: Prerequisites 12 | if: github.event_name == 'pull_request' 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v2 18 | with: 19 | fetch-depth: 0 20 | 21 | - name: Enforce CLA signature 22 | env: 23 | COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} 24 | run: curl https://raw.githubusercontent.com/shapesecurity/CLA/HEAD/cla-check.sh | bash 25 | 26 | check: 27 | needs: pre 28 | if: | 29 | !cancelled() && !failure() 30 | runs-on: ubuntu-latest 31 | 32 | strategy: 33 | matrix: 34 | node: [14, 16, 18] 35 | 36 | name: Check - node ${{ matrix.node }} 37 | 38 | steps: 39 | - name: Checkout 40 | uses: actions/checkout@v2 41 | 42 | - name: Setup node 43 | uses: actions/setup-node@v2 44 | with: 45 | node-version: ${{ matrix.node }} 46 | 47 | - name: Install dependencies 48 | run: npm ci 49 | 50 | - name: Build 51 | run: npm run build 52 | 53 | - name: Lint 54 | run: npm run lint -- --quiet 55 | 56 | - name: Test 57 | run: npm test 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | dist 4 | coverage 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Shift AST Constructors 2 | ====================== 3 | 4 | 5 | ## About 6 | 7 | This project provides constructors for 8 | [Shift format](https://github.com/shapesecurity/shift-spec) AST nodes. 9 | 10 | The resulting objects are suitable for use with the rest of the [Shift suite](http://shift-ast.org/). 11 | 12 | There is a version with typechecking available as `shift-ast/checked` for use during development. 13 | 14 | ## Status 15 | 16 | [Stable](http://nodejs.org/api/documentation.html#documentation_stability_index). 17 | 18 | 19 | ## Installation 20 | 21 | ```sh 22 | npm install shift-ast 23 | ``` 24 | 25 | 26 | ## Usage 27 | 28 | ```js 29 | var AST = require("shift-ast"); // or "shift-ast/checked" 30 | var myAstFragment = new AST.LabeledStatement({ 31 | label: "label", 32 | body: new AST.EmptyStatement 33 | }); 34 | ``` 35 | 36 | 37 | ## Contributing 38 | 39 | * Open a Github issue with a description of your desired change. If one exists already, leave a message stating that you are working on it with the date you expect it to be complete. 40 | * Fork this repo, and clone the forked repo. 41 | * Install dependencies with `npm install`. 42 | * Build and test in your environment with `npm run build && npm test`. 43 | * Create a feature branch. Make your changes. Add tests. 44 | * Build and test in your environment with `npm run build && npm test`. 45 | * Make a commit that includes the text "fixes #*XX*" where *XX* is the Github issue. 46 | * Open a Pull Request on Github. 47 | 48 | 49 | ## License 50 | 51 | Copyright 2014 Shape Security, Inc. 52 | 53 | Licensed under the Apache License, Version 2.0 (the "License"); 54 | you may not use this file except in compliance with the License. 55 | You may obtain a copy of the License at 56 | 57 | http://www.apache.org/licenses/LICENSE-2.0 58 | 59 | Unless required by applicable law or agreed to in writing, software 60 | distributed under the License is distributed on an "AS IS" BASIS, 61 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 62 | See the License for the specific language governing permissions and 63 | limitations under the License. 64 | -------------------------------------------------------------------------------- /checked.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Shape Security, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License") 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module.exports = require('./gen/checked'); 18 | -------------------------------------------------------------------------------- /gen/checked.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by scripts/generate-dts.js. 2 | 3 | /** 4 | * Copyright 2019 Shape Security, Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License") 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | export * from './index'; 20 | -------------------------------------------------------------------------------- /gen/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by scripts/generate-dts.js. 2 | 3 | /** 4 | * Copyright 2019 Shape Security, Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License") 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | type Init = Pick>; 20 | 21 | export type Node = ArrayAssignmentTarget | ArrayBinding | ArrayExpression | ArrowExpression | AssignmentExpression | AssignmentTargetIdentifier | AssignmentTargetPropertyIdentifier | AssignmentTargetPropertyProperty | AssignmentTargetWithDefault | AwaitExpression | BinaryExpression | BindingIdentifier | BindingPropertyIdentifier | BindingPropertyProperty | BindingWithDefault | Block | BlockStatement | BreakStatement | CallExpression | CatchClause | ClassDeclaration | ClassElement | ClassExpression | CompoundAssignmentExpression | ComputedMemberAssignmentTarget | ComputedMemberExpression | ComputedPropertyName | ConditionalExpression | ContinueStatement | DataProperty | DebuggerStatement | Directive | DoWhileStatement | EmptyStatement | Export | ExportAllFrom | ExportDefault | ExportFrom | ExportFromSpecifier | ExportLocalSpecifier | ExportLocals | ExpressionStatement | ForAwaitStatement | ForInStatement | ForOfStatement | ForStatement | FormalParameters | FunctionBody | FunctionDeclaration | FunctionExpression | Getter | IdentifierExpression | IfStatement | Import | ImportNamespace | ImportSpecifier | LabeledStatement | LiteralBooleanExpression | LiteralInfinityExpression | LiteralNullExpression | LiteralNumericExpression | LiteralRegExpExpression | LiteralStringExpression | Method | Module | NewExpression | NewTargetExpression | ObjectAssignmentTarget | ObjectBinding | ObjectExpression | ReturnStatement | Script | Setter | ShorthandProperty | SpreadElement | SpreadProperty | StaticMemberAssignmentTarget | StaticMemberExpression | StaticPropertyName | Super | SwitchCase | SwitchDefault | SwitchStatement | SwitchStatementWithDefault | TemplateElement | TemplateExpression | ThisExpression | ThrowStatement | TryCatchStatement | TryFinallyStatement | UnaryExpression | UpdateExpression | VariableDeclaration | VariableDeclarationStatement | VariableDeclarator | WhileStatement | WithStatement | YieldExpression | YieldGeneratorExpression; 22 | 23 | export type Expression = ArrayExpression | ArrowExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ClassExpression | CompoundAssignmentExpression | ConditionalExpression | FunctionExpression | IdentifierExpression | LiteralBooleanExpression | LiteralInfinityExpression | LiteralNullExpression | LiteralNumericExpression | LiteralRegExpExpression | LiteralStringExpression | ComputedMemberExpression | StaticMemberExpression | NewExpression | NewTargetExpression | ObjectExpression | TemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | YieldGeneratorExpression; 24 | 25 | export type Statement = BlockStatement | BreakStatement | ClassDeclaration | ContinueStatement | DebuggerStatement | EmptyStatement | ExpressionStatement | FunctionDeclaration | IfStatement | DoWhileStatement | ForAwaitStatement | ForInStatement | ForOfStatement | ForStatement | WhileStatement | LabeledStatement | ReturnStatement | SwitchStatement | SwitchStatementWithDefault | ThrowStatement | TryCatchStatement | TryFinallyStatement | VariableDeclarationStatement | WithStatement; 26 | 27 | 28 | export class ArrayAssignmentTarget { 29 | type: 'ArrayAssignmentTarget'; 30 | elements: Array; 31 | rest: ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget | null; 32 | constructor(init: Init); 33 | } 34 | 35 | export class ArrayBinding { 36 | type: 'ArrayBinding'; 37 | elements: Array; 38 | rest: BindingIdentifier | ArrayBinding | ObjectBinding | null; 39 | constructor(init: Init); 40 | } 41 | 42 | export class ArrayExpression { 43 | type: 'ArrayExpression'; 44 | elements: Array; 45 | constructor(init: Init); 46 | } 47 | 48 | export class ArrowExpression { 49 | type: 'ArrowExpression'; 50 | isAsync: boolean; 51 | params: FormalParameters; 52 | body: Expression | FunctionBody; 53 | constructor(init: Init); 54 | } 55 | 56 | export class AssignmentExpression { 57 | type: 'AssignmentExpression'; 58 | binding: ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget; 59 | expression: Expression; 60 | constructor(init: Init); 61 | } 62 | 63 | export class AssignmentTargetIdentifier { 64 | type: 'AssignmentTargetIdentifier'; 65 | name: string; 66 | constructor(init: Init); 67 | } 68 | 69 | export class AssignmentTargetPropertyIdentifier { 70 | type: 'AssignmentTargetPropertyIdentifier'; 71 | binding: AssignmentTargetIdentifier; 72 | init: Expression | null; 73 | constructor(init: Init); 74 | } 75 | 76 | export class AssignmentTargetPropertyProperty { 77 | type: 'AssignmentTargetPropertyProperty'; 78 | name: ComputedPropertyName | StaticPropertyName; 79 | binding: AssignmentTargetWithDefault | ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget; 80 | constructor(init: Init); 81 | } 82 | 83 | export class AssignmentTargetWithDefault { 84 | type: 'AssignmentTargetWithDefault'; 85 | binding: ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget; 86 | init: Expression; 87 | constructor(init: Init); 88 | } 89 | 90 | export class AwaitExpression { 91 | type: 'AwaitExpression'; 92 | expression: Expression; 93 | constructor(init: Init); 94 | } 95 | 96 | export class BinaryExpression { 97 | type: 'BinaryExpression'; 98 | left: Expression; 99 | operator: '==' | '!=' | '===' | '!==' | '<' | '<=' | '>' | '>=' | 'in' | 'instanceof' | '<<' | '>>' | '>>>' | '+' | '-' | '*' | '/' | '%' | '**' | ',' | '||' | '&&' | '|' | '^' | '&'; 100 | right: Expression; 101 | constructor(init: Init); 102 | } 103 | 104 | export class BindingIdentifier { 105 | type: 'BindingIdentifier'; 106 | name: string; 107 | constructor(init: Init); 108 | } 109 | 110 | export class BindingPropertyIdentifier { 111 | type: 'BindingPropertyIdentifier'; 112 | binding: BindingIdentifier; 113 | init: Expression | null; 114 | constructor(init: Init); 115 | } 116 | 117 | export class BindingPropertyProperty { 118 | type: 'BindingPropertyProperty'; 119 | name: ComputedPropertyName | StaticPropertyName; 120 | binding: BindingWithDefault | BindingIdentifier | ArrayBinding | ObjectBinding; 121 | constructor(init: Init); 122 | } 123 | 124 | export class BindingWithDefault { 125 | type: 'BindingWithDefault'; 126 | binding: BindingIdentifier | ArrayBinding | ObjectBinding; 127 | init: Expression; 128 | constructor(init: Init); 129 | } 130 | 131 | export class Block { 132 | type: 'Block'; 133 | statements: Array; 134 | constructor(init: Init); 135 | } 136 | 137 | export class BlockStatement { 138 | type: 'BlockStatement'; 139 | block: Block; 140 | constructor(init: Init); 141 | } 142 | 143 | export class BreakStatement { 144 | type: 'BreakStatement'; 145 | label: string | null; 146 | constructor(init: Init); 147 | } 148 | 149 | export class CallExpression { 150 | type: 'CallExpression'; 151 | callee: Expression | Super; 152 | arguments: Array; 153 | constructor(init: Init); 154 | } 155 | 156 | export class CatchClause { 157 | type: 'CatchClause'; 158 | binding: BindingIdentifier | ArrayBinding | ObjectBinding | null; 159 | body: Block; 160 | constructor(init: Init); 161 | } 162 | 163 | export class ClassDeclaration { 164 | type: 'ClassDeclaration'; 165 | name: BindingIdentifier; 166 | super: Expression | null; 167 | elements: Array; 168 | constructor(init: Init); 169 | } 170 | 171 | export class ClassElement { 172 | type: 'ClassElement'; 173 | isStatic: boolean; 174 | method: Getter | Method | Setter; 175 | constructor(init: Init); 176 | } 177 | 178 | export class ClassExpression { 179 | type: 'ClassExpression'; 180 | name: BindingIdentifier | null; 181 | super: Expression | null; 182 | elements: Array; 183 | constructor(init: Init); 184 | } 185 | 186 | export class CompoundAssignmentExpression { 187 | type: 'CompoundAssignmentExpression'; 188 | binding: AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget; 189 | operator: '+=' | '-=' | '*=' | '/=' | '%=' | '**=' | '<<=' | '>>=' | '>>>=' | '|=' | '^=' | '&='; 190 | expression: Expression; 191 | constructor(init: Init); 192 | } 193 | 194 | export class ComputedMemberAssignmentTarget { 195 | type: 'ComputedMemberAssignmentTarget'; 196 | object: Expression | Super; 197 | expression: Expression; 198 | constructor(init: Init); 199 | } 200 | 201 | export class ComputedMemberExpression { 202 | type: 'ComputedMemberExpression'; 203 | object: Expression | Super; 204 | expression: Expression; 205 | constructor(init: Init); 206 | } 207 | 208 | export class ComputedPropertyName { 209 | type: 'ComputedPropertyName'; 210 | expression: Expression; 211 | constructor(init: Init); 212 | } 213 | 214 | export class ConditionalExpression { 215 | type: 'ConditionalExpression'; 216 | test: Expression; 217 | consequent: Expression; 218 | alternate: Expression; 219 | constructor(init: Init); 220 | } 221 | 222 | export class ContinueStatement { 223 | type: 'ContinueStatement'; 224 | label: string | null; 225 | constructor(init: Init); 226 | } 227 | 228 | export class DataProperty { 229 | type: 'DataProperty'; 230 | name: ComputedPropertyName | StaticPropertyName; 231 | expression: Expression; 232 | constructor(init: Init); 233 | } 234 | 235 | export class DebuggerStatement { 236 | type: 'DebuggerStatement'; 237 | constructor(init?: Init); 238 | } 239 | 240 | export class Directive { 241 | type: 'Directive'; 242 | rawValue: string; 243 | constructor(init: Init); 244 | } 245 | 246 | export class DoWhileStatement { 247 | type: 'DoWhileStatement'; 248 | body: Statement; 249 | test: Expression; 250 | constructor(init: Init); 251 | } 252 | 253 | export class EmptyStatement { 254 | type: 'EmptyStatement'; 255 | constructor(init?: Init); 256 | } 257 | 258 | export class Export { 259 | type: 'Export'; 260 | declaration: ClassDeclaration | FunctionDeclaration | VariableDeclaration; 261 | constructor(init: Init); 262 | } 263 | 264 | export class ExportAllFrom { 265 | type: 'ExportAllFrom'; 266 | moduleSpecifier: string; 267 | constructor(init: Init); 268 | } 269 | 270 | export class ExportDefault { 271 | type: 'ExportDefault'; 272 | body: ClassDeclaration | Expression | FunctionDeclaration; 273 | constructor(init: Init); 274 | } 275 | 276 | export class ExportFrom { 277 | type: 'ExportFrom'; 278 | namedExports: Array; 279 | moduleSpecifier: string; 280 | constructor(init: Init); 281 | } 282 | 283 | export class ExportFromSpecifier { 284 | type: 'ExportFromSpecifier'; 285 | name: string; 286 | exportedName: string | null; 287 | constructor(init: Init); 288 | } 289 | 290 | export class ExportLocalSpecifier { 291 | type: 'ExportLocalSpecifier'; 292 | name: IdentifierExpression; 293 | exportedName: string | null; 294 | constructor(init: Init); 295 | } 296 | 297 | export class ExportLocals { 298 | type: 'ExportLocals'; 299 | namedExports: Array; 300 | constructor(init: Init); 301 | } 302 | 303 | export class ExpressionStatement { 304 | type: 'ExpressionStatement'; 305 | expression: Expression; 306 | constructor(init: Init); 307 | } 308 | 309 | export class ForAwaitStatement { 310 | type: 'ForAwaitStatement'; 311 | left: ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget | VariableDeclaration; 312 | right: Expression; 313 | body: Statement; 314 | constructor(init: Init); 315 | } 316 | 317 | export class ForInStatement { 318 | type: 'ForInStatement'; 319 | left: ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget | VariableDeclaration; 320 | right: Expression; 321 | body: Statement; 322 | constructor(init: Init); 323 | } 324 | 325 | export class ForOfStatement { 326 | type: 'ForOfStatement'; 327 | left: ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget | VariableDeclaration; 328 | right: Expression; 329 | body: Statement; 330 | constructor(init: Init); 331 | } 332 | 333 | export class ForStatement { 334 | type: 'ForStatement'; 335 | init: Expression | VariableDeclaration | null; 336 | test: Expression | null; 337 | update: Expression | null; 338 | body: Statement; 339 | constructor(init: Init); 340 | } 341 | 342 | export class FormalParameters { 343 | type: 'FormalParameters'; 344 | items: Array; 345 | rest: BindingIdentifier | ArrayBinding | ObjectBinding | null; 346 | constructor(init: Init); 347 | } 348 | 349 | export class FunctionBody { 350 | type: 'FunctionBody'; 351 | directives: Array; 352 | statements: Array; 353 | constructor(init: Init); 354 | } 355 | 356 | export class FunctionDeclaration { 357 | type: 'FunctionDeclaration'; 358 | isAsync: boolean; 359 | isGenerator: boolean; 360 | name: BindingIdentifier; 361 | params: FormalParameters; 362 | body: FunctionBody; 363 | constructor(init: Init); 364 | } 365 | 366 | export class FunctionExpression { 367 | type: 'FunctionExpression'; 368 | isAsync: boolean; 369 | isGenerator: boolean; 370 | name: BindingIdentifier | null; 371 | params: FormalParameters; 372 | body: FunctionBody; 373 | constructor(init: Init); 374 | } 375 | 376 | export class Getter { 377 | type: 'Getter'; 378 | name: ComputedPropertyName | StaticPropertyName; 379 | body: FunctionBody; 380 | constructor(init: Init); 381 | } 382 | 383 | export class IdentifierExpression { 384 | type: 'IdentifierExpression'; 385 | name: string; 386 | constructor(init: Init); 387 | } 388 | 389 | export class IfStatement { 390 | type: 'IfStatement'; 391 | test: Expression; 392 | consequent: Statement; 393 | alternate: Statement | null; 394 | constructor(init: Init); 395 | } 396 | 397 | export class Import { 398 | type: 'Import'; 399 | defaultBinding: BindingIdentifier | null; 400 | namedImports: Array; 401 | moduleSpecifier: string; 402 | constructor(init: Init); 403 | } 404 | 405 | export class ImportNamespace { 406 | type: 'ImportNamespace'; 407 | defaultBinding: BindingIdentifier | null; 408 | namespaceBinding: BindingIdentifier; 409 | moduleSpecifier: string; 410 | constructor(init: Init); 411 | } 412 | 413 | export class ImportSpecifier { 414 | type: 'ImportSpecifier'; 415 | name: string | null; 416 | binding: BindingIdentifier; 417 | constructor(init: Init); 418 | } 419 | 420 | export class LabeledStatement { 421 | type: 'LabeledStatement'; 422 | label: string; 423 | body: Statement; 424 | constructor(init: Init); 425 | } 426 | 427 | export class LiteralBooleanExpression { 428 | type: 'LiteralBooleanExpression'; 429 | value: boolean; 430 | constructor(init: Init); 431 | } 432 | 433 | export class LiteralInfinityExpression { 434 | type: 'LiteralInfinityExpression'; 435 | constructor(init?: Init); 436 | } 437 | 438 | export class LiteralNullExpression { 439 | type: 'LiteralNullExpression'; 440 | constructor(init?: Init); 441 | } 442 | 443 | export class LiteralNumericExpression { 444 | type: 'LiteralNumericExpression'; 445 | value: number; 446 | constructor(init: Init); 447 | } 448 | 449 | export class LiteralRegExpExpression { 450 | type: 'LiteralRegExpExpression'; 451 | pattern: string; 452 | global: boolean; 453 | ignoreCase: boolean; 454 | multiLine: boolean; 455 | dotAll: boolean; 456 | unicode: boolean; 457 | sticky: boolean; 458 | constructor(init: Init); 459 | } 460 | 461 | export class LiteralStringExpression { 462 | type: 'LiteralStringExpression'; 463 | value: string; 464 | constructor(init: Init); 465 | } 466 | 467 | export class Method { 468 | type: 'Method'; 469 | isAsync: boolean; 470 | isGenerator: boolean; 471 | name: ComputedPropertyName | StaticPropertyName; 472 | params: FormalParameters; 473 | body: FunctionBody; 474 | constructor(init: Init); 475 | } 476 | 477 | export class Module { 478 | type: 'Module'; 479 | directives: Array; 480 | items: Array; 481 | constructor(init: Init); 482 | } 483 | 484 | export class NewExpression { 485 | type: 'NewExpression'; 486 | callee: Expression; 487 | arguments: Array; 488 | constructor(init: Init); 489 | } 490 | 491 | export class NewTargetExpression { 492 | type: 'NewTargetExpression'; 493 | constructor(init?: Init); 494 | } 495 | 496 | export class ObjectAssignmentTarget { 497 | type: 'ObjectAssignmentTarget'; 498 | properties: Array; 499 | rest: AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget | null; 500 | constructor(init: Init); 501 | } 502 | 503 | export class ObjectBinding { 504 | type: 'ObjectBinding'; 505 | properties: Array; 506 | rest: BindingIdentifier | null; 507 | constructor(init: Init); 508 | } 509 | 510 | export class ObjectExpression { 511 | type: 'ObjectExpression'; 512 | properties: Array; 513 | constructor(init: Init); 514 | } 515 | 516 | export class ReturnStatement { 517 | type: 'ReturnStatement'; 518 | expression: Expression | null; 519 | constructor(init: Init); 520 | } 521 | 522 | export class Script { 523 | type: 'Script'; 524 | directives: Array; 525 | statements: Array; 526 | constructor(init: Init