From 3f04cd5fcaf139ea9b3102b246a73bfef0c5939f Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Fri, 1 Jan 2021 15:35:42 -0800 Subject: [PATCH] feat: refactor to split AST specification out as its own module Fixes #2726 Fixes #2912 This PR is the basis for a big cleanup and reorganisation of the AST. This first step takes the file `types/src/ts-estree.ts` and splits it up in its entirety. This file was a monolith at 1700 lines - meaning it was a pain to organise and manage, and there was no way to isolate/restrict certain things (aside from adding comments). This PR should ultimately be a no-op - there should be no breaking changes here. I did fix up a number of types which I found when organising files into their folders. Whilst this PR ultimately creates more LOC, the isolation enables a few things: - By splitting the AST into its own module, it's isolated so easier to manage / govern - By splitting each AST node into its own folder we can cleanly document and link to individual node specs - By grouping nodes decls by folder, it's easier to inspect the types to validate unions are correct. - I found a number of invalid nodes in unions in this PR which have been fixed. - In a future PR we can: - Add lint rule(s) to validate unions are correct (eg ensure all `Expression` types are included in the `Expression` union). - Easily add documentation about the node without cluttering things up - Colocate fixtures/snapshots with the node specs to document the cases that we expect a node to show up - Colocate the conversion logic here so that it's easier to validate that the spec and the conversion logic are in sync - This will make it much easier to implement and maintain #1852 --- .eslintignore | 3 + .eslintrc.js | 23 + .gitignore | 4 + .vscode/settings.json | 4 +- package.json | 3 +- packages/ast-spec/LICENSE | 21 + packages/ast-spec/README.md | 24 + packages/ast-spec/api-extractor.json | 31 + packages/ast-spec/jest.config.js | 20 + packages/ast-spec/package.json | 46 + .../{types => ast-spec}/src/ast-node-types.ts | 22 +- .../src/ast-token-types.ts | 4 +- packages/ast-spec/src/base/Accessibility.ts | 1 + packages/ast-spec/src/base/BaseNode.ts | 22 + packages/ast-spec/src/base/BaseToken.ts | 8 + .../ast-spec/src/base/BinaryExpressionBase.ts | 8 + .../ast-spec/src/base/ClassDeclarationBase.ts | 20 + .../ast-spec/src/base/ClassPropertyBase.ts | 34 + .../src/base/FunctionDeclarationBase.ts | 18 + .../ast-spec/src/base/LineAndColumnData.ts | 10 + packages/ast-spec/src/base/LiteralBase.ts | 6 + .../ast-spec/src/base/MethodDefinitionBase.ts | 35 + .../ast-spec/src/base/OptionalRangeAndLoc.ts | 11 + packages/ast-spec/src/base/Range.ts | 6 + packages/ast-spec/src/base/SourceLocation.ts | 12 + .../src/base/TSFunctionSignatureBase.ts | 10 + packages/ast-spec/src/base/TSHeritageBase.ts | 8 + .../ast-spec/src/base/UnaryExpressionBase.ts | 10 + .../src/declaration/ClassDeclaration/spec.ts | 6 + .../declaration/ExportAllDeclaration/spec.ts | 11 + .../ExportDefaultDeclaration/spec.ts | 10 + .../ExportNamedDeclaration/spec.ts | 13 + .../declaration/FunctionDeclaration/spec.ts | 8 + .../src/declaration/TSDeclareFunction/spec.ts | 6 + .../src/declaration/TSEnumDeclaration/spec.ts | 14 + .../TSImportEqualsDeclaration/spec.ts | 13 + .../TSInterfaceDeclaration/spec.ts | 17 + .../declaration/TSModuleDeclaration/spec.ts | 26 + .../TSNamespaceExportDeclaration/spec.ts | 8 + .../TSTypeAliasDeclaration/spec.ts | 13 + .../declaration/VariableDeclaration/spec.ts | 11 + packages/ast-spec/src/declaration/spec.ts | 13 + .../src/element/ClassProperty/spec.ts | 19 + .../src/element/MethodDefinition/spec.ts | 19 + .../ast-spec/src/element/Property/spec.ts | 37 + .../src/element/SpreadElement/spec.ts | 8 + .../element/TSAbstractClassProperty/spec.ts | 19 + .../TSAbstractMethodDefinition/spec.ts | 19 + .../TSCallSignatureDeclaration/spec.ts | 6 + .../TSConstructSignatureDeclaration/spec.ts | 7 + .../ast-spec/src/element/TSEnumMember/spec.ts | 41 + .../src/element/TSIndexSignature/spec.ts | 15 + .../src/element/TSMethodSignature/spec.ts | 39 + .../src/element/TSPropertySignature/spec.ts | 39 + packages/ast-spec/src/element/spec.ts | 12 + .../src/expression/ArrayExpression/spec.ts | 8 + .../ArrowFunctionExpression/spec.ts | 19 + .../expression/AssignmentExpression/spec.ts | 23 + .../src/expression/AwaitExpression/spec.ts | 16 + .../src/expression/BinaryExpression/spec.ts | 6 + .../src/expression/CallExpression/spec.ts | 13 + .../src/expression/ChainExpression/spec.ts | 8 + .../src/expression/ClassExpression/spec.ts | 6 + .../expression/ConditionalExpression/spec.ts | 10 + .../src/expression/FunctionExpression/spec.ts | 8 + .../src/expression/Identifier/spec.ts | 12 + .../src/expression/ImportExpression/spec.ts | 8 + .../src/expression/JSXElement/spec.ts | 12 + .../src/expression/JSXFragment/spec.ts | 12 + .../src/expression/LogicalExpression/spec.ts | 6 + .../src/expression/MemberExpression/spec.ts | 28 + .../src/expression/MetaProperty/spec.ts | 9 + .../src/expression/NewExpression/spec.ts | 12 + .../src/expression/ObjectExpression/spec.ts | 8 + .../src/expression/SequenceExpression/spec.ts | 8 + .../ast-spec/src/expression/Super/spec.ts | 6 + .../src/expression/TSAsExpression/spec.ts | 10 + .../TSEmptyBodyFunctionExpression/spec.ts | 7 + .../expression/TSNonNullExpression/spec.ts | 8 + .../src/expression/TSTypeAssertion/spec.ts | 10 + .../TaggedTemplateExpression/spec.ts | 12 + .../src/expression/TemplateLiteral/spec.ts | 10 + .../src/expression/ThisExpression/spec.ts | 6 + .../src/expression/UnaryExpression/spec.ts | 7 + .../src/expression/UpdateExpression/spec.ts | 7 + .../src/expression/YieldExpression/spec.ts | 9 + .../expression/literal/BigIntLiteral/spec.ts | 8 + .../expression/literal/BooleanLiteral/spec.ts | 8 + .../expression/literal/NullLiteral/spec.ts | 8 + .../expression/literal/NumberLiteral/spec.ts | 7 + .../expression/literal/RegExpLiteral/spec.ts | 11 + .../expression/literal/StringLiteral/spec.ts | 7 + .../ast-spec/src/expression/literal/spec.ts | 6 + packages/ast-spec/src/expression/spec.ts | 33 + packages/ast-spec/src/index.ts | 52 + .../ast-spec/src/jsx/JSXAttribute/spec.ts | 12 + .../src/jsx/JSXClosingElement/spec.ts | 8 + .../src/jsx/JSXClosingFragment/spec.ts | 6 + .../src/jsx/JSXEmptyExpression/spec.ts | 6 + .../src/jsx/JSXExpressionContainer/spec.ts | 9 + .../ast-spec/src/jsx/JSXIdentifier/spec.ts | 7 + .../src/jsx/JSXMemberExpression/spec.ts | 10 + .../src/jsx/JSXNamespacedName/spec.ts | 9 + .../src/jsx/JSXOpeningElement/spec.ts | 14 + .../src/jsx/JSXOpeningFragment/spec.ts | 6 + .../src/jsx/JSXSpreadAttribute/spec.ts | 8 + .../ast-spec/src/jsx/JSXSpreadChild/spec.ts | 9 + packages/ast-spec/src/jsx/JSXText/spec.ts | 8 + packages/ast-spec/src/jsx/spec.ts | 13 + .../src/parameter/ArrayPattern/spec.ts | 13 + .../src/parameter/AssignmentPattern/spec.ts | 15 + .../src/parameter/ObjectPattern/spec.ts | 14 + .../src/parameter/RestElement/spec.ts | 15 + .../src/parameter/TSParameterProperty/spec.ts | 17 + packages/ast-spec/src/parameter/spec.ts | 5 + .../ast-spec/src/special/CatchClause/spec.ts | 10 + .../ast-spec/src/special/ClassBody/spec.ts | 8 + .../ast-spec/src/special/Decorator/spec.ts | 8 + .../src/special/EmptyStatement/spec.ts | 6 + .../src/special/ExportSpecifier/spec.ts | 9 + .../special/ImportDefaultSpecifier/spec.ts | 8 + .../special/ImportNamespaceSpecifier/spec.ts | 8 + .../src/special/ImportSpecifier/spec.ts | 9 + packages/ast-spec/src/special/Program/spec.ts | 13 + .../ast-spec/src/special/SwitchCase/spec.ts | 10 + .../src/special/TSClassImplements/spec.ts | 6 + .../special/TSExternalModuleReference/spec.ts | 8 + .../src/special/TSInterfaceBody/spec.ts | 8 + .../src/special/TSInterfaceHeritage/spec.ts | 6 + .../src/special/TSModuleBlock/spec.ts | 8 + .../src/special/TSTypeAnnotation/spec.ts | 8 + .../src/special/TSTypeParameter/spec.ts | 11 + .../TSTypeParameterDeclaration/spec.ts | 8 + .../TSTypeParameterInstantiation/spec.ts | 8 + .../src/special/TemplateElement/spec.ts | 11 + .../src/special/VariableDeclarator/spec.ts | 11 + packages/ast-spec/src/special/spec.ts | 21 + .../src/statement/BlockStatement/spec.ts | 8 + .../src/statement/BreakStatement/spec.ts | 8 + .../src/statement/ContinueStatement/spec.ts | 8 + .../src/statement/DebuggerStatement/spec.ts | 6 + .../src/statement/DoWhileStatement/spec.ts | 10 + .../src/statement/ExpressionStatement/spec.ts | 9 + .../src/statement/ForInStatement/spec.ts | 12 + .../src/statement/ForOfStatement/spec.ts | 13 + .../src/statement/ForStatement/spec.ts | 13 + .../src/statement/IfStatement/spec.ts | 11 + .../src/statement/ImportDeclaration/spec.ts | 11 + .../src/statement/LabeledStatement/spec.ts | 10 + .../src/statement/ReturnStatement/spec.ts | 8 + .../src/statement/SwitchStatement/spec.ts | 10 + .../src/statement/TSExportAssignment/spec.ts | 8 + .../src/statement/ThrowStatement/spec.ts | 9 + .../src/statement/TryStatement/spec.ts | 11 + .../src/statement/WhileStatement/spec.ts | 10 + .../src/statement/WithStatement/spec.ts | 10 + packages/ast-spec/src/statement/spec.ts | 19 + .../ast-spec/src/token/BlockComment/spec.ts | 6 + .../ast-spec/src/token/BooleanToken/spec.ts | 6 + .../src/token/IdentifierToken/spec.ts | 6 + .../src/token/JSXIdentifierToken/spec.ts | 6 + .../ast-spec/src/token/JSXTextToken/spec.ts | 6 + .../ast-spec/src/token/KeywordToken/spec.ts | 6 + .../ast-spec/src/token/LineComment/spec.ts | 6 + packages/ast-spec/src/token/NullToken/spec.ts | 6 + .../ast-spec/src/token/NumericToken/spec.ts | 6 + .../src/token/PunctuatorToken/spec.ts | 6 + .../src/token/RegularExpressionToken/spec.ts | 10 + .../ast-spec/src/token/StringToken/spec.ts | 6 + .../src/token/TSAbstractKeyword/spec.ts | 6 + .../ast-spec/src/token/TSAsyncKeyword/spec.ts | 6 + .../src/token/TSDeclareKeyword/spec.ts | 6 + .../src/token/TSExportKeyword/spec.ts | 6 + .../src/token/TSPrivateKeyword/spec.ts | 6 + .../src/token/TSProtectedKeyword/spec.ts | 6 + .../src/token/TSPublicKeyword/spec.ts | 6 + .../src/token/TSReadonlyKeyword/spec.ts | 6 + .../src/token/TSStaticKeyword/spec.ts | 6 + .../ast-spec/src/token/TemplateToken/spec.ts | 6 + packages/ast-spec/src/token/spec.ts | 22 + .../ast-spec/src/type/TSAnyKeyword/spec.ts | 6 + .../ast-spec/src/type/TSArrayType/spec.ts | 8 + .../ast-spec/src/type/TSBigIntKeyword/spec.ts | 6 + .../src/type/TSBooleanKeyword/spec.ts | 6 + .../src/type/TSConditionalType/spec.ts | 11 + .../src/type/TSConstructorType/spec.ts | 7 + .../ast-spec/src/type/TSFunctionType/spec.ts | 6 + .../ast-spec/src/type/TSImportType/spec.ts | 13 + .../src/type/TSIndexedAccessType/spec.ts | 9 + .../ast-spec/src/type/TSInferType/spec.ts | 8 + .../src/type/TSIntersectionType/spec.ts | 8 + .../ast-spec/src/type/TSIntrinsicType/spec.ts | 6 + .../ast-spec/src/type/TSLiteralType/spec.ts | 10 + .../ast-spec/src/type/TSMappedType/spec.ts | 13 + .../src/type/TSNamedTupleMember/spec.ts | 11 + .../ast-spec/src/type/TSNeverKeyword/spec.ts | 6 + .../ast-spec/src/type/TSNullKeyword/spec.ts | 6 + .../ast-spec/src/type/TSNumberKeyword/spec.ts | 6 + .../ast-spec/src/type/TSObjectKeyword/spec.ts | 6 + .../ast-spec/src/type/TSOptionalType/spec.ts | 8 + .../src/type/TSParenthesizedType/spec.ts | 8 + .../ast-spec/src/type/TSQualifiedName/spec.ts | 10 + packages/ast-spec/src/type/TSRestType/spec.ts | 8 + .../ast-spec/src/type/TSStringKeyword/spec.ts | 6 + .../ast-spec/src/type/TSSymbolKeyword/spec.ts | 6 + .../src/type/TSTemplateLiteralType/spec.ts | 10 + packages/ast-spec/src/type/TSThisType/spec.ts | 6 + .../ast-spec/src/type/TSTupleType/spec.ts | 8 + .../ast-spec/src/type/TSTypeLiteral/spec.ts | 8 + .../ast-spec/src/type/TSTypeOperator/spec.ts | 9 + .../ast-spec/src/type/TSTypePredicate/spec.ts | 12 + .../ast-spec/src/type/TSTypeQuery/spec.ts | 8 + .../ast-spec/src/type/TSTypeReference/spec.ts | 10 + .../src/type/TSUndefinedKeyword/spec.ts | 6 + .../ast-spec/src/type/TSUnionType/spec.ts | 8 + .../src/type/TSUnknownKeyword/spec.ts | 6 + .../ast-spec/src/type/TSVoidKeyword/spec.ts | 6 + packages/ast-spec/src/type/spec.ts | 36 + packages/ast-spec/src/unions/BindingName.ts | 4 + .../ast-spec/src/unions/BindingPattern.ts | 4 + .../src/unions/CallExpressionArgument.ts | 4 + packages/ast-spec/src/unions/ChainElement.ts | 8 + packages/ast-spec/src/unions/ClassElement.ts | 12 + packages/ast-spec/src/unions/Comment.ts | 4 + .../src/unions/DeclarationStatement.ts | 29 + .../src/unions/DestructuringPattern.ts | 14 + packages/ast-spec/src/unions/EntityName.ts | 4 + .../ast-spec/src/unions/ExportDeclaration.ts | 20 + packages/ast-spec/src/unions/Expression.ts | 78 + .../ast-spec/src/unions/ForInitialiser.ts | 4 + packages/ast-spec/src/unions/FunctionLike.ts | 12 + packages/ast-spec/src/unions/ImportClause.ts | 8 + .../ast-spec/src/unions/IterationStatement.ts | 12 + packages/ast-spec/src/unions/JSXChild.ts | 6 + packages/ast-spec/src/unions/JSXExpression.ts | 8 + .../src/unions/JSXTagNameExpression.ts | 8 + .../src/unions/LeftHandSideExpression.ts | 44 + packages/ast-spec/src/unions/Literal.ts | 14 + .../ast-spec/src/unions/LiteralExpression.ts | 4 + packages/ast-spec/src/unions/Modifier.ts | 16 + packages/ast-spec/src/unions/Node.ts | 329 +++ .../src/unions/ObjectLiteralElement.ts | 8 + packages/ast-spec/src/unions/Parameter.ts | 14 + .../ast-spec/src/unions/PrimaryExpression.ts | 35 + packages/ast-spec/src/unions/PropertyName.ts | 11 + packages/ast-spec/src/unions/Statement.ts | 78 + .../ast-spec/src/unions/TSUnaryExpression.ts | 13 + packages/ast-spec/src/unions/Token.ts | 26 + packages/ast-spec/src/unions/TypeElement.ts | 12 + packages/ast-spec/src/unions/TypeNode.ts | 74 + .../ast-spec/tests/ast-node-types.test.ts | 16 + packages/ast-spec/tsconfig.build.json | 10 + packages/ast-spec/tsconfig.json | 8 + packages/eslint-plugin-internal/package.json | 2 +- .../src/rules/plugin-test-formatting.ts | 4 +- packages/eslint-plugin-tslint/package.json | 2 +- packages/eslint-plugin/package.json | 2 +- .../src/rules/no-loss-of-precision.ts | 2 +- .../src/rules/no-unnecessary-condition.ts | 2 +- .../src/rules/prefer-regexp-exec.ts | 4 +- .../sort-type-union-intersection-members.ts | 1 - packages/experimental-utils/package.json | 2 +- packages/parser/package.json | 2 +- packages/scope-manager/package.json | 2 +- packages/scope-manager/src/scope/ScopeBase.ts | 24 +- packages/types/package.json | 5 +- packages/types/src/index.ts | 6 +- packages/types/src/ts-estree.ts | 1780 +---------------- packages/types/tools/copy-ast-spec.ts | 59 + packages/types/tsconfig.build.json | 3 +- packages/types/tsconfig.json | 3 +- packages/typescript-estree/package.json | 2 +- packages/typescript-estree/src/convert.ts | 4 +- packages/visitor-keys/package.json | 2 +- tests/integration/docker-compose.yml | 36 +- tests/integration/fixtures/eslint-v6/test.sh | 1 + tests/integration/fixtures/markdown/test.sh | 1 + .../test.sh | 1 + .../test.sh | 1 + tests/integration/fixtures/vue-jsx/test.sh | 1 + tests/integration/fixtures/vue-sfc/test.sh | 1 + yarn.lock | 151 +- 282 files changed, 3647 insertions(+), 1847 deletions(-) create mode 100644 packages/ast-spec/LICENSE create mode 100644 packages/ast-spec/README.md create mode 100644 packages/ast-spec/api-extractor.json create mode 100644 packages/ast-spec/jest.config.js create mode 100644 packages/ast-spec/package.json rename packages/{types => ast-spec}/src/ast-node-types.ts (88%) rename packages/{types => ast-spec}/src/ast-token-types.ts (87%) create mode 100644 packages/ast-spec/src/base/Accessibility.ts create mode 100644 packages/ast-spec/src/base/BaseNode.ts create mode 100644 packages/ast-spec/src/base/BaseToken.ts create mode 100644 packages/ast-spec/src/base/BinaryExpressionBase.ts create mode 100644 packages/ast-spec/src/base/ClassDeclarationBase.ts create mode 100644 packages/ast-spec/src/base/ClassPropertyBase.ts create mode 100644 packages/ast-spec/src/base/FunctionDeclarationBase.ts create mode 100644 packages/ast-spec/src/base/LineAndColumnData.ts create mode 100644 packages/ast-spec/src/base/LiteralBase.ts create mode 100644 packages/ast-spec/src/base/MethodDefinitionBase.ts create mode 100644 packages/ast-spec/src/base/OptionalRangeAndLoc.ts create mode 100644 packages/ast-spec/src/base/Range.ts create mode 100644 packages/ast-spec/src/base/SourceLocation.ts create mode 100644 packages/ast-spec/src/base/TSFunctionSignatureBase.ts create mode 100644 packages/ast-spec/src/base/TSHeritageBase.ts create mode 100644 packages/ast-spec/src/base/UnaryExpressionBase.ts create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/spec.ts create mode 100644 packages/ast-spec/src/declaration/ExportAllDeclaration/spec.ts create mode 100644 packages/ast-spec/src/declaration/ExportDefaultDeclaration/spec.ts create mode 100644 packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts create mode 100644 packages/ast-spec/src/declaration/FunctionDeclaration/spec.ts create mode 100644 packages/ast-spec/src/declaration/TSDeclareFunction/spec.ts create mode 100644 packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts create mode 100644 packages/ast-spec/src/declaration/TSImportEqualsDeclaration/spec.ts create mode 100644 packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts create mode 100644 packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts create mode 100644 packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/spec.ts create mode 100644 packages/ast-spec/src/declaration/TSTypeAliasDeclaration/spec.ts create mode 100644 packages/ast-spec/src/declaration/VariableDeclaration/spec.ts create mode 100644 packages/ast-spec/src/declaration/spec.ts create mode 100644 packages/ast-spec/src/element/ClassProperty/spec.ts create mode 100644 packages/ast-spec/src/element/MethodDefinition/spec.ts create mode 100644 packages/ast-spec/src/element/Property/spec.ts create mode 100644 packages/ast-spec/src/element/SpreadElement/spec.ts create mode 100644 packages/ast-spec/src/element/TSAbstractClassProperty/spec.ts create mode 100644 packages/ast-spec/src/element/TSAbstractMethodDefinition/spec.ts create mode 100644 packages/ast-spec/src/element/TSCallSignatureDeclaration/spec.ts create mode 100644 packages/ast-spec/src/element/TSConstructSignatureDeclaration/spec.ts create mode 100644 packages/ast-spec/src/element/TSEnumMember/spec.ts create mode 100644 packages/ast-spec/src/element/TSIndexSignature/spec.ts create mode 100644 packages/ast-spec/src/element/TSMethodSignature/spec.ts create mode 100644 packages/ast-spec/src/element/TSPropertySignature/spec.ts create mode 100644 packages/ast-spec/src/element/spec.ts create mode 100644 packages/ast-spec/src/expression/ArrayExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/ArrowFunctionExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/AssignmentExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/AwaitExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/BinaryExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/CallExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/ChainExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/ClassExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/ConditionalExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/FunctionExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/Identifier/spec.ts create mode 100644 packages/ast-spec/src/expression/ImportExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/JSXElement/spec.ts create mode 100644 packages/ast-spec/src/expression/JSXFragment/spec.ts create mode 100644 packages/ast-spec/src/expression/LogicalExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/MemberExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/MetaProperty/spec.ts create mode 100644 packages/ast-spec/src/expression/NewExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/ObjectExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/SequenceExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/Super/spec.ts create mode 100644 packages/ast-spec/src/expression/TSAsExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/TSEmptyBodyFunctionExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/TSNonNullExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/TSTypeAssertion/spec.ts create mode 100644 packages/ast-spec/src/expression/TaggedTemplateExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/TemplateLiteral/spec.ts create mode 100644 packages/ast-spec/src/expression/ThisExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/UnaryExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/UpdateExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/YieldExpression/spec.ts create mode 100644 packages/ast-spec/src/expression/literal/BigIntLiteral/spec.ts create mode 100644 packages/ast-spec/src/expression/literal/BooleanLiteral/spec.ts create mode 100644 packages/ast-spec/src/expression/literal/NullLiteral/spec.ts create mode 100644 packages/ast-spec/src/expression/literal/NumberLiteral/spec.ts create mode 100644 packages/ast-spec/src/expression/literal/RegExpLiteral/spec.ts create mode 100644 packages/ast-spec/src/expression/literal/StringLiteral/spec.ts create mode 100644 packages/ast-spec/src/expression/literal/spec.ts create mode 100644 packages/ast-spec/src/expression/spec.ts create mode 100644 packages/ast-spec/src/index.ts create mode 100644 packages/ast-spec/src/jsx/JSXAttribute/spec.ts create mode 100644 packages/ast-spec/src/jsx/JSXClosingElement/spec.ts create mode 100644 packages/ast-spec/src/jsx/JSXClosingFragment/spec.ts create mode 100644 packages/ast-spec/src/jsx/JSXEmptyExpression/spec.ts create mode 100644 packages/ast-spec/src/jsx/JSXExpressionContainer/spec.ts create mode 100644 packages/ast-spec/src/jsx/JSXIdentifier/spec.ts create mode 100644 packages/ast-spec/src/jsx/JSXMemberExpression/spec.ts create mode 100644 packages/ast-spec/src/jsx/JSXNamespacedName/spec.ts create mode 100644 packages/ast-spec/src/jsx/JSXOpeningElement/spec.ts create mode 100644 packages/ast-spec/src/jsx/JSXOpeningFragment/spec.ts create mode 100644 packages/ast-spec/src/jsx/JSXSpreadAttribute/spec.ts create mode 100644 packages/ast-spec/src/jsx/JSXSpreadChild/spec.ts create mode 100644 packages/ast-spec/src/jsx/JSXText/spec.ts create mode 100644 packages/ast-spec/src/jsx/spec.ts create mode 100644 packages/ast-spec/src/parameter/ArrayPattern/spec.ts create mode 100644 packages/ast-spec/src/parameter/AssignmentPattern/spec.ts create mode 100644 packages/ast-spec/src/parameter/ObjectPattern/spec.ts create mode 100644 packages/ast-spec/src/parameter/RestElement/spec.ts create mode 100644 packages/ast-spec/src/parameter/TSParameterProperty/spec.ts create mode 100644 packages/ast-spec/src/parameter/spec.ts create mode 100644 packages/ast-spec/src/special/CatchClause/spec.ts create mode 100644 packages/ast-spec/src/special/ClassBody/spec.ts create mode 100644 packages/ast-spec/src/special/Decorator/spec.ts create mode 100644 packages/ast-spec/src/special/EmptyStatement/spec.ts create mode 100644 packages/ast-spec/src/special/ExportSpecifier/spec.ts create mode 100644 packages/ast-spec/src/special/ImportDefaultSpecifier/spec.ts create mode 100644 packages/ast-spec/src/special/ImportNamespaceSpecifier/spec.ts create mode 100644 packages/ast-spec/src/special/ImportSpecifier/spec.ts create mode 100644 packages/ast-spec/src/special/Program/spec.ts create mode 100644 packages/ast-spec/src/special/SwitchCase/spec.ts create mode 100644 packages/ast-spec/src/special/TSClassImplements/spec.ts create mode 100644 packages/ast-spec/src/special/TSExternalModuleReference/spec.ts create mode 100644 packages/ast-spec/src/special/TSInterfaceBody/spec.ts create mode 100644 packages/ast-spec/src/special/TSInterfaceHeritage/spec.ts create mode 100644 packages/ast-spec/src/special/TSModuleBlock/spec.ts create mode 100644 packages/ast-spec/src/special/TSTypeAnnotation/spec.ts create mode 100644 packages/ast-spec/src/special/TSTypeParameter/spec.ts create mode 100644 packages/ast-spec/src/special/TSTypeParameterDeclaration/spec.ts create mode 100644 packages/ast-spec/src/special/TSTypeParameterInstantiation/spec.ts create mode 100644 packages/ast-spec/src/special/TemplateElement/spec.ts create mode 100644 packages/ast-spec/src/special/VariableDeclarator/spec.ts create mode 100644 packages/ast-spec/src/special/spec.ts create mode 100644 packages/ast-spec/src/statement/BlockStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/BreakStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/ContinueStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/DebuggerStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/DoWhileStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/ExpressionStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/ForInStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/ForOfStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/ForStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/IfStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/ImportDeclaration/spec.ts create mode 100644 packages/ast-spec/src/statement/LabeledStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/ReturnStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/SwitchStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/TSExportAssignment/spec.ts create mode 100644 packages/ast-spec/src/statement/ThrowStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/TryStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/WhileStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/WithStatement/spec.ts create mode 100644 packages/ast-spec/src/statement/spec.ts create mode 100644 packages/ast-spec/src/token/BlockComment/spec.ts create mode 100644 packages/ast-spec/src/token/BooleanToken/spec.ts create mode 100644 packages/ast-spec/src/token/IdentifierToken/spec.ts create mode 100644 packages/ast-spec/src/token/JSXIdentifierToken/spec.ts create mode 100644 packages/ast-spec/src/token/JSXTextToken/spec.ts create mode 100644 packages/ast-spec/src/token/KeywordToken/spec.ts create mode 100644 packages/ast-spec/src/token/LineComment/spec.ts create mode 100644 packages/ast-spec/src/token/NullToken/spec.ts create mode 100644 packages/ast-spec/src/token/NumericToken/spec.ts create mode 100644 packages/ast-spec/src/token/PunctuatorToken/spec.ts create mode 100644 packages/ast-spec/src/token/RegularExpressionToken/spec.ts create mode 100644 packages/ast-spec/src/token/StringToken/spec.ts create mode 100644 packages/ast-spec/src/token/TSAbstractKeyword/spec.ts create mode 100644 packages/ast-spec/src/token/TSAsyncKeyword/spec.ts create mode 100644 packages/ast-spec/src/token/TSDeclareKeyword/spec.ts create mode 100644 packages/ast-spec/src/token/TSExportKeyword/spec.ts create mode 100644 packages/ast-spec/src/token/TSPrivateKeyword/spec.ts create mode 100644 packages/ast-spec/src/token/TSProtectedKeyword/spec.ts create mode 100644 packages/ast-spec/src/token/TSPublicKeyword/spec.ts create mode 100644 packages/ast-spec/src/token/TSReadonlyKeyword/spec.ts create mode 100644 packages/ast-spec/src/token/TSStaticKeyword/spec.ts create mode 100644 packages/ast-spec/src/token/TemplateToken/spec.ts create mode 100644 packages/ast-spec/src/token/spec.ts create mode 100644 packages/ast-spec/src/type/TSAnyKeyword/spec.ts create mode 100644 packages/ast-spec/src/type/TSArrayType/spec.ts create mode 100644 packages/ast-spec/src/type/TSBigIntKeyword/spec.ts create mode 100644 packages/ast-spec/src/type/TSBooleanKeyword/spec.ts create mode 100644 packages/ast-spec/src/type/TSConditionalType/spec.ts create mode 100644 packages/ast-spec/src/type/TSConstructorType/spec.ts create mode 100644 packages/ast-spec/src/type/TSFunctionType/spec.ts create mode 100644 packages/ast-spec/src/type/TSImportType/spec.ts create mode 100644 packages/ast-spec/src/type/TSIndexedAccessType/spec.ts create mode 100644 packages/ast-spec/src/type/TSInferType/spec.ts create mode 100644 packages/ast-spec/src/type/TSIntersectionType/spec.ts create mode 100644 packages/ast-spec/src/type/TSIntrinsicType/spec.ts create mode 100644 packages/ast-spec/src/type/TSLiteralType/spec.ts create mode 100644 packages/ast-spec/src/type/TSMappedType/spec.ts create mode 100644 packages/ast-spec/src/type/TSNamedTupleMember/spec.ts create mode 100644 packages/ast-spec/src/type/TSNeverKeyword/spec.ts create mode 100644 packages/ast-spec/src/type/TSNullKeyword/spec.ts create mode 100644 packages/ast-spec/src/type/TSNumberKeyword/spec.ts create mode 100644 packages/ast-spec/src/type/TSObjectKeyword/spec.ts create mode 100644 packages/ast-spec/src/type/TSOptionalType/spec.ts create mode 100644 packages/ast-spec/src/type/TSParenthesizedType/spec.ts create mode 100644 packages/ast-spec/src/type/TSQualifiedName/spec.ts create mode 100644 packages/ast-spec/src/type/TSRestType/spec.ts create mode 100644 packages/ast-spec/src/type/TSStringKeyword/spec.ts create mode 100644 packages/ast-spec/src/type/TSSymbolKeyword/spec.ts create mode 100644 packages/ast-spec/src/type/TSTemplateLiteralType/spec.ts create mode 100644 packages/ast-spec/src/type/TSThisType/spec.ts create mode 100644 packages/ast-spec/src/type/TSTupleType/spec.ts create mode 100644 packages/ast-spec/src/type/TSTypeLiteral/spec.ts create mode 100644 packages/ast-spec/src/type/TSTypeOperator/spec.ts create mode 100644 packages/ast-spec/src/type/TSTypePredicate/spec.ts create mode 100644 packages/ast-spec/src/type/TSTypeQuery/spec.ts create mode 100644 packages/ast-spec/src/type/TSTypeReference/spec.ts create mode 100644 packages/ast-spec/src/type/TSUndefinedKeyword/spec.ts create mode 100644 packages/ast-spec/src/type/TSUnionType/spec.ts create mode 100644 packages/ast-spec/src/type/TSUnknownKeyword/spec.ts create mode 100644 packages/ast-spec/src/type/TSVoidKeyword/spec.ts create mode 100644 packages/ast-spec/src/type/spec.ts create mode 100644 packages/ast-spec/src/unions/BindingName.ts create mode 100644 packages/ast-spec/src/unions/BindingPattern.ts create mode 100644 packages/ast-spec/src/unions/CallExpressionArgument.ts create mode 100644 packages/ast-spec/src/unions/ChainElement.ts create mode 100644 packages/ast-spec/src/unions/ClassElement.ts create mode 100644 packages/ast-spec/src/unions/Comment.ts create mode 100644 packages/ast-spec/src/unions/DeclarationStatement.ts create mode 100644 packages/ast-spec/src/unions/DestructuringPattern.ts create mode 100644 packages/ast-spec/src/unions/EntityName.ts create mode 100644 packages/ast-spec/src/unions/ExportDeclaration.ts create mode 100644 packages/ast-spec/src/unions/Expression.ts create mode 100644 packages/ast-spec/src/unions/ForInitialiser.ts create mode 100644 packages/ast-spec/src/unions/FunctionLike.ts create mode 100644 packages/ast-spec/src/unions/ImportClause.ts create mode 100644 packages/ast-spec/src/unions/IterationStatement.ts create mode 100644 packages/ast-spec/src/unions/JSXChild.ts create mode 100644 packages/ast-spec/src/unions/JSXExpression.ts create mode 100644 packages/ast-spec/src/unions/JSXTagNameExpression.ts create mode 100644 packages/ast-spec/src/unions/LeftHandSideExpression.ts create mode 100644 packages/ast-spec/src/unions/Literal.ts create mode 100644 packages/ast-spec/src/unions/LiteralExpression.ts create mode 100644 packages/ast-spec/src/unions/Modifier.ts create mode 100644 packages/ast-spec/src/unions/Node.ts create mode 100644 packages/ast-spec/src/unions/ObjectLiteralElement.ts create mode 100644 packages/ast-spec/src/unions/Parameter.ts create mode 100644 packages/ast-spec/src/unions/PrimaryExpression.ts create mode 100644 packages/ast-spec/src/unions/PropertyName.ts create mode 100644 packages/ast-spec/src/unions/Statement.ts create mode 100644 packages/ast-spec/src/unions/TSUnaryExpression.ts create mode 100644 packages/ast-spec/src/unions/Token.ts create mode 100644 packages/ast-spec/src/unions/TypeElement.ts create mode 100644 packages/ast-spec/src/unions/TypeNode.ts create mode 100644 packages/ast-spec/tests/ast-node-types.test.ts create mode 100644 packages/ast-spec/tsconfig.build.json create mode 100644 packages/ast-spec/tsconfig.json create mode 100644 packages/types/tools/copy-ast-spec.ts diff --git a/.eslintignore b/.eslintignore index 3c9816ccb5cc..255b369df6b0 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,3 +7,6 @@ coverage __snapshots__ packages/eslint-plugin-tslint/tests + +# Files copied as part of the build +packages/types/src/ast-spec.ts diff --git a/.eslintrc.js b/.eslintrc.js index 5d944cceacbe..c02abfbd7a8d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,6 +7,7 @@ module.exports = { 'import', 'eslint-comments', '@typescript-eslint/internal', + 'simple-import-sort', ], env: { es6: true, @@ -261,5 +262,27 @@ module.exports = { '@typescript-eslint/internal/prefer-ast-types-enum': 'off', }, }, + // ast spec specific standardization + { + files: ['packages/ast-spec/src/**/*.ts'], + rules: { + '@typescript-eslint/consistent-type-imports': [ + 'error', + { prefer: 'type-imports', disallowTypeAnnotations: true }, + ], + '@typescript-eslint/no-unused-vars': 'error', + '@typescript-eslint/sort-type-union-intersection-members': 'error', + 'import/first': 'error', + 'import/newline-after-import': 'error', + 'import/no-duplicates': 'error', + 'simple-import-sort/imports': 'error', + }, + }, + { + files: ['rollup.config.ts'], + rules: { + 'import/no-default-export': 'off', + }, + }, ], }; diff --git a/.gitignore b/.gitignore index b7d08022ef73..95ec54effa37 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,7 @@ dist _ts3.4 *.tsbuildinfo .watchmanconfig +.rollup.cache + +# Files copied as part of the build +packages/types/src/ast-spec.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 20830a2fa0b8..f0677068d037 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,8 +13,8 @@ // typescript auto-format settings "typescript.tsdk": "node_modules/typescript/lib", - "javascript.preferences.importModuleSpecifier": "auto", - "typescript.preferences.importModuleSpecifier": "auto", + "javascript.preferences.importModuleSpecifier": "project-relative", + "typescript.preferences.importModuleSpecifier": "project-relative", "javascript.preferences.quoteStyle": "single", "typescript.preferences.quoteStyle": "single", "editor.defaultFormatter": "esbenp.prettier-vscode", diff --git a/package.json b/package.json index 431c13ac5668..f93f8088afdc 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "url": "https://github.com/typescript-eslint/typescript-eslint/issues" }, "scripts": { - "build": "lerna run build", + "build": "lerna run build --ignore ast-spec", "check:clean-workspace-after-install": "git diff --quiet --exit-code", "check:configs": "lerna run check:configs", "check:docs": "lerna run check:docs", @@ -98,6 +98,7 @@ "eslint-plugin-eslint-plugin": "^3.0.0", "eslint-plugin-import": "^2.22.0", "eslint-plugin-jest": "^24.1.3", + "eslint-plugin-simple-import-sort": "^7.0.0", "glob": "^7.1.6", "husky": "^5.0.9", "jest": "^26.6.3", diff --git a/packages/ast-spec/LICENSE b/packages/ast-spec/LICENSE new file mode 100644 index 000000000000..7e7370143b26 --- /dev/null +++ b/packages/ast-spec/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 TypeScript ESLint and other contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/ast-spec/README.md b/packages/ast-spec/README.md new file mode 100644 index 000000000000..7c954398395b --- /dev/null +++ b/packages/ast-spec/README.md @@ -0,0 +1,24 @@ +

TypeScript-ESTree AST Specification

+ +

+ CI + NPM Version + NPM Downloads +

+ +This is the complete specification for the TypeScript-ESTree AST. + +It includes: + +- Node definitions as TypeScript types (the specification) +- Logic for converting from the TypeScript AST to the TypeScript-ESTree AST. +- Tests/Fixtures/Examples for each Node + +**You probably don't want to use it directly.** + +If you're building an ESLint plugin, consider using [`@typescript-eslint/experimental-utils`](../experimental-utils). +If you're parsing TypeScript code, consider using [`@typescript-eslint/typescript-estree`](../typescript-estree). + +## Contributing + +[See the contributing guide here](../../CONTRIBUTING.md) diff --git a/packages/ast-spec/api-extractor.json b/packages/ast-spec/api-extractor.json new file mode 100644 index 000000000000..f474f3bf26fd --- /dev/null +++ b/packages/ast-spec/api-extractor.json @@ -0,0 +1,31 @@ +{ + "mainEntryPointFilePath": "/dist/index.d.ts", + "apiReport": { + "enabled": false + }, + "docModel": { + "enabled": false + }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "/dist/ast-spec.ts" + }, + "tsdocMetadata": { + "enabled": false + }, + "messages": { + "extractorMessageReporting": { + "default": { + "logLevel": "none" + }, + "ae-forgotten-export": { + "logLevel": "none" + } + }, + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + } + } +} diff --git a/packages/ast-spec/jest.config.js b/packages/ast-spec/jest.config.js new file mode 100644 index 000000000000..c23ca67fbc68 --- /dev/null +++ b/packages/ast-spec/jest.config.js @@ -0,0 +1,20 @@ +'use strict'; + +// @ts-check +/** @type {import('@jest/types').Config.InitialOptions} */ +module.exports = { + globals: { + 'ts-jest': { + isolatedModules: true, + }, + }, + testEnvironment: 'node', + transform: { + ['^.+\\.tsx?$']: 'ts-jest', + }, + testRegex: ['./tests/.+\\.test\\.ts$'], + collectCoverage: false, + collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'], + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], + coverageReporters: ['text-summary', 'lcov'], +}; diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json new file mode 100644 index 000000000000..c688fcdda2e1 --- /dev/null +++ b/packages/ast-spec/package.json @@ -0,0 +1,46 @@ +{ + "name": "@typescript-eslint/ast-spec", + "version": "4.20.0", + "description": "TypeScript-ESTree AST spec", + "private": true, + "keywords": [ + "eslint", + "typescript", + "estree" + ], + "engines": { + "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + }, + "files": [ + "dist", + "package.json", + "README.md", + "LICENSE" + ], + "repository": { + "type": "git", + "url": "https://github.com/typescript-eslint/typescript-eslint.git", + "directory": "packages/ast-spec" + }, + "bugs": { + "url": "https://github.com/typescript-eslint/typescript-eslint/issues" + }, + "license": "MIT", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "scripts": { + "build": "tsc -b tsconfig.build.json && api-extractor run --local", + "clean": "tsc -b tsconfig.build.json --clean", + "postclean": "rimraf dist && rimraf _ts3.4 && rimraf .rollup.cache && rimraf coverage", + "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", + "lint": "eslint . --ext .js,.ts --ignore-path='../../.eslintignore'", + "typecheck": "tsc -p tsconfig.json --noEmit" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "devDependencies": { + "@microsoft/api-extractor": "^7.13.2" + } +} diff --git a/packages/types/src/ast-node-types.ts b/packages/ast-spec/src/ast-node-types.ts similarity index 88% rename from packages/types/src/ast-node-types.ts rename to packages/ast-spec/src/ast-node-types.ts index f233d60f8aeb..6aa0087d5eb2 100644 --- a/packages/types/src/ast-node-types.ts +++ b/packages/ast-spec/src/ast-node-types.ts @@ -1,4 +1,4 @@ -enum AST_NODE_TYPES { +export enum AST_NODE_TYPES { ArrayExpression = 'ArrayExpression', ArrayPattern = 'ArrayPattern', ArrowFunctionExpression = 'ArrowFunctionExpression', @@ -164,23 +164,3 @@ enum AST_NODE_TYPES { TSUnknownKeyword = 'TSUnknownKeyword', TSVoidKeyword = 'TSVoidKeyword', } - -export { AST_NODE_TYPES }; - -// Below is a special type-only test which ensures that we don't accidentally leave unused keys in this enum -// eslint-disable-next-line import/first -- purposely down here to colocate it with this hack of a test -import type { Node } from './ts-estree'; - -type GetKeys = keyof Extract; - -type AllKeys = { - readonly [T in AST_NODE_TYPES]: GetKeys; -}; - -type TakesString> = T; - -// @ts-expect-error: purposely unused -type _Test = - // forcing the test onto a new line so it isn't covered by the expect error - // If there are any enum members that don't have a corresponding TSESTree.Node, then this line will error with "Type 'string | number | symbol' is not assignable to type 'string'." - void | TakesString; diff --git a/packages/types/src/ast-token-types.ts b/packages/ast-spec/src/ast-token-types.ts similarity index 87% rename from packages/types/src/ast-token-types.ts rename to packages/ast-spec/src/ast-token-types.ts index 144befece83e..f839d8dfae59 100644 --- a/packages/types/src/ast-token-types.ts +++ b/packages/ast-spec/src/ast-token-types.ts @@ -1,4 +1,4 @@ -enum AST_TOKEN_TYPES { +export enum AST_TOKEN_TYPES { Boolean = 'Boolean', Identifier = 'Identifier', JSXIdentifier = 'JSXIdentifier', @@ -15,5 +15,3 @@ enum AST_TOKEN_TYPES { Block = 'Block', Line = 'Line', } - -export { AST_TOKEN_TYPES }; diff --git a/packages/ast-spec/src/base/Accessibility.ts b/packages/ast-spec/src/base/Accessibility.ts new file mode 100644 index 000000000000..d52942f43ab2 --- /dev/null +++ b/packages/ast-spec/src/base/Accessibility.ts @@ -0,0 +1 @@ +export type Accessibility = 'private' | 'protected' | 'public'; diff --git a/packages/ast-spec/src/base/BaseNode.ts b/packages/ast-spec/src/base/BaseNode.ts new file mode 100644 index 000000000000..362f156832b4 --- /dev/null +++ b/packages/ast-spec/src/base/BaseNode.ts @@ -0,0 +1,22 @@ +// import type { Node } from '../unions/Node'; +import type { Range } from './Range'; +import type { SourceLocation } from './SourceLocation'; + +export interface BaseNode { + /** + * The source location information of the node. + * @see {SourceLocation} + */ + loc: SourceLocation; + /** + * @see {Range} + */ + range: Range; + /** + * The parent node of the current node + */ + // parent?: Node; + + // every node *will* have a type, but let the nodes define their own exact string + // type: string; +} diff --git a/packages/ast-spec/src/base/BaseToken.ts b/packages/ast-spec/src/base/BaseToken.ts new file mode 100644 index 000000000000..cdf0d1286438 --- /dev/null +++ b/packages/ast-spec/src/base/BaseToken.ts @@ -0,0 +1,8 @@ +import type { BaseNode } from './BaseNode'; + +/* + * Token and Comment are pseudo-nodes to represent pieces of source code + */ +export interface BaseToken extends BaseNode { + value: string; +} diff --git a/packages/ast-spec/src/base/BinaryExpressionBase.ts b/packages/ast-spec/src/base/BinaryExpressionBase.ts new file mode 100644 index 000000000000..926491d49855 --- /dev/null +++ b/packages/ast-spec/src/base/BinaryExpressionBase.ts @@ -0,0 +1,8 @@ +import type { Expression } from '../unions/Expression'; +import type { BaseNode } from './BaseNode'; + +export interface BinaryExpressionBase extends BaseNode { + operator: string; + left: Expression; + right: Expression; +} diff --git a/packages/ast-spec/src/base/ClassDeclarationBase.ts b/packages/ast-spec/src/base/ClassDeclarationBase.ts new file mode 100644 index 000000000000..f104b739b517 --- /dev/null +++ b/packages/ast-spec/src/base/ClassDeclarationBase.ts @@ -0,0 +1,20 @@ +import type { Identifier } from '../expression/Identifier/spec'; +import type { ClassBody } from '../special/ClassBody/spec'; +import type { Decorator } from '../special/Decorator/spec'; +import type { TSClassImplements } from '../special/TSClassImplements/spec'; +import type { TSTypeParameterDeclaration } from '../special/TSTypeParameterDeclaration/spec'; +import type { TSTypeParameterInstantiation } from '../special/TSTypeParameterInstantiation/spec'; +import type { LeftHandSideExpression } from '../unions/LeftHandSideExpression'; +import type { BaseNode } from './BaseNode'; + +export interface ClassDeclarationBase extends BaseNode { + typeParameters?: TSTypeParameterDeclaration; + superTypeParameters?: TSTypeParameterInstantiation; + id: Identifier | null; + body: ClassBody; + superClass: LeftHandSideExpression | null; + implements?: TSClassImplements[]; + abstract?: boolean; + declare?: boolean; + decorators?: Decorator[]; +} diff --git a/packages/ast-spec/src/base/ClassPropertyBase.ts b/packages/ast-spec/src/base/ClassPropertyBase.ts new file mode 100644 index 000000000000..8ac19b05fa55 --- /dev/null +++ b/packages/ast-spec/src/base/ClassPropertyBase.ts @@ -0,0 +1,34 @@ +import type { Decorator } from '../special/Decorator/spec'; +import type { TSTypeAnnotation } from '../special/TSTypeAnnotation/spec'; +import type { Expression } from '../unions/Expression'; +import type { + PropertyName, + PropertyNameComputed, + PropertyNameNonComputed, +} from '../unions/PropertyName'; +import type { Accessibility } from './Accessibility'; +import type { BaseNode } from './BaseNode'; + +interface ClassPropertyBase extends BaseNode { + key: PropertyName; + value: Expression | null; + computed: boolean; + static: boolean; + declare: boolean; + readonly?: boolean; + decorators?: Decorator[]; + accessibility?: Accessibility; + optional?: boolean; + definite?: boolean; + typeAnnotation?: TSTypeAnnotation; +} + +export interface ClassPropertyComputedNameBase extends ClassPropertyBase { + key: PropertyNameComputed; + computed: true; +} + +export interface ClassPropertyNonComputedNameBase extends ClassPropertyBase { + key: PropertyNameNonComputed; + computed: false; +} diff --git a/packages/ast-spec/src/base/FunctionDeclarationBase.ts b/packages/ast-spec/src/base/FunctionDeclarationBase.ts new file mode 100644 index 000000000000..50b7aa97bf2f --- /dev/null +++ b/packages/ast-spec/src/base/FunctionDeclarationBase.ts @@ -0,0 +1,18 @@ +import type { Identifier } from '../expression/Identifier/spec'; +import type { TSTypeAnnotation } from '../special/TSTypeAnnotation/spec'; +import type { TSTypeParameterDeclaration } from '../special/TSTypeParameterDeclaration/spec'; +import type { BlockStatement } from '../statement/BlockStatement/spec'; +import type { Parameter } from '../unions/Parameter'; +import type { BaseNode } from './BaseNode'; + +export interface FunctionDeclarationBase extends BaseNode { + id: Identifier | null; + generator: boolean; + expression: boolean; + async: boolean; + params: Parameter[]; + body?: BlockStatement | null; + returnType?: TSTypeAnnotation; + typeParameters?: TSTypeParameterDeclaration; + declare?: boolean; +} diff --git a/packages/ast-spec/src/base/LineAndColumnData.ts b/packages/ast-spec/src/base/LineAndColumnData.ts new file mode 100644 index 000000000000..740ebe6fa467 --- /dev/null +++ b/packages/ast-spec/src/base/LineAndColumnData.ts @@ -0,0 +1,10 @@ +export interface LineAndColumnData { + /** + * Line number (1-indexed) + */ + line: number; + /** + * Column number on the line (0-indexed) + */ + column: number; +} diff --git a/packages/ast-spec/src/base/LiteralBase.ts b/packages/ast-spec/src/base/LiteralBase.ts new file mode 100644 index 000000000000..01a480ddc3cb --- /dev/null +++ b/packages/ast-spec/src/base/LiteralBase.ts @@ -0,0 +1,6 @@ +import type { BaseNode } from './BaseNode'; + +export interface LiteralBase extends BaseNode { + raw: string; + value: RegExp | bigint | boolean | number | string | null; +} diff --git a/packages/ast-spec/src/base/MethodDefinitionBase.ts b/packages/ast-spec/src/base/MethodDefinitionBase.ts new file mode 100644 index 000000000000..fe8846062106 --- /dev/null +++ b/packages/ast-spec/src/base/MethodDefinitionBase.ts @@ -0,0 +1,35 @@ +import type { FunctionExpression } from '../expression/FunctionExpression/spec'; +import type { TSEmptyBodyFunctionExpression } from '../expression/TSEmptyBodyFunctionExpression/spec'; +import type { Decorator } from '../special/Decorator/spec'; +import type { TSTypeParameterDeclaration } from '../special/TSTypeParameterDeclaration/spec'; +import type { + PropertyName, + PropertyNameComputed, + PropertyNameNonComputed, +} from '../unions/PropertyName'; +import type { Accessibility } from './Accessibility'; +import type { BaseNode } from './BaseNode'; + +/** this should not be directly used - instead use MethodDefinitionComputedNameBase or MethodDefinitionNonComputedNameBase */ +interface MethodDefinitionBase extends BaseNode { + key: PropertyName; + value: FunctionExpression | TSEmptyBodyFunctionExpression; + computed: boolean; + static: boolean; + kind: 'constructor' | 'get' | 'method' | 'set'; + optional?: boolean; + decorators?: Decorator[]; + accessibility?: Accessibility; + typeParameters?: TSTypeParameterDeclaration; +} + +export interface MethodDefinitionComputedNameBase extends MethodDefinitionBase { + key: PropertyNameComputed; + computed: true; +} + +export interface MethodDefinitionNonComputedNameBase + extends MethodDefinitionBase { + key: PropertyNameNonComputed; + computed: false; +} diff --git a/packages/ast-spec/src/base/OptionalRangeAndLoc.ts b/packages/ast-spec/src/base/OptionalRangeAndLoc.ts new file mode 100644 index 000000000000..d9b8cc9f874d --- /dev/null +++ b/packages/ast-spec/src/base/OptionalRangeAndLoc.ts @@ -0,0 +1,11 @@ +import type { Range } from './Range'; +import type { SourceLocation } from './SourceLocation'; + +// TODO - breaking change move this into `typescript-estree` +export type OptionalRangeAndLoc = Pick< + T, + Exclude +> & { + range?: Range; + loc?: SourceLocation; +}; diff --git a/packages/ast-spec/src/base/Range.ts b/packages/ast-spec/src/base/Range.ts new file mode 100644 index 000000000000..e78f71e3f747 --- /dev/null +++ b/packages/ast-spec/src/base/Range.ts @@ -0,0 +1,6 @@ +/** + * An array of two numbers. + * Both numbers are a 0-based index which is the position in the array of source code characters. + * The first is the start position of the node, the second is the end position of the node. + */ +export type Range = [number, number]; diff --git a/packages/ast-spec/src/base/SourceLocation.ts b/packages/ast-spec/src/base/SourceLocation.ts new file mode 100644 index 000000000000..e1a8e272a6fc --- /dev/null +++ b/packages/ast-spec/src/base/SourceLocation.ts @@ -0,0 +1,12 @@ +import type { LineAndColumnData } from './LineAndColumnData'; + +export interface SourceLocation { + /** + * The position of the first character of the parsed source region + */ + start: LineAndColumnData; + /** + * The position of the first character after the parsed source region + */ + end: LineAndColumnData; +} diff --git a/packages/ast-spec/src/base/TSFunctionSignatureBase.ts b/packages/ast-spec/src/base/TSFunctionSignatureBase.ts new file mode 100644 index 000000000000..0da1e7b414d6 --- /dev/null +++ b/packages/ast-spec/src/base/TSFunctionSignatureBase.ts @@ -0,0 +1,10 @@ +import type { TSTypeAnnotation } from '../special/TSTypeAnnotation/spec'; +import type { TSTypeParameterDeclaration } from '../special/TSTypeParameterDeclaration/spec'; +import type { Parameter } from '../unions/Parameter'; +import type { BaseNode } from './BaseNode'; + +export interface TSFunctionSignatureBase extends BaseNode { + params: Parameter[]; + returnType?: TSTypeAnnotation; + typeParameters?: TSTypeParameterDeclaration; +} diff --git a/packages/ast-spec/src/base/TSHeritageBase.ts b/packages/ast-spec/src/base/TSHeritageBase.ts new file mode 100644 index 000000000000..b3ed1770b674 --- /dev/null +++ b/packages/ast-spec/src/base/TSHeritageBase.ts @@ -0,0 +1,8 @@ +import type { TSTypeParameterInstantiation } from '../special/TSTypeParameterInstantiation/spec'; +import type { Expression } from '../unions/Expression'; +import type { BaseNode } from './BaseNode'; + +export interface TSHeritageBase extends BaseNode { + expression: Expression; + typeParameters?: TSTypeParameterInstantiation; +} diff --git a/packages/ast-spec/src/base/UnaryExpressionBase.ts b/packages/ast-spec/src/base/UnaryExpressionBase.ts new file mode 100644 index 000000000000..feb681ccbc3c --- /dev/null +++ b/packages/ast-spec/src/base/UnaryExpressionBase.ts @@ -0,0 +1,10 @@ +import type { UnaryExpression } from '../expression/UnaryExpression/spec'; +import type { LeftHandSideExpression } from '../unions/LeftHandSideExpression'; +import type { Literal } from '../unions/Literal'; +import type { BaseNode } from './BaseNode'; + +export interface UnaryExpressionBase extends BaseNode { + operator: string; + prefix: boolean; + argument: LeftHandSideExpression | Literal | UnaryExpression; +} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/spec.ts b/packages/ast-spec/src/declaration/ClassDeclaration/spec.ts new file mode 100644 index 000000000000..2154b8863a02 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { ClassDeclarationBase } from '../../base/ClassDeclarationBase'; + +export interface ClassDeclaration extends ClassDeclarationBase { + type: AST_NODE_TYPES.ClassDeclaration; +} diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/spec.ts b/packages/ast-spec/src/declaration/ExportAllDeclaration/spec.ts new file mode 100644 index 000000000000..e9657a7536fa --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/spec.ts @@ -0,0 +1,11 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; +import type { Expression } from '../../unions/Expression'; + +export interface ExportAllDeclaration extends BaseNode { + type: AST_NODE_TYPES.ExportAllDeclaration; + source: Expression | null; + exportKind: 'type' | 'value'; + exported: Identifier | null; +} diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/spec.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/spec.ts new file mode 100644 index 000000000000..f34b6e44668f --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { ExportDeclaration } from '../../unions/ExportDeclaration'; +import type { Expression } from '../../unions/Expression'; + +export interface ExportDefaultDeclaration extends BaseNode { + type: AST_NODE_TYPES.ExportDefaultDeclaration; + declaration: ExportDeclaration | Expression; + exportKind: 'type' | 'value'; +} diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts new file mode 100644 index 000000000000..021fea1c6330 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts @@ -0,0 +1,13 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { ExportSpecifier } from '../../special/ExportSpecifier/spec'; +import type { ExportDeclaration } from '../../unions/ExportDeclaration'; +import type { Expression } from '../../unions/Expression'; + +export interface ExportNamedDeclaration extends BaseNode { + type: AST_NODE_TYPES.ExportNamedDeclaration; + declaration: ExportDeclaration | null; + specifiers: ExportSpecifier[]; + source: Expression | null; + exportKind: 'type' | 'value'; +} diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/spec.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/spec.ts new file mode 100644 index 000000000000..59d7c4ffe39d --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { FunctionDeclarationBase } from '../../base/FunctionDeclarationBase'; +import type { BlockStatement } from '../../statement/BlockStatement/spec'; + +export interface FunctionDeclaration extends FunctionDeclarationBase { + type: AST_NODE_TYPES.FunctionDeclaration; + body: BlockStatement; +} diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/spec.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/spec.ts new file mode 100644 index 000000000000..88bd4aff2f21 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { FunctionDeclarationBase } from '../../base/FunctionDeclarationBase'; + +export interface TSDeclareFunction extends FunctionDeclarationBase { + type: AST_NODE_TYPES.TSDeclareFunction; +} diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts new file mode 100644 index 000000000000..1c1530d501ff --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts @@ -0,0 +1,14 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSEnumMember } from '../../element/TSEnumMember/spec'; +import type { Identifier } from '../../expression/Identifier/spec'; +import type { Modifier } from '../../unions/Modifier'; + +export interface TSEnumDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSEnumDeclaration; + id: Identifier; + members: TSEnumMember[]; + const?: boolean; + declare?: boolean; + modifiers?: Modifier[]; +} diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/spec.ts new file mode 100644 index 000000000000..4c434dded782 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/spec.ts @@ -0,0 +1,13 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; +import type { TSExternalModuleReference } from '../../special/TSExternalModuleReference/spec'; +import type { EntityName } from '../../unions/EntityName'; + +export interface TSImportEqualsDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSImportEqualsDeclaration; + id: Identifier; + moduleReference: EntityName | TSExternalModuleReference; + importKind: 'type' | 'value'; + isExport: boolean; +} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts new file mode 100644 index 000000000000..1e95380c3cbb --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts @@ -0,0 +1,17 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; +import type { TSInterfaceBody } from '../../special/TSInterfaceBody/spec'; +import type { TSInterfaceHeritage } from '../../special/TSInterfaceHeritage/spec'; +import type { TSTypeParameterDeclaration } from '../../special/TSTypeParameterDeclaration/spec'; + +export interface TSInterfaceDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSInterfaceDeclaration; + body: TSInterfaceBody; + id: Identifier; + typeParameters?: TSTypeParameterDeclaration; + extends?: TSInterfaceHeritage[]; + implements?: TSInterfaceHeritage[]; + abstract?: boolean; + declare?: boolean; +} diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts new file mode 100644 index 000000000000..ac63e52a5938 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts @@ -0,0 +1,26 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; +import type { TSModuleBlock } from '../../special/TSModuleBlock/spec'; +import type { Literal } from '../../unions/Literal'; +import type { Modifier } from '../../unions/Modifier'; + +export interface TSModuleDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSModuleDeclaration; + id: Identifier | Literal; + body?: + | TSModuleBlock + /* + TODO - we currently emit this due to bad parser handling of nested modules + namespace Foo.Bar {} + ^^^^^^^^^^^^^^^^^^^^ TSModuleDeclaration + ^^^^^^ TSModuleDeclaration + ^^ TSModuleBlock + + This should instead emit a TSQualifiedName for the `id` and not emit an inner TSModuleDeclaration + */ + | TSModuleDeclaration; + global?: boolean; + declare?: boolean; + modifiers?: Modifier[]; +} diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/spec.ts new file mode 100644 index 000000000000..6853d4a28544 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; + +export interface TSNamespaceExportDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSNamespaceExportDeclaration; + id: Identifier; +} diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/spec.ts new file mode 100644 index 000000000000..61ce986c2a23 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/spec.ts @@ -0,0 +1,13 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; +import type { TSTypeParameterDeclaration } from '../../special/TSTypeParameterDeclaration/spec'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSTypeAliasDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSTypeAliasDeclaration; + id: Identifier; + typeAnnotation: TypeNode; + declare?: boolean; + typeParameters?: TSTypeParameterDeclaration; +} diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/spec.ts b/packages/ast-spec/src/declaration/VariableDeclaration/spec.ts new file mode 100644 index 000000000000..418a51eb735b --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/spec.ts @@ -0,0 +1,11 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { VariableDeclarator } from '../../special/VariableDeclarator/spec'; + +export interface VariableDeclaration extends BaseNode { + type: AST_NODE_TYPES.VariableDeclaration; + // NOTE - this is not guaranteed to have any elements in it. i.e. `const;` + declarations: VariableDeclarator[]; + kind: 'const' | 'let' | 'var'; + declare?: boolean; +} diff --git a/packages/ast-spec/src/declaration/spec.ts b/packages/ast-spec/src/declaration/spec.ts new file mode 100644 index 000000000000..8d29c3cd70a1 --- /dev/null +++ b/packages/ast-spec/src/declaration/spec.ts @@ -0,0 +1,13 @@ +export * from './ClassDeclaration/spec'; +export * from './ExportAllDeclaration/spec'; +export * from './ExportDefaultDeclaration/spec'; +export * from './ExportNamedDeclaration/spec'; +export * from './FunctionDeclaration/spec'; +export * from './TSDeclareFunction/spec'; +export * from './TSEnumDeclaration/spec'; +export * from './TSImportEqualsDeclaration/spec'; +export * from './TSInterfaceDeclaration/spec'; +export * from './TSModuleDeclaration/spec'; +export * from './TSNamespaceExportDeclaration/spec'; +export * from './TSTypeAliasDeclaration/spec'; +export * from './VariableDeclaration/spec'; diff --git a/packages/ast-spec/src/element/ClassProperty/spec.ts b/packages/ast-spec/src/element/ClassProperty/spec.ts new file mode 100644 index 000000000000..29fe75aa84e6 --- /dev/null +++ b/packages/ast-spec/src/element/ClassProperty/spec.ts @@ -0,0 +1,19 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { + ClassPropertyComputedNameBase, + ClassPropertyNonComputedNameBase, +} from '../../base/ClassPropertyBase'; + +export interface ClassPropertyComputedName + extends ClassPropertyComputedNameBase { + type: AST_NODE_TYPES.ClassProperty; +} + +export interface ClassPropertyNonComputedName + extends ClassPropertyNonComputedNameBase { + type: AST_NODE_TYPES.ClassProperty; +} + +export type ClassProperty = + | ClassPropertyComputedName + | ClassPropertyNonComputedName; diff --git a/packages/ast-spec/src/element/MethodDefinition/spec.ts b/packages/ast-spec/src/element/MethodDefinition/spec.ts new file mode 100644 index 000000000000..f097f9f8e854 --- /dev/null +++ b/packages/ast-spec/src/element/MethodDefinition/spec.ts @@ -0,0 +1,19 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { + MethodDefinitionComputedNameBase, + MethodDefinitionNonComputedNameBase, +} from '../../base/MethodDefinitionBase'; + +export interface MethodDefinitionComputedName + extends MethodDefinitionComputedNameBase { + type: AST_NODE_TYPES.MethodDefinition; +} + +export interface MethodDefinitionNonComputedName + extends MethodDefinitionNonComputedNameBase { + type: AST_NODE_TYPES.MethodDefinition; +} + +export type MethodDefinition = + | MethodDefinitionComputedName + | MethodDefinitionNonComputedName; diff --git a/packages/ast-spec/src/element/Property/spec.ts b/packages/ast-spec/src/element/Property/spec.ts new file mode 100644 index 000000000000..c96a7a26e371 --- /dev/null +++ b/packages/ast-spec/src/element/Property/spec.ts @@ -0,0 +1,37 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSEmptyBodyFunctionExpression } from '../../expression/TSEmptyBodyFunctionExpression/spec'; +import type { AssignmentPattern } from '../../parameter/AssignmentPattern/spec'; +import type { BindingName } from '../../unions/BindingName'; +import type { Expression } from '../../unions/Expression'; +import type { + PropertyName, + PropertyNameComputed, + PropertyNameNonComputed, +} from '../../unions/PropertyName'; + +interface PropertyBase extends BaseNode { + type: AST_NODE_TYPES.Property; + key: PropertyName; + value: + | AssignmentPattern + | BindingName + | Expression + | TSEmptyBodyFunctionExpression; + computed: boolean; + method: boolean; + shorthand: boolean; + optional?: boolean; + kind: 'get' | 'init' | 'set'; +} + +export interface PropertyComputedName extends PropertyBase { + key: PropertyNameComputed; + computed: true; +} +export interface PropertyNonComputedName extends PropertyBase { + key: PropertyNameNonComputed; + computed: false; +} + +export type Property = PropertyComputedName | PropertyNonComputedName; diff --git a/packages/ast-spec/src/element/SpreadElement/spec.ts b/packages/ast-spec/src/element/SpreadElement/spec.ts new file mode 100644 index 000000000000..13a691901710 --- /dev/null +++ b/packages/ast-spec/src/element/SpreadElement/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; + +export interface SpreadElement extends BaseNode { + type: AST_NODE_TYPES.SpreadElement; + argument: Expression; +} diff --git a/packages/ast-spec/src/element/TSAbstractClassProperty/spec.ts b/packages/ast-spec/src/element/TSAbstractClassProperty/spec.ts new file mode 100644 index 000000000000..0d845a893290 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractClassProperty/spec.ts @@ -0,0 +1,19 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { + ClassPropertyComputedNameBase, + ClassPropertyNonComputedNameBase, +} from '../../base/ClassPropertyBase'; + +export interface TSAbstractClassPropertyComputedName + extends ClassPropertyComputedNameBase { + type: AST_NODE_TYPES.TSAbstractClassProperty; +} + +export interface TSAbstractClassPropertyNonComputedName + extends ClassPropertyNonComputedNameBase { + type: AST_NODE_TYPES.TSAbstractClassProperty; +} + +export type TSAbstractClassProperty = + | TSAbstractClassPropertyComputedName + | TSAbstractClassPropertyNonComputedName; diff --git a/packages/ast-spec/src/element/TSAbstractMethodDefinition/spec.ts b/packages/ast-spec/src/element/TSAbstractMethodDefinition/spec.ts new file mode 100644 index 000000000000..a8f5a05c50ab --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractMethodDefinition/spec.ts @@ -0,0 +1,19 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { + MethodDefinitionComputedNameBase, + MethodDefinitionNonComputedNameBase, +} from '../../base/MethodDefinitionBase'; + +export interface TSAbstractMethodDefinitionComputedName + extends MethodDefinitionComputedNameBase { + type: AST_NODE_TYPES.TSAbstractMethodDefinition; +} + +export interface TSAbstractMethodDefinitionNonComputedName + extends MethodDefinitionNonComputedNameBase { + type: AST_NODE_TYPES.TSAbstractMethodDefinition; +} + +export type TSAbstractMethodDefinition = + | TSAbstractMethodDefinitionComputedName + | TSAbstractMethodDefinitionNonComputedName; diff --git a/packages/ast-spec/src/element/TSCallSignatureDeclaration/spec.ts b/packages/ast-spec/src/element/TSCallSignatureDeclaration/spec.ts new file mode 100644 index 000000000000..8ba015661ccb --- /dev/null +++ b/packages/ast-spec/src/element/TSCallSignatureDeclaration/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { TSFunctionSignatureBase } from '../../base/TSFunctionSignatureBase'; + +export interface TSCallSignatureDeclaration extends TSFunctionSignatureBase { + type: AST_NODE_TYPES.TSCallSignatureDeclaration; +} diff --git a/packages/ast-spec/src/element/TSConstructSignatureDeclaration/spec.ts b/packages/ast-spec/src/element/TSConstructSignatureDeclaration/spec.ts new file mode 100644 index 000000000000..21feddb824d1 --- /dev/null +++ b/packages/ast-spec/src/element/TSConstructSignatureDeclaration/spec.ts @@ -0,0 +1,7 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { TSFunctionSignatureBase } from '../../base/TSFunctionSignatureBase'; + +export interface TSConstructSignatureDeclaration + extends TSFunctionSignatureBase { + type: AST_NODE_TYPES.TSConstructSignatureDeclaration; +} diff --git a/packages/ast-spec/src/element/TSEnumMember/spec.ts b/packages/ast-spec/src/element/TSEnumMember/spec.ts new file mode 100644 index 000000000000..97d8e49fcd94 --- /dev/null +++ b/packages/ast-spec/src/element/TSEnumMember/spec.ts @@ -0,0 +1,41 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { + PropertyNameComputed, + PropertyNameNonComputed, +} from '../../unions/PropertyName'; + +interface TSEnumMemberBase extends BaseNode { + type: AST_NODE_TYPES.TSEnumMember; + id: + | PropertyNameComputed // this should only happen in semantically invalid code (ts error 1164) + | PropertyNameNonComputed; + initializer?: Expression; + computed?: boolean; +} + +/** + * this should only really happen in semantically invalid code (errors 1164 and 2452) + * + * VALID: + * enum Foo { ['a'] } + * + * INVALID: + * const x = 'a'; + * enum Foo { [x] } + * enum Bar { ['a' + 'b'] } + */ +export interface TSEnumMemberComputedName extends TSEnumMemberBase { + id: PropertyNameComputed; + computed: true; +} + +export interface TSEnumMemberNonComputedName extends TSEnumMemberBase { + id: PropertyNameNonComputed; + computed?: false; +} + +export type TSEnumMember = + | TSEnumMemberComputedName + | TSEnumMemberNonComputedName; diff --git a/packages/ast-spec/src/element/TSIndexSignature/spec.ts b/packages/ast-spec/src/element/TSIndexSignature/spec.ts new file mode 100644 index 000000000000..38002bec2951 --- /dev/null +++ b/packages/ast-spec/src/element/TSIndexSignature/spec.ts @@ -0,0 +1,15 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { Accessibility } from '../../base/Accessibility'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSTypeAnnotation } from '../../special/TSTypeAnnotation/spec'; +import type { Parameter } from '../../unions/Parameter'; + +export interface TSIndexSignature extends BaseNode { + type: AST_NODE_TYPES.TSIndexSignature; + parameters: Parameter[]; + typeAnnotation?: TSTypeAnnotation; + readonly?: boolean; + accessibility?: Accessibility; + export?: boolean; + static?: boolean; +} diff --git a/packages/ast-spec/src/element/TSMethodSignature/spec.ts b/packages/ast-spec/src/element/TSMethodSignature/spec.ts new file mode 100644 index 000000000000..76b2e71ab3ad --- /dev/null +++ b/packages/ast-spec/src/element/TSMethodSignature/spec.ts @@ -0,0 +1,39 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { Accessibility } from '../../base/Accessibility'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSTypeAnnotation } from '../../special/TSTypeAnnotation/spec'; +import type { TSTypeParameterDeclaration } from '../../special/TSTypeParameterDeclaration/spec'; +import type { Parameter } from '../../unions/Parameter'; +import type { + PropertyName, + PropertyNameComputed, + PropertyNameNonComputed, +} from '../../unions/PropertyName'; + +interface TSMethodSignatureBase extends BaseNode { + type: AST_NODE_TYPES.TSMethodSignature; + key: PropertyName; + computed: boolean; + params: Parameter[]; + optional?: boolean; + returnType?: TSTypeAnnotation; + readonly?: boolean; + typeParameters?: TSTypeParameterDeclaration; + accessibility?: Accessibility; + export?: boolean; + static?: boolean; +} + +export interface TSMethodSignatureComputedName extends TSMethodSignatureBase { + key: PropertyNameComputed; + computed: true; +} +export interface TSMethodSignatureNonComputedName + extends TSMethodSignatureBase { + key: PropertyNameNonComputed; + computed: false; +} + +export type TSMethodSignature = + | TSMethodSignatureComputedName + | TSMethodSignatureNonComputedName; diff --git a/packages/ast-spec/src/element/TSPropertySignature/spec.ts b/packages/ast-spec/src/element/TSPropertySignature/spec.ts new file mode 100644 index 000000000000..a3f91ac26807 --- /dev/null +++ b/packages/ast-spec/src/element/TSPropertySignature/spec.ts @@ -0,0 +1,39 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { Accessibility } from '../../base/Accessibility'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSTypeAnnotation } from '../../special/TSTypeAnnotation/spec'; +import type { Expression } from '../../unions/Expression'; +import type { + PropertyName, + PropertyNameComputed, + PropertyNameNonComputed, +} from '../../unions/PropertyName'; + +interface TSPropertySignatureBase extends BaseNode { + type: AST_NODE_TYPES.TSPropertySignature; + key: PropertyName; + optional?: boolean; + computed: boolean; + typeAnnotation?: TSTypeAnnotation; + initializer?: Expression; + readonly?: boolean; + static?: boolean; + export?: boolean; + accessibility?: Accessibility; +} + +export interface TSPropertySignatureComputedName + extends TSPropertySignatureBase { + key: PropertyNameComputed; + computed: true; +} + +export interface TSPropertySignatureNonComputedName + extends TSPropertySignatureBase { + key: PropertyNameNonComputed; + computed: false; +} + +export type TSPropertySignature = + | TSPropertySignatureComputedName + | TSPropertySignatureNonComputedName; diff --git a/packages/ast-spec/src/element/spec.ts b/packages/ast-spec/src/element/spec.ts new file mode 100644 index 000000000000..5ee18d914024 --- /dev/null +++ b/packages/ast-spec/src/element/spec.ts @@ -0,0 +1,12 @@ +export * from './ClassProperty/spec'; +export * from './MethodDefinition/spec'; +export * from './Property/spec'; +export * from './SpreadElement/spec'; +export * from './TSAbstractClassProperty/spec'; +export * from './TSAbstractMethodDefinition/spec'; +export * from './TSCallSignatureDeclaration/spec'; +export * from './TSConstructSignatureDeclaration/spec'; +export * from './TSEnumMember/spec'; +export * from './TSIndexSignature/spec'; +export * from './TSMethodSignature/spec'; +export * from './TSPropertySignature/spec'; diff --git a/packages/ast-spec/src/expression/ArrayExpression/spec.ts b/packages/ast-spec/src/expression/ArrayExpression/spec.ts new file mode 100644 index 000000000000..7da330e231a4 --- /dev/null +++ b/packages/ast-spec/src/expression/ArrayExpression/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; + +export interface ArrayExpression extends BaseNode { + type: AST_NODE_TYPES.ArrayExpression; + elements: Expression[]; +} diff --git a/packages/ast-spec/src/expression/ArrowFunctionExpression/spec.ts b/packages/ast-spec/src/expression/ArrowFunctionExpression/spec.ts new file mode 100644 index 000000000000..347ee8541371 --- /dev/null +++ b/packages/ast-spec/src/expression/ArrowFunctionExpression/spec.ts @@ -0,0 +1,19 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSTypeAnnotation } from '../../special/TSTypeAnnotation/spec'; +import type { TSTypeParameterDeclaration } from '../../special/TSTypeParameterDeclaration/spec'; +import type { BlockStatement } from '../../statement/BlockStatement/spec'; +import type { Expression } from '../../unions/Expression'; +import type { Parameter } from '../../unions/Parameter'; + +export interface ArrowFunctionExpression extends BaseNode { + type: AST_NODE_TYPES.ArrowFunctionExpression; + generator: boolean; + id: null; + params: Parameter[]; + body: BlockStatement | Expression; + async: boolean; + expression: boolean; + returnType?: TSTypeAnnotation; + typeParameters?: TSTypeParameterDeclaration; +} diff --git a/packages/ast-spec/src/expression/AssignmentExpression/spec.ts b/packages/ast-spec/src/expression/AssignmentExpression/spec.ts new file mode 100644 index 000000000000..8d76be21bdcc --- /dev/null +++ b/packages/ast-spec/src/expression/AssignmentExpression/spec.ts @@ -0,0 +1,23 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BinaryExpressionBase } from '../../base/BinaryExpressionBase'; + +export interface AssignmentExpression extends BinaryExpressionBase { + type: AST_NODE_TYPES.AssignmentExpression; + operator: + | '-=' + | '??=' + | '**=' + | '*=' + | '/=' + | '&&=' + | '&=' + | '%=' + | '^=' + | '+=' + | '<<=' + | '=' + | '>>=' + | '>>>=' + | '|=' + | '||='; +} diff --git a/packages/ast-spec/src/expression/AwaitExpression/spec.ts b/packages/ast-spec/src/expression/AwaitExpression/spec.ts new file mode 100644 index 000000000000..248e371e871b --- /dev/null +++ b/packages/ast-spec/src/expression/AwaitExpression/spec.ts @@ -0,0 +1,16 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { LeftHandSideExpression } from '../../unions/LeftHandSideExpression'; +import type { TSTypeAssertion } from '../TSTypeAssertion/spec'; +import type { UnaryExpression } from '../UnaryExpression/spec'; +import type { UpdateExpression } from '../UpdateExpression/spec'; + +export interface AwaitExpression extends BaseNode { + type: AST_NODE_TYPES.AwaitExpression; + argument: + | AwaitExpression + | LeftHandSideExpression + | TSTypeAssertion + | UnaryExpression + | UpdateExpression; +} diff --git a/packages/ast-spec/src/expression/BinaryExpression/spec.ts b/packages/ast-spec/src/expression/BinaryExpression/spec.ts new file mode 100644 index 000000000000..5df33cc3e16a --- /dev/null +++ b/packages/ast-spec/src/expression/BinaryExpression/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BinaryExpressionBase } from '../../base/BinaryExpressionBase'; + +export interface BinaryExpression extends BinaryExpressionBase { + type: AST_NODE_TYPES.BinaryExpression; +} diff --git a/packages/ast-spec/src/expression/CallExpression/spec.ts b/packages/ast-spec/src/expression/CallExpression/spec.ts new file mode 100644 index 000000000000..bd71773a1be8 --- /dev/null +++ b/packages/ast-spec/src/expression/CallExpression/spec.ts @@ -0,0 +1,13 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSTypeParameterInstantiation } from '../../special/TSTypeParameterInstantiation/spec'; +import type { CallExpressionArgument } from '../../unions/CallExpressionArgument'; +import type { LeftHandSideExpression } from '../../unions/LeftHandSideExpression'; + +export interface CallExpression extends BaseNode { + type: AST_NODE_TYPES.CallExpression; + callee: LeftHandSideExpression; + arguments: CallExpressionArgument[]; + typeParameters?: TSTypeParameterInstantiation; + optional: boolean; +} diff --git a/packages/ast-spec/src/expression/ChainExpression/spec.ts b/packages/ast-spec/src/expression/ChainExpression/spec.ts new file mode 100644 index 000000000000..dfad50f3580f --- /dev/null +++ b/packages/ast-spec/src/expression/ChainExpression/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { ChainElement } from '../../unions/ChainElement'; + +export interface ChainExpression extends BaseNode { + type: AST_NODE_TYPES.ChainExpression; + expression: ChainElement; +} diff --git a/packages/ast-spec/src/expression/ClassExpression/spec.ts b/packages/ast-spec/src/expression/ClassExpression/spec.ts new file mode 100644 index 000000000000..15215c31f1b6 --- /dev/null +++ b/packages/ast-spec/src/expression/ClassExpression/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { ClassDeclarationBase } from '../../base/ClassDeclarationBase'; + +export interface ClassExpression extends ClassDeclarationBase { + type: AST_NODE_TYPES.ClassExpression; +} diff --git a/packages/ast-spec/src/expression/ConditionalExpression/spec.ts b/packages/ast-spec/src/expression/ConditionalExpression/spec.ts new file mode 100644 index 000000000000..545fc9497b77 --- /dev/null +++ b/packages/ast-spec/src/expression/ConditionalExpression/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; + +export interface ConditionalExpression extends BaseNode { + type: AST_NODE_TYPES.ConditionalExpression; + test: Expression; + consequent: Expression; + alternate: Expression; +} diff --git a/packages/ast-spec/src/expression/FunctionExpression/spec.ts b/packages/ast-spec/src/expression/FunctionExpression/spec.ts new file mode 100644 index 000000000000..111be168b024 --- /dev/null +++ b/packages/ast-spec/src/expression/FunctionExpression/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { FunctionDeclarationBase } from '../../base/FunctionDeclarationBase'; +import type { BlockStatement } from '../../statement/BlockStatement/spec'; + +export interface FunctionExpression extends FunctionDeclarationBase { + type: AST_NODE_TYPES.FunctionExpression; + body: BlockStatement; +} diff --git a/packages/ast-spec/src/expression/Identifier/spec.ts b/packages/ast-spec/src/expression/Identifier/spec.ts new file mode 100644 index 000000000000..384922a061a1 --- /dev/null +++ b/packages/ast-spec/src/expression/Identifier/spec.ts @@ -0,0 +1,12 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Decorator } from '../../special/Decorator/spec'; +import type { TSTypeAnnotation } from '../../special/TSTypeAnnotation/spec'; + +export interface Identifier extends BaseNode { + type: AST_NODE_TYPES.Identifier; + name: string; + typeAnnotation?: TSTypeAnnotation; + optional?: boolean; + decorators?: Decorator[]; +} diff --git a/packages/ast-spec/src/expression/ImportExpression/spec.ts b/packages/ast-spec/src/expression/ImportExpression/spec.ts new file mode 100644 index 000000000000..c381802571a6 --- /dev/null +++ b/packages/ast-spec/src/expression/ImportExpression/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; + +export interface ImportExpression extends BaseNode { + type: AST_NODE_TYPES.ImportExpression; + source: Expression; +} diff --git a/packages/ast-spec/src/expression/JSXElement/spec.ts b/packages/ast-spec/src/expression/JSXElement/spec.ts new file mode 100644 index 000000000000..32a514f677a3 --- /dev/null +++ b/packages/ast-spec/src/expression/JSXElement/spec.ts @@ -0,0 +1,12 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { JSXClosingElement } from '../../jsx/JSXClosingElement/spec'; +import type { JSXOpeningElement } from '../../jsx/JSXOpeningElement/spec'; +import type { JSXChild } from '../../unions/JSXChild'; + +export interface JSXElement extends BaseNode { + type: AST_NODE_TYPES.JSXElement; + openingElement: JSXOpeningElement; + closingElement: JSXClosingElement | null; + children: JSXChild[]; +} diff --git a/packages/ast-spec/src/expression/JSXFragment/spec.ts b/packages/ast-spec/src/expression/JSXFragment/spec.ts new file mode 100644 index 000000000000..9adce12ada58 --- /dev/null +++ b/packages/ast-spec/src/expression/JSXFragment/spec.ts @@ -0,0 +1,12 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { JSXClosingFragment } from '../../jsx/JSXClosingFragment/spec'; +import type { JSXOpeningFragment } from '../../jsx/JSXOpeningFragment/spec'; +import type { JSXChild } from '../../unions/JSXChild'; + +export interface JSXFragment extends BaseNode { + type: AST_NODE_TYPES.JSXFragment; + openingFragment: JSXOpeningFragment; + closingFragment: JSXClosingFragment; + children: JSXChild[]; +} diff --git a/packages/ast-spec/src/expression/LogicalExpression/spec.ts b/packages/ast-spec/src/expression/LogicalExpression/spec.ts new file mode 100644 index 000000000000..a9bd50e1dfe1 --- /dev/null +++ b/packages/ast-spec/src/expression/LogicalExpression/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BinaryExpressionBase } from '../../base/BinaryExpressionBase'; + +export interface LogicalExpression extends BinaryExpressionBase { + type: AST_NODE_TYPES.LogicalExpression; +} diff --git a/packages/ast-spec/src/expression/MemberExpression/spec.ts b/packages/ast-spec/src/expression/MemberExpression/spec.ts new file mode 100644 index 000000000000..92bad8cf3dc3 --- /dev/null +++ b/packages/ast-spec/src/expression/MemberExpression/spec.ts @@ -0,0 +1,28 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { LeftHandSideExpression } from '../../unions/LeftHandSideExpression'; +import type { Identifier } from '../Identifier/spec'; + +interface MemberExpressionBase extends BaseNode { + object: LeftHandSideExpression; + property: Expression | Identifier; + computed: boolean; + optional: boolean; +} + +export interface MemberExpressionComputedName extends MemberExpressionBase { + type: AST_NODE_TYPES.MemberExpression; + property: Expression; + computed: true; +} + +export interface MemberExpressionNonComputedName extends MemberExpressionBase { + type: AST_NODE_TYPES.MemberExpression; + property: Identifier; + computed: false; +} + +export type MemberExpression = + | MemberExpressionComputedName + | MemberExpressionNonComputedName; diff --git a/packages/ast-spec/src/expression/MetaProperty/spec.ts b/packages/ast-spec/src/expression/MetaProperty/spec.ts new file mode 100644 index 000000000000..5bc9afb81113 --- /dev/null +++ b/packages/ast-spec/src/expression/MetaProperty/spec.ts @@ -0,0 +1,9 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../Identifier/spec'; + +export interface MetaProperty extends BaseNode { + type: AST_NODE_TYPES.MetaProperty; + meta: Identifier; + property: Identifier; +} diff --git a/packages/ast-spec/src/expression/NewExpression/spec.ts b/packages/ast-spec/src/expression/NewExpression/spec.ts new file mode 100644 index 000000000000..bb75ae3f4b8f --- /dev/null +++ b/packages/ast-spec/src/expression/NewExpression/spec.ts @@ -0,0 +1,12 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSTypeParameterInstantiation } from '../../special/TSTypeParameterInstantiation/spec'; +import type { Expression } from '../../unions/Expression'; +import type { LeftHandSideExpression } from '../../unions/LeftHandSideExpression'; + +export interface NewExpression extends BaseNode { + type: AST_NODE_TYPES.NewExpression; + callee: LeftHandSideExpression; + arguments: Expression[]; + typeParameters?: TSTypeParameterInstantiation; +} diff --git a/packages/ast-spec/src/expression/ObjectExpression/spec.ts b/packages/ast-spec/src/expression/ObjectExpression/spec.ts new file mode 100644 index 000000000000..0573a2a76faf --- /dev/null +++ b/packages/ast-spec/src/expression/ObjectExpression/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { ObjectLiteralElement } from '../../unions/ObjectLiteralElement'; + +export interface ObjectExpression extends BaseNode { + type: AST_NODE_TYPES.ObjectExpression; + properties: ObjectLiteralElement[]; +} diff --git a/packages/ast-spec/src/expression/SequenceExpression/spec.ts b/packages/ast-spec/src/expression/SequenceExpression/spec.ts new file mode 100644 index 000000000000..fa571adb4f08 --- /dev/null +++ b/packages/ast-spec/src/expression/SequenceExpression/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; + +export interface SequenceExpression extends BaseNode { + type: AST_NODE_TYPES.SequenceExpression; + expressions: Expression[]; +} diff --git a/packages/ast-spec/src/expression/Super/spec.ts b/packages/ast-spec/src/expression/Super/spec.ts new file mode 100644 index 000000000000..eb310620d8ed --- /dev/null +++ b/packages/ast-spec/src/expression/Super/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface Super extends BaseNode { + type: AST_NODE_TYPES.Super; +} diff --git a/packages/ast-spec/src/expression/TSAsExpression/spec.ts b/packages/ast-spec/src/expression/TSAsExpression/spec.ts new file mode 100644 index 000000000000..b90925a53ca7 --- /dev/null +++ b/packages/ast-spec/src/expression/TSAsExpression/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSAsExpression extends BaseNode { + type: AST_NODE_TYPES.TSAsExpression; + expression: Expression; + typeAnnotation: TypeNode; +} diff --git a/packages/ast-spec/src/expression/TSEmptyBodyFunctionExpression/spec.ts b/packages/ast-spec/src/expression/TSEmptyBodyFunctionExpression/spec.ts new file mode 100644 index 000000000000..2cc413c01095 --- /dev/null +++ b/packages/ast-spec/src/expression/TSEmptyBodyFunctionExpression/spec.ts @@ -0,0 +1,7 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { FunctionDeclarationBase } from '../../base/FunctionDeclarationBase'; + +export interface TSEmptyBodyFunctionExpression extends FunctionDeclarationBase { + type: AST_NODE_TYPES.TSEmptyBodyFunctionExpression; + body: null; +} diff --git a/packages/ast-spec/src/expression/TSNonNullExpression/spec.ts b/packages/ast-spec/src/expression/TSNonNullExpression/spec.ts new file mode 100644 index 000000000000..fd25d33d372f --- /dev/null +++ b/packages/ast-spec/src/expression/TSNonNullExpression/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; + +export interface TSNonNullExpression extends BaseNode { + type: AST_NODE_TYPES.TSNonNullExpression; + expression: Expression; +} diff --git a/packages/ast-spec/src/expression/TSTypeAssertion/spec.ts b/packages/ast-spec/src/expression/TSTypeAssertion/spec.ts new file mode 100644 index 000000000000..d820f8fcc378 --- /dev/null +++ b/packages/ast-spec/src/expression/TSTypeAssertion/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSTypeAssertion extends BaseNode { + type: AST_NODE_TYPES.TSTypeAssertion; + typeAnnotation: TypeNode; + expression: Expression; +} diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/spec.ts b/packages/ast-spec/src/expression/TaggedTemplateExpression/spec.ts new file mode 100644 index 000000000000..e3438484d9dd --- /dev/null +++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/spec.ts @@ -0,0 +1,12 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSTypeParameterInstantiation } from '../../special/TSTypeParameterInstantiation/spec'; +import type { LeftHandSideExpression } from '../../unions/LeftHandSideExpression'; +import type { TemplateLiteral } from '../TemplateLiteral/spec'; + +export interface TaggedTemplateExpression extends BaseNode { + type: AST_NODE_TYPES.TaggedTemplateExpression; + typeParameters?: TSTypeParameterInstantiation; + tag: LeftHandSideExpression; + quasi: TemplateLiteral; +} diff --git a/packages/ast-spec/src/expression/TemplateLiteral/spec.ts b/packages/ast-spec/src/expression/TemplateLiteral/spec.ts new file mode 100644 index 000000000000..4d92ef79176d --- /dev/null +++ b/packages/ast-spec/src/expression/TemplateLiteral/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TemplateElement } from '../../special/TemplateElement/spec'; +import type { Expression } from '../../unions/Expression'; + +export interface TemplateLiteral extends BaseNode { + type: AST_NODE_TYPES.TemplateLiteral; + quasis: TemplateElement[]; + expressions: Expression[]; +} diff --git a/packages/ast-spec/src/expression/ThisExpression/spec.ts b/packages/ast-spec/src/expression/ThisExpression/spec.ts new file mode 100644 index 000000000000..63b5a213a883 --- /dev/null +++ b/packages/ast-spec/src/expression/ThisExpression/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface ThisExpression extends BaseNode { + type: AST_NODE_TYPES.ThisExpression; +} diff --git a/packages/ast-spec/src/expression/UnaryExpression/spec.ts b/packages/ast-spec/src/expression/UnaryExpression/spec.ts new file mode 100644 index 000000000000..26ec8a0e9cdf --- /dev/null +++ b/packages/ast-spec/src/expression/UnaryExpression/spec.ts @@ -0,0 +1,7 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { UnaryExpressionBase } from '../../base/UnaryExpressionBase'; + +export interface UnaryExpression extends UnaryExpressionBase { + type: AST_NODE_TYPES.UnaryExpression; + operator: '-' | '!' | '+' | '~' | 'delete' | 'typeof' | 'void'; +} diff --git a/packages/ast-spec/src/expression/UpdateExpression/spec.ts b/packages/ast-spec/src/expression/UpdateExpression/spec.ts new file mode 100644 index 000000000000..909815fdabf3 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/spec.ts @@ -0,0 +1,7 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { UnaryExpressionBase } from '../../base/UnaryExpressionBase'; + +export interface UpdateExpression extends UnaryExpressionBase { + type: AST_NODE_TYPES.UpdateExpression; + operator: '--' | '++'; +} diff --git a/packages/ast-spec/src/expression/YieldExpression/spec.ts b/packages/ast-spec/src/expression/YieldExpression/spec.ts new file mode 100644 index 000000000000..1f07e4f78e32 --- /dev/null +++ b/packages/ast-spec/src/expression/YieldExpression/spec.ts @@ -0,0 +1,9 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; + +export interface YieldExpression extends BaseNode { + type: AST_NODE_TYPES.YieldExpression; + delegate: boolean; + argument?: Expression; +} diff --git a/packages/ast-spec/src/expression/literal/BigIntLiteral/spec.ts b/packages/ast-spec/src/expression/literal/BigIntLiteral/spec.ts new file mode 100644 index 000000000000..c27a85543ff8 --- /dev/null +++ b/packages/ast-spec/src/expression/literal/BigIntLiteral/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../../ast-node-types'; +import type { LiteralBase } from '../../../base/LiteralBase'; + +export interface BigIntLiteral extends LiteralBase { + type: AST_NODE_TYPES.Literal; + value: bigint | null; + bigint: string; +} diff --git a/packages/ast-spec/src/expression/literal/BooleanLiteral/spec.ts b/packages/ast-spec/src/expression/literal/BooleanLiteral/spec.ts new file mode 100644 index 000000000000..a2310a698d02 --- /dev/null +++ b/packages/ast-spec/src/expression/literal/BooleanLiteral/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../../ast-node-types'; +import type { LiteralBase } from '../../../base/LiteralBase'; + +export interface BooleanLiteral extends LiteralBase { + type: AST_NODE_TYPES.Literal; + value: boolean; + raw: 'false' | 'true'; +} diff --git a/packages/ast-spec/src/expression/literal/NullLiteral/spec.ts b/packages/ast-spec/src/expression/literal/NullLiteral/spec.ts new file mode 100644 index 000000000000..f520b7b3d454 --- /dev/null +++ b/packages/ast-spec/src/expression/literal/NullLiteral/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../../ast-node-types'; +import type { LiteralBase } from '../../../base/LiteralBase'; + +export interface NullLiteral extends LiteralBase { + type: AST_NODE_TYPES.Literal; + value: null; + raw: 'null'; +} diff --git a/packages/ast-spec/src/expression/literal/NumberLiteral/spec.ts b/packages/ast-spec/src/expression/literal/NumberLiteral/spec.ts new file mode 100644 index 000000000000..8155bb45cafc --- /dev/null +++ b/packages/ast-spec/src/expression/literal/NumberLiteral/spec.ts @@ -0,0 +1,7 @@ +import type { AST_NODE_TYPES } from '../../../ast-node-types'; +import type { LiteralBase } from '../../../base/LiteralBase'; + +export interface NumberLiteral extends LiteralBase { + type: AST_NODE_TYPES.Literal; + value: number; +} diff --git a/packages/ast-spec/src/expression/literal/RegExpLiteral/spec.ts b/packages/ast-spec/src/expression/literal/RegExpLiteral/spec.ts new file mode 100644 index 000000000000..ab45f651b768 --- /dev/null +++ b/packages/ast-spec/src/expression/literal/RegExpLiteral/spec.ts @@ -0,0 +1,11 @@ +import type { AST_NODE_TYPES } from '../../../ast-node-types'; +import type { LiteralBase } from '../../../base/LiteralBase'; + +export interface RegExpLiteral extends LiteralBase { + type: AST_NODE_TYPES.Literal; + value: RegExp | null; + regex: { + pattern: string; + flags: string; + }; +} diff --git a/packages/ast-spec/src/expression/literal/StringLiteral/spec.ts b/packages/ast-spec/src/expression/literal/StringLiteral/spec.ts new file mode 100644 index 000000000000..de83d9d20e1d --- /dev/null +++ b/packages/ast-spec/src/expression/literal/StringLiteral/spec.ts @@ -0,0 +1,7 @@ +import type { AST_NODE_TYPES } from '../../../ast-node-types'; +import type { LiteralBase } from '../../../base/LiteralBase'; + +export interface StringLiteral extends LiteralBase { + type: AST_NODE_TYPES.Literal; + value: string; +} diff --git a/packages/ast-spec/src/expression/literal/spec.ts b/packages/ast-spec/src/expression/literal/spec.ts new file mode 100644 index 000000000000..d40804b424e1 --- /dev/null +++ b/packages/ast-spec/src/expression/literal/spec.ts @@ -0,0 +1,6 @@ +export * from './BigIntLiteral/spec'; +export * from './BooleanLiteral/spec'; +export * from './NullLiteral/spec'; +export * from './NumberLiteral/spec'; +export * from './RegExpLiteral/spec'; +export * from './StringLiteral/spec'; diff --git a/packages/ast-spec/src/expression/spec.ts b/packages/ast-spec/src/expression/spec.ts new file mode 100644 index 000000000000..9ea054546202 --- /dev/null +++ b/packages/ast-spec/src/expression/spec.ts @@ -0,0 +1,33 @@ +export * from './ArrayExpression/spec'; +export * from './ArrowFunctionExpression/spec'; +export * from './AssignmentExpression/spec'; +export * from './AwaitExpression/spec'; +export * from './BinaryExpression/spec'; +export * from './CallExpression/spec'; +export * from './ChainExpression/spec'; +export * from './ClassExpression/spec'; +export * from './ConditionalExpression/spec'; +export * from './FunctionExpression/spec'; +export * from './Identifier/spec'; +export * from './ImportExpression/spec'; +export * from './JSXElement/spec'; +export * from './JSXFragment/spec'; +export * from './LogicalExpression/spec'; +export * from './MemberExpression/spec'; +export * from './MetaProperty/spec'; +export * from './NewExpression/spec'; +export * from './ObjectExpression/spec'; +export * from './SequenceExpression/spec'; +export * from './Super/spec'; +export * from './TSAsExpression/spec'; +export * from './TSEmptyBodyFunctionExpression/spec'; +export * from './TSNonNullExpression/spec'; +export * from './TSTypeAssertion/spec'; +export * from './TaggedTemplateExpression/spec'; +export * from './TemplateLiteral/spec'; +export * from './ThisExpression/spec'; +export * from './UnaryExpression/spec'; +export * from './UpdateExpression/spec'; +export * from './YieldExpression/spec'; + +export * from './literal/spec'; diff --git a/packages/ast-spec/src/index.ts b/packages/ast-spec/src/index.ts new file mode 100644 index 000000000000..bd4b6584482d --- /dev/null +++ b/packages/ast-spec/src/index.ts @@ -0,0 +1,52 @@ +export * from './base/Accessibility'; +export * from './base/BaseNode'; // this is exported so that the `types` package can merge the decl and add the `parent` property +export * from './base/OptionalRangeAndLoc'; +export * from './base/LineAndColumnData'; +export * from './base/Range'; +export * from './base/SourceLocation'; + +export * from './unions/BindingName'; +export * from './unions/BindingPattern'; +export * from './unions/CallExpressionArgument'; +export * from './unions/ChainElement'; +export * from './unions/ClassElement'; +export * from './unions/Comment'; +export * from './unions/DeclarationStatement'; +export * from './unions/DestructuringPattern'; +export * from './unions/EntityName'; +export * from './unions/ExportDeclaration'; +export * from './unions/Expression'; +export * from './unions/ForInitialiser'; +export * from './unions/FunctionLike'; +export * from './unions/ImportClause'; +export * from './unions/IterationStatement'; +export * from './unions/JSXChild'; +export * from './unions/JSXExpression'; +export * from './unions/JSXTagNameExpression'; +export * from './unions/LeftHandSideExpression'; +export * from './unions/Literal'; +export * from './unions/LiteralExpression'; +export * from './unions/Modifier'; +export * from './unions/Node'; +export * from './unions/ObjectLiteralElement'; +export * from './unions/Parameter'; +export * from './unions/PrimaryExpression'; +export * from './unions/PropertyName'; +export * from './unions/Statement'; +export * from './unions/TSUnaryExpression'; +export * from './unions/Token'; +export * from './unions/TypeElement'; +export * from './unions/TypeNode'; + +export * from './declaration/spec'; +export * from './element/spec'; +export * from './expression/spec'; +export * from './jsx/spec'; +export * from './parameter/spec'; +export * from './special/spec'; +export * from './statement/spec'; +export * from './token/spec'; +export * from './type/spec'; + +export * from './ast-node-types'; +export * from './ast-token-types'; diff --git a/packages/ast-spec/src/jsx/JSXAttribute/spec.ts b/packages/ast-spec/src/jsx/JSXAttribute/spec.ts new file mode 100644 index 000000000000..8fc8364c05fd --- /dev/null +++ b/packages/ast-spec/src/jsx/JSXAttribute/spec.ts @@ -0,0 +1,12 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { JSXExpression } from '../../unions/JSXExpression'; +import type { Literal } from '../../unions/Literal'; +import type { JSXIdentifier } from '../JSXIdentifier/spec'; +import type { JSXNamespacedName } from '../JSXNamespacedName/spec'; + +export interface JSXAttribute extends BaseNode { + type: AST_NODE_TYPES.JSXAttribute; + name: JSXIdentifier | JSXNamespacedName; + value: JSXExpression | Literal | null; +} diff --git a/packages/ast-spec/src/jsx/JSXClosingElement/spec.ts b/packages/ast-spec/src/jsx/JSXClosingElement/spec.ts new file mode 100644 index 000000000000..ea698d6059ed --- /dev/null +++ b/packages/ast-spec/src/jsx/JSXClosingElement/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { JSXTagNameExpression } from '../../unions/JSXTagNameExpression'; + +export interface JSXClosingElement extends BaseNode { + type: AST_NODE_TYPES.JSXClosingElement; + name: JSXTagNameExpression; +} diff --git a/packages/ast-spec/src/jsx/JSXClosingFragment/spec.ts b/packages/ast-spec/src/jsx/JSXClosingFragment/spec.ts new file mode 100644 index 000000000000..8edd7c4e958f --- /dev/null +++ b/packages/ast-spec/src/jsx/JSXClosingFragment/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface JSXClosingFragment extends BaseNode { + type: AST_NODE_TYPES.JSXClosingFragment; +} diff --git a/packages/ast-spec/src/jsx/JSXEmptyExpression/spec.ts b/packages/ast-spec/src/jsx/JSXEmptyExpression/spec.ts new file mode 100644 index 000000000000..36e3c16069c4 --- /dev/null +++ b/packages/ast-spec/src/jsx/JSXEmptyExpression/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface JSXEmptyExpression extends BaseNode { + type: AST_NODE_TYPES.JSXEmptyExpression; +} diff --git a/packages/ast-spec/src/jsx/JSXExpressionContainer/spec.ts b/packages/ast-spec/src/jsx/JSXExpressionContainer/spec.ts new file mode 100644 index 000000000000..1a0673e6fd15 --- /dev/null +++ b/packages/ast-spec/src/jsx/JSXExpressionContainer/spec.ts @@ -0,0 +1,9 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { JSXEmptyExpression } from '../JSXEmptyExpression/spec'; + +export interface JSXExpressionContainer extends BaseNode { + type: AST_NODE_TYPES.JSXExpressionContainer; + expression: Expression | JSXEmptyExpression; +} diff --git a/packages/ast-spec/src/jsx/JSXIdentifier/spec.ts b/packages/ast-spec/src/jsx/JSXIdentifier/spec.ts new file mode 100644 index 000000000000..1d7b71d67ab0 --- /dev/null +++ b/packages/ast-spec/src/jsx/JSXIdentifier/spec.ts @@ -0,0 +1,7 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface JSXIdentifier extends BaseNode { + type: AST_NODE_TYPES.JSXIdentifier; + name: string; +} diff --git a/packages/ast-spec/src/jsx/JSXMemberExpression/spec.ts b/packages/ast-spec/src/jsx/JSXMemberExpression/spec.ts new file mode 100644 index 000000000000..e0cda9c16ee4 --- /dev/null +++ b/packages/ast-spec/src/jsx/JSXMemberExpression/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { JSXTagNameExpression } from '../../unions/JSXTagNameExpression'; +import type { JSXIdentifier } from '../JSXIdentifier/spec'; + +export interface JSXMemberExpression extends BaseNode { + type: AST_NODE_TYPES.JSXMemberExpression; + object: JSXTagNameExpression; + property: JSXIdentifier; +} diff --git a/packages/ast-spec/src/jsx/JSXNamespacedName/spec.ts b/packages/ast-spec/src/jsx/JSXNamespacedName/spec.ts new file mode 100644 index 000000000000..22443d938eca --- /dev/null +++ b/packages/ast-spec/src/jsx/JSXNamespacedName/spec.ts @@ -0,0 +1,9 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { JSXIdentifier } from '../JSXIdentifier/spec'; + +export interface JSXNamespacedName extends BaseNode { + type: AST_NODE_TYPES.JSXNamespacedName; + namespace: JSXIdentifier; + name: JSXIdentifier; +} diff --git a/packages/ast-spec/src/jsx/JSXOpeningElement/spec.ts b/packages/ast-spec/src/jsx/JSXOpeningElement/spec.ts new file mode 100644 index 000000000000..710fade02fa5 --- /dev/null +++ b/packages/ast-spec/src/jsx/JSXOpeningElement/spec.ts @@ -0,0 +1,14 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSTypeParameterInstantiation } from '../../special/TSTypeParameterInstantiation/spec'; +import type { JSXTagNameExpression } from '../../unions/JSXTagNameExpression'; +import type { JSXAttribute } from '../JSXAttribute/spec'; +import type { JSXSpreadAttribute } from '../JSXSpreadAttribute/spec'; + +export interface JSXOpeningElement extends BaseNode { + type: AST_NODE_TYPES.JSXOpeningElement; + typeParameters?: TSTypeParameterInstantiation; + selfClosing: boolean; + name: JSXTagNameExpression; + attributes: (JSXAttribute | JSXSpreadAttribute)[]; +} diff --git a/packages/ast-spec/src/jsx/JSXOpeningFragment/spec.ts b/packages/ast-spec/src/jsx/JSXOpeningFragment/spec.ts new file mode 100644 index 000000000000..9b972a237f22 --- /dev/null +++ b/packages/ast-spec/src/jsx/JSXOpeningFragment/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface JSXOpeningFragment extends BaseNode { + type: AST_NODE_TYPES.JSXOpeningFragment; +} diff --git a/packages/ast-spec/src/jsx/JSXSpreadAttribute/spec.ts b/packages/ast-spec/src/jsx/JSXSpreadAttribute/spec.ts new file mode 100644 index 000000000000..db6e6fc1d1bc --- /dev/null +++ b/packages/ast-spec/src/jsx/JSXSpreadAttribute/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; + +export interface JSXSpreadAttribute extends BaseNode { + type: AST_NODE_TYPES.JSXSpreadAttribute; + argument: Expression; +} diff --git a/packages/ast-spec/src/jsx/JSXSpreadChild/spec.ts b/packages/ast-spec/src/jsx/JSXSpreadChild/spec.ts new file mode 100644 index 000000000000..53fe53555c30 --- /dev/null +++ b/packages/ast-spec/src/jsx/JSXSpreadChild/spec.ts @@ -0,0 +1,9 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { JSXEmptyExpression } from '../JSXEmptyExpression/spec'; + +export interface JSXSpreadChild extends BaseNode { + type: AST_NODE_TYPES.JSXSpreadChild; + expression: Expression | JSXEmptyExpression; +} diff --git a/packages/ast-spec/src/jsx/JSXText/spec.ts b/packages/ast-spec/src/jsx/JSXText/spec.ts new file mode 100644 index 000000000000..a323493fba90 --- /dev/null +++ b/packages/ast-spec/src/jsx/JSXText/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface JSXText extends BaseNode { + type: AST_NODE_TYPES.JSXText; + value: string; + raw: string; +} diff --git a/packages/ast-spec/src/jsx/spec.ts b/packages/ast-spec/src/jsx/spec.ts new file mode 100644 index 000000000000..1efb134bed7f --- /dev/null +++ b/packages/ast-spec/src/jsx/spec.ts @@ -0,0 +1,13 @@ +export * from './JSXAttribute/spec'; +export * from './JSXClosingElement/spec'; +export * from './JSXClosingFragment/spec'; +export * from './JSXEmptyExpression/spec'; +export * from './JSXExpressionContainer/spec'; +export * from './JSXIdentifier/spec'; +export * from './JSXMemberExpression/spec'; +export * from './JSXNamespacedName/spec'; +export * from './JSXOpeningElement/spec'; +export * from './JSXOpeningFragment/spec'; +export * from './JSXSpreadAttribute/spec'; +export * from './JSXSpreadChild/spec'; +export * from './JSXText/spec'; diff --git a/packages/ast-spec/src/parameter/ArrayPattern/spec.ts b/packages/ast-spec/src/parameter/ArrayPattern/spec.ts new file mode 100644 index 000000000000..420a93278731 --- /dev/null +++ b/packages/ast-spec/src/parameter/ArrayPattern/spec.ts @@ -0,0 +1,13 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Decorator } from '../../special/Decorator/spec'; +import type { TSTypeAnnotation } from '../../special/TSTypeAnnotation/spec'; +import type { DestructuringPattern } from '../../unions/DestructuringPattern'; + +export interface ArrayPattern extends BaseNode { + type: AST_NODE_TYPES.ArrayPattern; + elements: (DestructuringPattern | null)[]; + typeAnnotation?: TSTypeAnnotation; + optional?: boolean; + decorators?: Decorator[]; +} diff --git a/packages/ast-spec/src/parameter/AssignmentPattern/spec.ts b/packages/ast-spec/src/parameter/AssignmentPattern/spec.ts new file mode 100644 index 000000000000..ee558c2167c2 --- /dev/null +++ b/packages/ast-spec/src/parameter/AssignmentPattern/spec.ts @@ -0,0 +1,15 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Decorator } from '../../special/Decorator/spec'; +import type { TSTypeAnnotation } from '../../special/TSTypeAnnotation/spec'; +import type { BindingName } from '../../unions/BindingName'; +import type { Expression } from '../../unions/Expression'; + +export interface AssignmentPattern extends BaseNode { + type: AST_NODE_TYPES.AssignmentPattern; + left: BindingName; + right: Expression; + typeAnnotation?: TSTypeAnnotation; + optional?: boolean; + decorators?: Decorator[]; +} diff --git a/packages/ast-spec/src/parameter/ObjectPattern/spec.ts b/packages/ast-spec/src/parameter/ObjectPattern/spec.ts new file mode 100644 index 000000000000..12c89878794e --- /dev/null +++ b/packages/ast-spec/src/parameter/ObjectPattern/spec.ts @@ -0,0 +1,14 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Property } from '../../element/Property/spec'; +import type { Decorator } from '../../special/Decorator/spec'; +import type { TSTypeAnnotation } from '../../special/TSTypeAnnotation/spec'; +import type { RestElement } from '../RestElement/spec'; + +export interface ObjectPattern extends BaseNode { + type: AST_NODE_TYPES.ObjectPattern; + properties: (Property | RestElement)[]; + typeAnnotation?: TSTypeAnnotation; + optional?: boolean; + decorators?: Decorator[]; +} diff --git a/packages/ast-spec/src/parameter/RestElement/spec.ts b/packages/ast-spec/src/parameter/RestElement/spec.ts new file mode 100644 index 000000000000..006f5e48ba3b --- /dev/null +++ b/packages/ast-spec/src/parameter/RestElement/spec.ts @@ -0,0 +1,15 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Decorator } from '../../special/Decorator/spec'; +import type { TSTypeAnnotation } from '../../special/TSTypeAnnotation/spec'; +import type { DestructuringPattern } from '../../unions/DestructuringPattern'; +import type { AssignmentPattern } from '../AssignmentPattern/spec'; + +export interface RestElement extends BaseNode { + type: AST_NODE_TYPES.RestElement; + argument: DestructuringPattern; + typeAnnotation?: TSTypeAnnotation; + optional?: boolean; + value?: AssignmentPattern; + decorators?: Decorator[]; +} diff --git a/packages/ast-spec/src/parameter/TSParameterProperty/spec.ts b/packages/ast-spec/src/parameter/TSParameterProperty/spec.ts new file mode 100644 index 000000000000..d04e49fd98b8 --- /dev/null +++ b/packages/ast-spec/src/parameter/TSParameterProperty/spec.ts @@ -0,0 +1,17 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { Accessibility } from '../../base/Accessibility'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Decorator } from '../../special/Decorator/spec'; +import type { BindingName } from '../../unions/BindingName'; +import type { AssignmentPattern } from '../AssignmentPattern/spec'; +import type { RestElement } from '../RestElement/spec'; + +export interface TSParameterProperty extends BaseNode { + type: AST_NODE_TYPES.TSParameterProperty; + accessibility?: Accessibility; + readonly?: boolean; + static?: boolean; + export?: boolean; + parameter: AssignmentPattern | BindingName | RestElement; + decorators?: Decorator[]; +} diff --git a/packages/ast-spec/src/parameter/spec.ts b/packages/ast-spec/src/parameter/spec.ts new file mode 100644 index 000000000000..b006664a36ae --- /dev/null +++ b/packages/ast-spec/src/parameter/spec.ts @@ -0,0 +1,5 @@ +export * from './ArrayPattern/spec'; +export * from './AssignmentPattern/spec'; +export * from './ObjectPattern/spec'; +export * from './RestElement/spec'; +export * from './TSParameterProperty/spec'; diff --git a/packages/ast-spec/src/special/CatchClause/spec.ts b/packages/ast-spec/src/special/CatchClause/spec.ts new file mode 100644 index 000000000000..dea8168acda0 --- /dev/null +++ b/packages/ast-spec/src/special/CatchClause/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { BlockStatement } from '../../statement/BlockStatement/spec'; +import type { BindingName } from '../../unions/BindingName'; + +export interface CatchClause extends BaseNode { + type: AST_NODE_TYPES.CatchClause; + param: BindingName | null; + body: BlockStatement; +} diff --git a/packages/ast-spec/src/special/ClassBody/spec.ts b/packages/ast-spec/src/special/ClassBody/spec.ts new file mode 100644 index 000000000000..11c93d540fb3 --- /dev/null +++ b/packages/ast-spec/src/special/ClassBody/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { ClassElement } from '../../unions/ClassElement'; + +export interface ClassBody extends BaseNode { + type: AST_NODE_TYPES.ClassBody; + body: ClassElement[]; +} diff --git a/packages/ast-spec/src/special/Decorator/spec.ts b/packages/ast-spec/src/special/Decorator/spec.ts new file mode 100644 index 000000000000..3c8d1e819042 --- /dev/null +++ b/packages/ast-spec/src/special/Decorator/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { LeftHandSideExpression } from '../../unions/LeftHandSideExpression'; + +export interface Decorator extends BaseNode { + type: AST_NODE_TYPES.Decorator; + expression: LeftHandSideExpression; +} diff --git a/packages/ast-spec/src/special/EmptyStatement/spec.ts b/packages/ast-spec/src/special/EmptyStatement/spec.ts new file mode 100644 index 000000000000..530283d3bdc1 --- /dev/null +++ b/packages/ast-spec/src/special/EmptyStatement/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface EmptyStatement extends BaseNode { + type: AST_NODE_TYPES.EmptyStatement; +} diff --git a/packages/ast-spec/src/special/ExportSpecifier/spec.ts b/packages/ast-spec/src/special/ExportSpecifier/spec.ts new file mode 100644 index 000000000000..8fd038e92be6 --- /dev/null +++ b/packages/ast-spec/src/special/ExportSpecifier/spec.ts @@ -0,0 +1,9 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; + +export interface ExportSpecifier extends BaseNode { + type: AST_NODE_TYPES.ExportSpecifier; + local: Identifier; + exported: Identifier; +} diff --git a/packages/ast-spec/src/special/ImportDefaultSpecifier/spec.ts b/packages/ast-spec/src/special/ImportDefaultSpecifier/spec.ts new file mode 100644 index 000000000000..c4ad22f20340 --- /dev/null +++ b/packages/ast-spec/src/special/ImportDefaultSpecifier/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; + +export interface ImportDefaultSpecifier extends BaseNode { + type: AST_NODE_TYPES.ImportDefaultSpecifier; + local: Identifier; +} diff --git a/packages/ast-spec/src/special/ImportNamespaceSpecifier/spec.ts b/packages/ast-spec/src/special/ImportNamespaceSpecifier/spec.ts new file mode 100644 index 000000000000..eec79636f1fc --- /dev/null +++ b/packages/ast-spec/src/special/ImportNamespaceSpecifier/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; + +export interface ImportNamespaceSpecifier extends BaseNode { + type: AST_NODE_TYPES.ImportNamespaceSpecifier; + local: Identifier; +} diff --git a/packages/ast-spec/src/special/ImportSpecifier/spec.ts b/packages/ast-spec/src/special/ImportSpecifier/spec.ts new file mode 100644 index 000000000000..326df7db6b65 --- /dev/null +++ b/packages/ast-spec/src/special/ImportSpecifier/spec.ts @@ -0,0 +1,9 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; + +export interface ImportSpecifier extends BaseNode { + type: AST_NODE_TYPES.ImportSpecifier; + local: Identifier; + imported: Identifier; +} diff --git a/packages/ast-spec/src/special/Program/spec.ts b/packages/ast-spec/src/special/Program/spec.ts new file mode 100644 index 000000000000..81d69e1e604d --- /dev/null +++ b/packages/ast-spec/src/special/Program/spec.ts @@ -0,0 +1,13 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Comment } from '../../unions/Comment'; +import type { ProgramStatement } from '../../unions/Statement'; +import type { Token } from '../../unions/Token'; + +export interface Program extends BaseNode { + type: AST_NODE_TYPES.Program; + body: ProgramStatement[]; + sourceType: 'module' | 'script'; + comments?: Comment[]; + tokens?: Token[]; +} diff --git a/packages/ast-spec/src/special/SwitchCase/spec.ts b/packages/ast-spec/src/special/SwitchCase/spec.ts new file mode 100644 index 000000000000..f48f323536a4 --- /dev/null +++ b/packages/ast-spec/src/special/SwitchCase/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { Statement } from '../../unions/Statement'; + +export interface SwitchCase extends BaseNode { + type: AST_NODE_TYPES.SwitchCase; + test: Expression | null; + consequent: Statement[]; +} diff --git a/packages/ast-spec/src/special/TSClassImplements/spec.ts b/packages/ast-spec/src/special/TSClassImplements/spec.ts new file mode 100644 index 000000000000..98213713edc4 --- /dev/null +++ b/packages/ast-spec/src/special/TSClassImplements/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { TSHeritageBase } from '../../base/TSHeritageBase'; + +export interface TSClassImplements extends TSHeritageBase { + type: AST_NODE_TYPES.TSClassImplements; +} diff --git a/packages/ast-spec/src/special/TSExternalModuleReference/spec.ts b/packages/ast-spec/src/special/TSExternalModuleReference/spec.ts new file mode 100644 index 000000000000..e634d4d0d6e9 --- /dev/null +++ b/packages/ast-spec/src/special/TSExternalModuleReference/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; + +export interface TSExternalModuleReference extends BaseNode { + type: AST_NODE_TYPES.TSExternalModuleReference; + expression: Expression; +} diff --git a/packages/ast-spec/src/special/TSInterfaceBody/spec.ts b/packages/ast-spec/src/special/TSInterfaceBody/spec.ts new file mode 100644 index 000000000000..1ee1c901c14d --- /dev/null +++ b/packages/ast-spec/src/special/TSInterfaceBody/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeElement } from '../../unions/TypeElement'; + +export interface TSInterfaceBody extends BaseNode { + type: AST_NODE_TYPES.TSInterfaceBody; + body: TypeElement[]; +} diff --git a/packages/ast-spec/src/special/TSInterfaceHeritage/spec.ts b/packages/ast-spec/src/special/TSInterfaceHeritage/spec.ts new file mode 100644 index 000000000000..29382acd5460 --- /dev/null +++ b/packages/ast-spec/src/special/TSInterfaceHeritage/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { TSHeritageBase } from '../../base/TSHeritageBase'; + +export interface TSInterfaceHeritage extends TSHeritageBase { + type: AST_NODE_TYPES.TSInterfaceHeritage; +} diff --git a/packages/ast-spec/src/special/TSModuleBlock/spec.ts b/packages/ast-spec/src/special/TSModuleBlock/spec.ts new file mode 100644 index 000000000000..9fed19af3b80 --- /dev/null +++ b/packages/ast-spec/src/special/TSModuleBlock/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { ProgramStatement } from '../../unions/Statement'; + +export interface TSModuleBlock extends BaseNode { + type: AST_NODE_TYPES.TSModuleBlock; + body: ProgramStatement[]; +} diff --git a/packages/ast-spec/src/special/TSTypeAnnotation/spec.ts b/packages/ast-spec/src/special/TSTypeAnnotation/spec.ts new file mode 100644 index 000000000000..bb9272353cbc --- /dev/null +++ b/packages/ast-spec/src/special/TSTypeAnnotation/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSTypeAnnotation extends BaseNode { + type: AST_NODE_TYPES.TSTypeAnnotation; + typeAnnotation: TypeNode; +} diff --git a/packages/ast-spec/src/special/TSTypeParameter/spec.ts b/packages/ast-spec/src/special/TSTypeParameter/spec.ts new file mode 100644 index 000000000000..61d75a6a29ed --- /dev/null +++ b/packages/ast-spec/src/special/TSTypeParameter/spec.ts @@ -0,0 +1,11 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSTypeParameter extends BaseNode { + type: AST_NODE_TYPES.TSTypeParameter; + name: Identifier; + constraint?: TypeNode; + default?: TypeNode; +} diff --git a/packages/ast-spec/src/special/TSTypeParameterDeclaration/spec.ts b/packages/ast-spec/src/special/TSTypeParameterDeclaration/spec.ts new file mode 100644 index 000000000000..ac8971e38a0c --- /dev/null +++ b/packages/ast-spec/src/special/TSTypeParameterDeclaration/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSTypeParameter } from '../TSTypeParameter/spec'; + +export interface TSTypeParameterDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSTypeParameterDeclaration; + params: TSTypeParameter[]; +} diff --git a/packages/ast-spec/src/special/TSTypeParameterInstantiation/spec.ts b/packages/ast-spec/src/special/TSTypeParameterInstantiation/spec.ts new file mode 100644 index 000000000000..e5122c2f6a5c --- /dev/null +++ b/packages/ast-spec/src/special/TSTypeParameterInstantiation/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSTypeParameterInstantiation extends BaseNode { + type: AST_NODE_TYPES.TSTypeParameterInstantiation; + params: TypeNode[]; +} diff --git a/packages/ast-spec/src/special/TemplateElement/spec.ts b/packages/ast-spec/src/special/TemplateElement/spec.ts new file mode 100644 index 000000000000..abf4dc910457 --- /dev/null +++ b/packages/ast-spec/src/special/TemplateElement/spec.ts @@ -0,0 +1,11 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TemplateElement extends BaseNode { + type: AST_NODE_TYPES.TemplateElement; + value: { + raw: string; + cooked: string; + }; + tail: boolean; +} diff --git a/packages/ast-spec/src/special/VariableDeclarator/spec.ts b/packages/ast-spec/src/special/VariableDeclarator/spec.ts new file mode 100644 index 000000000000..619c6a57d5dc --- /dev/null +++ b/packages/ast-spec/src/special/VariableDeclarator/spec.ts @@ -0,0 +1,11 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { BindingName } from '../../unions/BindingName'; +import type { Expression } from '../../unions/Expression'; + +export interface VariableDeclarator extends BaseNode { + type: AST_NODE_TYPES.VariableDeclarator; + id: BindingName; + init: Expression | null; + definite?: boolean; +} diff --git a/packages/ast-spec/src/special/spec.ts b/packages/ast-spec/src/special/spec.ts new file mode 100644 index 000000000000..07142e15c8f9 --- /dev/null +++ b/packages/ast-spec/src/special/spec.ts @@ -0,0 +1,21 @@ +export * from './CatchClause/spec'; +export * from './ClassBody/spec'; +export * from './Decorator/spec'; +export * from './EmptyStatement/spec'; +export * from './ExportSpecifier/spec'; +export * from './ImportDefaultSpecifier/spec'; +export * from './ImportNamespaceSpecifier/spec'; +export * from './ImportSpecifier/spec'; +export * from './Program/spec'; +export * from './SwitchCase/spec'; +export * from './TSClassImplements/spec'; +export * from './TSExternalModuleReference/spec'; +export * from './TSInterfaceBody/spec'; +export * from './TSInterfaceHeritage/spec'; +export * from './TSModuleBlock/spec'; +export * from './TSTypeAnnotation/spec'; +export * from './TSTypeParameter/spec'; +export * from './TSTypeParameterDeclaration/spec'; +export * from './TSTypeParameterInstantiation/spec'; +export * from './TemplateElement/spec'; +export * from './VariableDeclarator/spec'; diff --git a/packages/ast-spec/src/statement/BlockStatement/spec.ts b/packages/ast-spec/src/statement/BlockStatement/spec.ts new file mode 100644 index 000000000000..298a962e5161 --- /dev/null +++ b/packages/ast-spec/src/statement/BlockStatement/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Statement } from '../../unions/Statement'; + +export interface BlockStatement extends BaseNode { + type: AST_NODE_TYPES.BlockStatement; + body: Statement[]; +} diff --git a/packages/ast-spec/src/statement/BreakStatement/spec.ts b/packages/ast-spec/src/statement/BreakStatement/spec.ts new file mode 100644 index 000000000000..0441c298d365 --- /dev/null +++ b/packages/ast-spec/src/statement/BreakStatement/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; + +export interface BreakStatement extends BaseNode { + type: AST_NODE_TYPES.BreakStatement; + label: Identifier | null; +} diff --git a/packages/ast-spec/src/statement/ContinueStatement/spec.ts b/packages/ast-spec/src/statement/ContinueStatement/spec.ts new file mode 100644 index 000000000000..70f2373dc217 --- /dev/null +++ b/packages/ast-spec/src/statement/ContinueStatement/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; + +export interface ContinueStatement extends BaseNode { + type: AST_NODE_TYPES.ContinueStatement; + label: Identifier | null; +} diff --git a/packages/ast-spec/src/statement/DebuggerStatement/spec.ts b/packages/ast-spec/src/statement/DebuggerStatement/spec.ts new file mode 100644 index 000000000000..f28b7fc41b72 --- /dev/null +++ b/packages/ast-spec/src/statement/DebuggerStatement/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface DebuggerStatement extends BaseNode { + type: AST_NODE_TYPES.DebuggerStatement; +} diff --git a/packages/ast-spec/src/statement/DoWhileStatement/spec.ts b/packages/ast-spec/src/statement/DoWhileStatement/spec.ts new file mode 100644 index 000000000000..933ce61b2c4c --- /dev/null +++ b/packages/ast-spec/src/statement/DoWhileStatement/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { Statement } from '../../unions/Statement'; + +export interface DoWhileStatement extends BaseNode { + type: AST_NODE_TYPES.DoWhileStatement; + test: Expression; + body: Statement; +} diff --git a/packages/ast-spec/src/statement/ExpressionStatement/spec.ts b/packages/ast-spec/src/statement/ExpressionStatement/spec.ts new file mode 100644 index 000000000000..f5fd336a9604 --- /dev/null +++ b/packages/ast-spec/src/statement/ExpressionStatement/spec.ts @@ -0,0 +1,9 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; + +export interface ExpressionStatement extends BaseNode { + type: AST_NODE_TYPES.ExpressionStatement; + expression: Expression; + directive?: string; +} diff --git a/packages/ast-spec/src/statement/ForInStatement/spec.ts b/packages/ast-spec/src/statement/ForInStatement/spec.ts new file mode 100644 index 000000000000..7abe3b2f5fad --- /dev/null +++ b/packages/ast-spec/src/statement/ForInStatement/spec.ts @@ -0,0 +1,12 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { ForInitialiser } from '../../unions/ForInitialiser'; +import type { Statement } from '../../unions/Statement'; + +export interface ForInStatement extends BaseNode { + type: AST_NODE_TYPES.ForInStatement; + left: ForInitialiser; + right: Expression; + body: Statement; +} diff --git a/packages/ast-spec/src/statement/ForOfStatement/spec.ts b/packages/ast-spec/src/statement/ForOfStatement/spec.ts new file mode 100644 index 000000000000..963261eaaac8 --- /dev/null +++ b/packages/ast-spec/src/statement/ForOfStatement/spec.ts @@ -0,0 +1,13 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { ForInitialiser } from '../../unions/ForInitialiser'; +import type { Statement } from '../../unions/Statement'; + +export interface ForOfStatement extends BaseNode { + type: AST_NODE_TYPES.ForOfStatement; + left: ForInitialiser; + right: Expression; + body: Statement; + await: boolean; +} diff --git a/packages/ast-spec/src/statement/ForStatement/spec.ts b/packages/ast-spec/src/statement/ForStatement/spec.ts new file mode 100644 index 000000000000..1b56756b3a50 --- /dev/null +++ b/packages/ast-spec/src/statement/ForStatement/spec.ts @@ -0,0 +1,13 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { ForInitialiser } from '../../unions/ForInitialiser'; +import type { Statement } from '../../unions/Statement'; + +export interface ForStatement extends BaseNode { + type: AST_NODE_TYPES.ForStatement; + init: Expression | ForInitialiser | null; + test: Expression | null; + update: Expression | null; + body: Statement; +} diff --git a/packages/ast-spec/src/statement/IfStatement/spec.ts b/packages/ast-spec/src/statement/IfStatement/spec.ts new file mode 100644 index 000000000000..f9081923e64a --- /dev/null +++ b/packages/ast-spec/src/statement/IfStatement/spec.ts @@ -0,0 +1,11 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { Statement } from '../../unions/Statement'; + +export interface IfStatement extends BaseNode { + type: AST_NODE_TYPES.IfStatement; + test: Expression; + consequent: Statement; + alternate: Statement | null; +} diff --git a/packages/ast-spec/src/statement/ImportDeclaration/spec.ts b/packages/ast-spec/src/statement/ImportDeclaration/spec.ts new file mode 100644 index 000000000000..eaaad5f53e32 --- /dev/null +++ b/packages/ast-spec/src/statement/ImportDeclaration/spec.ts @@ -0,0 +1,11 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { ImportClause } from '../../unions/ImportClause'; +import type { Literal } from '../../unions/Literal'; + +export interface ImportDeclaration extends BaseNode { + type: AST_NODE_TYPES.ImportDeclaration; + source: Literal; + specifiers: ImportClause[]; + importKind: 'type' | 'value'; +} diff --git a/packages/ast-spec/src/statement/LabeledStatement/spec.ts b/packages/ast-spec/src/statement/LabeledStatement/spec.ts new file mode 100644 index 000000000000..d007008d3a4b --- /dev/null +++ b/packages/ast-spec/src/statement/LabeledStatement/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; +import type { Statement } from '../../unions/Statement'; + +export interface LabeledStatement extends BaseNode { + type: AST_NODE_TYPES.LabeledStatement; + label: Identifier; + body: Statement; +} diff --git a/packages/ast-spec/src/statement/ReturnStatement/spec.ts b/packages/ast-spec/src/statement/ReturnStatement/spec.ts new file mode 100644 index 000000000000..d7758715c8dd --- /dev/null +++ b/packages/ast-spec/src/statement/ReturnStatement/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; + +export interface ReturnStatement extends BaseNode { + type: AST_NODE_TYPES.ReturnStatement; + argument: Expression | null; +} diff --git a/packages/ast-spec/src/statement/SwitchStatement/spec.ts b/packages/ast-spec/src/statement/SwitchStatement/spec.ts new file mode 100644 index 000000000000..9c76f81455c8 --- /dev/null +++ b/packages/ast-spec/src/statement/SwitchStatement/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { SwitchCase } from '../../special/SwitchCase/spec'; +import type { Expression } from '../../unions/Expression'; + +export interface SwitchStatement extends BaseNode { + type: AST_NODE_TYPES.SwitchStatement; + discriminant: Expression; + cases: SwitchCase[]; +} diff --git a/packages/ast-spec/src/statement/TSExportAssignment/spec.ts b/packages/ast-spec/src/statement/TSExportAssignment/spec.ts new file mode 100644 index 000000000000..3792bc5012b1 --- /dev/null +++ b/packages/ast-spec/src/statement/TSExportAssignment/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; + +export interface TSExportAssignment extends BaseNode { + type: AST_NODE_TYPES.TSExportAssignment; + expression: Expression; +} diff --git a/packages/ast-spec/src/statement/ThrowStatement/spec.ts b/packages/ast-spec/src/statement/ThrowStatement/spec.ts new file mode 100644 index 000000000000..ac47bd98778c --- /dev/null +++ b/packages/ast-spec/src/statement/ThrowStatement/spec.ts @@ -0,0 +1,9 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSAsExpression } from '../../expression/TSAsExpression/spec'; +import type { Statement } from '../../unions/Statement'; + +export interface ThrowStatement extends BaseNode { + type: AST_NODE_TYPES.ThrowStatement; + argument: Statement | TSAsExpression | null; +} diff --git a/packages/ast-spec/src/statement/TryStatement/spec.ts b/packages/ast-spec/src/statement/TryStatement/spec.ts new file mode 100644 index 000000000000..0435fbeb2100 --- /dev/null +++ b/packages/ast-spec/src/statement/TryStatement/spec.ts @@ -0,0 +1,11 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { CatchClause } from '../../special/CatchClause/spec'; +import type { BlockStatement } from '../BlockStatement/spec'; + +export interface TryStatement extends BaseNode { + type: AST_NODE_TYPES.TryStatement; + block: BlockStatement; + handler: CatchClause | null; + finalizer: BlockStatement | null; +} diff --git a/packages/ast-spec/src/statement/WhileStatement/spec.ts b/packages/ast-spec/src/statement/WhileStatement/spec.ts new file mode 100644 index 000000000000..1c9492c77140 --- /dev/null +++ b/packages/ast-spec/src/statement/WhileStatement/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { Statement } from '../../unions/Statement'; + +export interface WhileStatement extends BaseNode { + type: AST_NODE_TYPES.WhileStatement; + test: Expression; + body: Statement; +} diff --git a/packages/ast-spec/src/statement/WithStatement/spec.ts b/packages/ast-spec/src/statement/WithStatement/spec.ts new file mode 100644 index 000000000000..c661a5175b9a --- /dev/null +++ b/packages/ast-spec/src/statement/WithStatement/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { Statement } from '../../unions/Statement'; + +export interface WithStatement extends BaseNode { + type: AST_NODE_TYPES.WithStatement; + object: Expression; + body: Statement; +} diff --git a/packages/ast-spec/src/statement/spec.ts b/packages/ast-spec/src/statement/spec.ts new file mode 100644 index 000000000000..d1ce293283e4 --- /dev/null +++ b/packages/ast-spec/src/statement/spec.ts @@ -0,0 +1,19 @@ +export * from './BlockStatement/spec'; +export * from './BreakStatement/spec'; +export * from './ContinueStatement/spec'; +export * from './DebuggerStatement/spec'; +export * from './DoWhileStatement/spec'; +export * from './ExpressionStatement/spec'; +export * from './ForInStatement/spec'; +export * from './ForOfStatement/spec'; +export * from './ForStatement/spec'; +export * from './IfStatement/spec'; +export * from './ImportDeclaration/spec'; +export * from './LabeledStatement/spec'; +export * from './ReturnStatement/spec'; +export * from './SwitchStatement/spec'; +export * from './TSExportAssignment/spec'; +export * from './ThrowStatement/spec'; +export * from './TryStatement/spec'; +export * from './WhileStatement/spec'; +export * from './WithStatement/spec'; diff --git a/packages/ast-spec/src/token/BlockComment/spec.ts b/packages/ast-spec/src/token/BlockComment/spec.ts new file mode 100644 index 000000000000..c2c7db298a4f --- /dev/null +++ b/packages/ast-spec/src/token/BlockComment/spec.ts @@ -0,0 +1,6 @@ +import type { AST_TOKEN_TYPES } from '../../ast-token-types'; +import type { BaseToken } from '../../base/BaseToken'; + +export interface BlockComment extends BaseToken { + type: AST_TOKEN_TYPES.Block; +} diff --git a/packages/ast-spec/src/token/BooleanToken/spec.ts b/packages/ast-spec/src/token/BooleanToken/spec.ts new file mode 100644 index 000000000000..eeace18c8cd9 --- /dev/null +++ b/packages/ast-spec/src/token/BooleanToken/spec.ts @@ -0,0 +1,6 @@ +import type { AST_TOKEN_TYPES } from '../../ast-token-types'; +import type { BaseToken } from '../../base/BaseToken'; + +export interface BooleanToken extends BaseToken { + type: AST_TOKEN_TYPES.Boolean; +} diff --git a/packages/ast-spec/src/token/IdentifierToken/spec.ts b/packages/ast-spec/src/token/IdentifierToken/spec.ts new file mode 100644 index 000000000000..9df6e14c3c99 --- /dev/null +++ b/packages/ast-spec/src/token/IdentifierToken/spec.ts @@ -0,0 +1,6 @@ +import type { AST_TOKEN_TYPES } from '../../ast-token-types'; +import type { BaseToken } from '../../base/BaseToken'; + +export interface IdentifierToken extends BaseToken { + type: AST_TOKEN_TYPES.Identifier; +} diff --git a/packages/ast-spec/src/token/JSXIdentifierToken/spec.ts b/packages/ast-spec/src/token/JSXIdentifierToken/spec.ts new file mode 100644 index 000000000000..858775073735 --- /dev/null +++ b/packages/ast-spec/src/token/JSXIdentifierToken/spec.ts @@ -0,0 +1,6 @@ +import type { AST_TOKEN_TYPES } from '../../ast-token-types'; +import type { BaseToken } from '../../base/BaseToken'; + +export interface JSXIdentifierToken extends BaseToken { + type: AST_TOKEN_TYPES.JSXIdentifier; +} diff --git a/packages/ast-spec/src/token/JSXTextToken/spec.ts b/packages/ast-spec/src/token/JSXTextToken/spec.ts new file mode 100644 index 000000000000..6a8d3aa5d50d --- /dev/null +++ b/packages/ast-spec/src/token/JSXTextToken/spec.ts @@ -0,0 +1,6 @@ +import type { AST_TOKEN_TYPES } from '../../ast-token-types'; +import type { BaseToken } from '../../base/BaseToken'; + +export interface JSXTextToken extends BaseToken { + type: AST_TOKEN_TYPES.JSXText; +} diff --git a/packages/ast-spec/src/token/KeywordToken/spec.ts b/packages/ast-spec/src/token/KeywordToken/spec.ts new file mode 100644 index 000000000000..b7e9c058f692 --- /dev/null +++ b/packages/ast-spec/src/token/KeywordToken/spec.ts @@ -0,0 +1,6 @@ +import type { AST_TOKEN_TYPES } from '../../ast-token-types'; +import type { BaseToken } from '../../base/BaseToken'; + +export interface KeywordToken extends BaseToken { + type: AST_TOKEN_TYPES.Keyword; +} diff --git a/packages/ast-spec/src/token/LineComment/spec.ts b/packages/ast-spec/src/token/LineComment/spec.ts new file mode 100644 index 000000000000..82db26f07442 --- /dev/null +++ b/packages/ast-spec/src/token/LineComment/spec.ts @@ -0,0 +1,6 @@ +import type { AST_TOKEN_TYPES } from '../../ast-token-types'; +import type { BaseToken } from '../../base/BaseToken'; + +export interface LineComment extends BaseToken { + type: AST_TOKEN_TYPES.Line; +} diff --git a/packages/ast-spec/src/token/NullToken/spec.ts b/packages/ast-spec/src/token/NullToken/spec.ts new file mode 100644 index 000000000000..d5ae492de83a --- /dev/null +++ b/packages/ast-spec/src/token/NullToken/spec.ts @@ -0,0 +1,6 @@ +import type { AST_TOKEN_TYPES } from '../../ast-token-types'; +import type { BaseToken } from '../../base/BaseToken'; + +export interface NullToken extends BaseToken { + type: AST_TOKEN_TYPES.Null; +} diff --git a/packages/ast-spec/src/token/NumericToken/spec.ts b/packages/ast-spec/src/token/NumericToken/spec.ts new file mode 100644 index 000000000000..a00fd383df75 --- /dev/null +++ b/packages/ast-spec/src/token/NumericToken/spec.ts @@ -0,0 +1,6 @@ +import type { AST_TOKEN_TYPES } from '../../ast-token-types'; +import type { BaseToken } from '../../base/BaseToken'; + +export interface NumericToken extends BaseToken { + type: AST_TOKEN_TYPES.Numeric; +} diff --git a/packages/ast-spec/src/token/PunctuatorToken/spec.ts b/packages/ast-spec/src/token/PunctuatorToken/spec.ts new file mode 100644 index 000000000000..39b9507348c2 --- /dev/null +++ b/packages/ast-spec/src/token/PunctuatorToken/spec.ts @@ -0,0 +1,6 @@ +import type { AST_TOKEN_TYPES } from '../../ast-token-types'; +import type { BaseToken } from '../../base/BaseToken'; + +export interface PunctuatorToken extends BaseToken { + type: AST_TOKEN_TYPES.Punctuator; +} diff --git a/packages/ast-spec/src/token/RegularExpressionToken/spec.ts b/packages/ast-spec/src/token/RegularExpressionToken/spec.ts new file mode 100644 index 000000000000..7b0bb09d5262 --- /dev/null +++ b/packages/ast-spec/src/token/RegularExpressionToken/spec.ts @@ -0,0 +1,10 @@ +import type { AST_TOKEN_TYPES } from '../../ast-token-types'; +import type { BaseToken } from '../../base/BaseToken'; + +export interface RegularExpressionToken extends BaseToken { + type: AST_TOKEN_TYPES.RegularExpression; + regex: { + pattern: string; + flags: string; + }; +} diff --git a/packages/ast-spec/src/token/StringToken/spec.ts b/packages/ast-spec/src/token/StringToken/spec.ts new file mode 100644 index 000000000000..6b6535c6208d --- /dev/null +++ b/packages/ast-spec/src/token/StringToken/spec.ts @@ -0,0 +1,6 @@ +import type { AST_TOKEN_TYPES } from '../../ast-token-types'; +import type { BaseToken } from '../../base/BaseToken'; + +export interface StringToken extends BaseToken { + type: AST_TOKEN_TYPES.String; +} diff --git a/packages/ast-spec/src/token/TSAbstractKeyword/spec.ts b/packages/ast-spec/src/token/TSAbstractKeyword/spec.ts new file mode 100644 index 000000000000..d15a55443c57 --- /dev/null +++ b/packages/ast-spec/src/token/TSAbstractKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSAbstractKeyword extends BaseNode { + type: AST_NODE_TYPES.TSAbstractKeyword; +} diff --git a/packages/ast-spec/src/token/TSAsyncKeyword/spec.ts b/packages/ast-spec/src/token/TSAsyncKeyword/spec.ts new file mode 100644 index 000000000000..26baddf7ad64 --- /dev/null +++ b/packages/ast-spec/src/token/TSAsyncKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSAsyncKeyword extends BaseNode { + type: AST_NODE_TYPES.TSAsyncKeyword; +} diff --git a/packages/ast-spec/src/token/TSDeclareKeyword/spec.ts b/packages/ast-spec/src/token/TSDeclareKeyword/spec.ts new file mode 100644 index 000000000000..8b6e6606b3e8 --- /dev/null +++ b/packages/ast-spec/src/token/TSDeclareKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSDeclareKeyword extends BaseNode { + type: AST_NODE_TYPES.TSDeclareKeyword; +} diff --git a/packages/ast-spec/src/token/TSExportKeyword/spec.ts b/packages/ast-spec/src/token/TSExportKeyword/spec.ts new file mode 100644 index 000000000000..016664d11b03 --- /dev/null +++ b/packages/ast-spec/src/token/TSExportKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSExportKeyword extends BaseNode { + type: AST_NODE_TYPES.TSExportKeyword; +} diff --git a/packages/ast-spec/src/token/TSPrivateKeyword/spec.ts b/packages/ast-spec/src/token/TSPrivateKeyword/spec.ts new file mode 100644 index 000000000000..ae57db0a066c --- /dev/null +++ b/packages/ast-spec/src/token/TSPrivateKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSPrivateKeyword extends BaseNode { + type: AST_NODE_TYPES.TSPrivateKeyword; +} diff --git a/packages/ast-spec/src/token/TSProtectedKeyword/spec.ts b/packages/ast-spec/src/token/TSProtectedKeyword/spec.ts new file mode 100644 index 000000000000..815b28a1c2c1 --- /dev/null +++ b/packages/ast-spec/src/token/TSProtectedKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSProtectedKeyword extends BaseNode { + type: AST_NODE_TYPES.TSProtectedKeyword; +} diff --git a/packages/ast-spec/src/token/TSPublicKeyword/spec.ts b/packages/ast-spec/src/token/TSPublicKeyword/spec.ts new file mode 100644 index 000000000000..3409fc6d689a --- /dev/null +++ b/packages/ast-spec/src/token/TSPublicKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSPublicKeyword extends BaseNode { + type: AST_NODE_TYPES.TSPublicKeyword; +} diff --git a/packages/ast-spec/src/token/TSReadonlyKeyword/spec.ts b/packages/ast-spec/src/token/TSReadonlyKeyword/spec.ts new file mode 100644 index 000000000000..462849972785 --- /dev/null +++ b/packages/ast-spec/src/token/TSReadonlyKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSReadonlyKeyword extends BaseNode { + type: AST_NODE_TYPES.TSReadonlyKeyword; +} diff --git a/packages/ast-spec/src/token/TSStaticKeyword/spec.ts b/packages/ast-spec/src/token/TSStaticKeyword/spec.ts new file mode 100644 index 000000000000..1c2417eeb589 --- /dev/null +++ b/packages/ast-spec/src/token/TSStaticKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSStaticKeyword extends BaseNode { + type: AST_NODE_TYPES.TSStaticKeyword; +} diff --git a/packages/ast-spec/src/token/TemplateToken/spec.ts b/packages/ast-spec/src/token/TemplateToken/spec.ts new file mode 100644 index 000000000000..da64ef0b6e98 --- /dev/null +++ b/packages/ast-spec/src/token/TemplateToken/spec.ts @@ -0,0 +1,6 @@ +import type { AST_TOKEN_TYPES } from '../../ast-token-types'; +import type { BaseToken } from '../../base/BaseToken'; + +export interface TemplateToken extends BaseToken { + type: AST_TOKEN_TYPES.Template; +} diff --git a/packages/ast-spec/src/token/spec.ts b/packages/ast-spec/src/token/spec.ts new file mode 100644 index 000000000000..45df05189eb2 --- /dev/null +++ b/packages/ast-spec/src/token/spec.ts @@ -0,0 +1,22 @@ +export * from './BlockComment/spec'; +export * from './BooleanToken/spec'; +export * from './IdentifierToken/spec'; +export * from './JSXIdentifierToken/spec'; +export * from './JSXTextToken/spec'; +export * from './KeywordToken/spec'; +export * from './LineComment/spec'; +export * from './NullToken/spec'; +export * from './NumericToken/spec'; +export * from './PunctuatorToken/spec'; +export * from './RegularExpressionToken/spec'; +export * from './StringToken/spec'; +export * from './TSAbstractKeyword/spec'; +export * from './TSAsyncKeyword/spec'; +export * from './TSDeclareKeyword/spec'; +export * from './TSExportKeyword/spec'; +export * from './TSPrivateKeyword/spec'; +export * from './TSProtectedKeyword/spec'; +export * from './TSPublicKeyword/spec'; +export * from './TSReadonlyKeyword/spec'; +export * from './TSStaticKeyword/spec'; +export * from './TemplateToken/spec'; diff --git a/packages/ast-spec/src/type/TSAnyKeyword/spec.ts b/packages/ast-spec/src/type/TSAnyKeyword/spec.ts new file mode 100644 index 000000000000..a9e2ba977f1d --- /dev/null +++ b/packages/ast-spec/src/type/TSAnyKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSAnyKeyword extends BaseNode { + type: AST_NODE_TYPES.TSAnyKeyword; +} diff --git a/packages/ast-spec/src/type/TSArrayType/spec.ts b/packages/ast-spec/src/type/TSArrayType/spec.ts new file mode 100644 index 000000000000..f7aa4f16a596 --- /dev/null +++ b/packages/ast-spec/src/type/TSArrayType/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSArrayType extends BaseNode { + type: AST_NODE_TYPES.TSArrayType; + elementType: TypeNode; +} diff --git a/packages/ast-spec/src/type/TSBigIntKeyword/spec.ts b/packages/ast-spec/src/type/TSBigIntKeyword/spec.ts new file mode 100644 index 000000000000..fc18a9519dee --- /dev/null +++ b/packages/ast-spec/src/type/TSBigIntKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSBigIntKeyword extends BaseNode { + type: AST_NODE_TYPES.TSBigIntKeyword; +} diff --git a/packages/ast-spec/src/type/TSBooleanKeyword/spec.ts b/packages/ast-spec/src/type/TSBooleanKeyword/spec.ts new file mode 100644 index 000000000000..89438151de1f --- /dev/null +++ b/packages/ast-spec/src/type/TSBooleanKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSBooleanKeyword extends BaseNode { + type: AST_NODE_TYPES.TSBooleanKeyword; +} diff --git a/packages/ast-spec/src/type/TSConditionalType/spec.ts b/packages/ast-spec/src/type/TSConditionalType/spec.ts new file mode 100644 index 000000000000..979fcb3e6026 --- /dev/null +++ b/packages/ast-spec/src/type/TSConditionalType/spec.ts @@ -0,0 +1,11 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSConditionalType extends BaseNode { + type: AST_NODE_TYPES.TSConditionalType; + checkType: TypeNode; + extendsType: TypeNode; + trueType: TypeNode; + falseType: TypeNode; +} diff --git a/packages/ast-spec/src/type/TSConstructorType/spec.ts b/packages/ast-spec/src/type/TSConstructorType/spec.ts new file mode 100644 index 000000000000..08e19757d14a --- /dev/null +++ b/packages/ast-spec/src/type/TSConstructorType/spec.ts @@ -0,0 +1,7 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { TSFunctionSignatureBase } from '../../base/TSFunctionSignatureBase'; + +export interface TSConstructorType extends TSFunctionSignatureBase { + type: AST_NODE_TYPES.TSConstructorType; + abstract: boolean; +} diff --git a/packages/ast-spec/src/type/TSFunctionType/spec.ts b/packages/ast-spec/src/type/TSFunctionType/spec.ts new file mode 100644 index 000000000000..4388b097efd5 --- /dev/null +++ b/packages/ast-spec/src/type/TSFunctionType/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { TSFunctionSignatureBase } from '../../base/TSFunctionSignatureBase'; + +export interface TSFunctionType extends TSFunctionSignatureBase { + type: AST_NODE_TYPES.TSFunctionType; +} diff --git a/packages/ast-spec/src/type/TSImportType/spec.ts b/packages/ast-spec/src/type/TSImportType/spec.ts new file mode 100644 index 000000000000..b2eea1a78e01 --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/spec.ts @@ -0,0 +1,13 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSTypeParameterInstantiation } from '../../special/TSTypeParameterInstantiation/spec'; +import type { EntityName } from '../../unions/EntityName'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSImportType extends BaseNode { + type: AST_NODE_TYPES.TSImportType; + isTypeOf: boolean; + parameter: TypeNode; + qualifier: EntityName | null; + typeParameters: TSTypeParameterInstantiation | null; +} diff --git a/packages/ast-spec/src/type/TSIndexedAccessType/spec.ts b/packages/ast-spec/src/type/TSIndexedAccessType/spec.ts new file mode 100644 index 000000000000..86a22e22a16e --- /dev/null +++ b/packages/ast-spec/src/type/TSIndexedAccessType/spec.ts @@ -0,0 +1,9 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSIndexedAccessType extends BaseNode { + type: AST_NODE_TYPES.TSIndexedAccessType; + objectType: TypeNode; + indexType: TypeNode; +} diff --git a/packages/ast-spec/src/type/TSInferType/spec.ts b/packages/ast-spec/src/type/TSInferType/spec.ts new file mode 100644 index 000000000000..11cdacb25d20 --- /dev/null +++ b/packages/ast-spec/src/type/TSInferType/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSTypeParameter } from '../../special/TSTypeParameter/spec'; + +export interface TSInferType extends BaseNode { + type: AST_NODE_TYPES.TSInferType; + typeParameter: TSTypeParameter; +} diff --git a/packages/ast-spec/src/type/TSIntersectionType/spec.ts b/packages/ast-spec/src/type/TSIntersectionType/spec.ts new file mode 100644 index 000000000000..b84834143a0e --- /dev/null +++ b/packages/ast-spec/src/type/TSIntersectionType/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSIntersectionType extends BaseNode { + type: AST_NODE_TYPES.TSIntersectionType; + types: TypeNode[]; +} diff --git a/packages/ast-spec/src/type/TSIntrinsicType/spec.ts b/packages/ast-spec/src/type/TSIntrinsicType/spec.ts new file mode 100644 index 000000000000..b7158c2803c0 --- /dev/null +++ b/packages/ast-spec/src/type/TSIntrinsicType/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSIntrinsicKeyword extends BaseNode { + type: AST_NODE_TYPES.TSIntrinsicKeyword; +} diff --git a/packages/ast-spec/src/type/TSLiteralType/spec.ts b/packages/ast-spec/src/type/TSLiteralType/spec.ts new file mode 100644 index 000000000000..39f6ae0d2961 --- /dev/null +++ b/packages/ast-spec/src/type/TSLiteralType/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { UnaryExpression } from '../../expression/UnaryExpression/spec'; +import type { UpdateExpression } from '../../expression/UpdateExpression/spec'; +import type { LiteralExpression } from '../../unions/LiteralExpression'; + +export interface TSLiteralType extends BaseNode { + type: AST_NODE_TYPES.TSLiteralType; + literal: LiteralExpression | UnaryExpression | UpdateExpression; +} diff --git a/packages/ast-spec/src/type/TSMappedType/spec.ts b/packages/ast-spec/src/type/TSMappedType/spec.ts new file mode 100644 index 000000000000..db5abd4063a1 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/spec.ts @@ -0,0 +1,13 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSTypeParameter } from '../../special/TSTypeParameter/spec'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSMappedType extends BaseNode { + type: AST_NODE_TYPES.TSMappedType; + typeParameter: TSTypeParameter; + readonly?: boolean | '-' | '+'; + optional?: boolean | '-' | '+'; + typeAnnotation?: TypeNode; + nameType: TypeNode | null; +} diff --git a/packages/ast-spec/src/type/TSNamedTupleMember/spec.ts b/packages/ast-spec/src/type/TSNamedTupleMember/spec.ts new file mode 100644 index 000000000000..540d8bf19db5 --- /dev/null +++ b/packages/ast-spec/src/type/TSNamedTupleMember/spec.ts @@ -0,0 +1,11 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSNamedTupleMember extends BaseNode { + type: AST_NODE_TYPES.TSNamedTupleMember; + elementType: TypeNode; + label: Identifier; + optional: boolean; +} diff --git a/packages/ast-spec/src/type/TSNeverKeyword/spec.ts b/packages/ast-spec/src/type/TSNeverKeyword/spec.ts new file mode 100644 index 000000000000..59fe839e3473 --- /dev/null +++ b/packages/ast-spec/src/type/TSNeverKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSNeverKeyword extends BaseNode { + type: AST_NODE_TYPES.TSNeverKeyword; +} diff --git a/packages/ast-spec/src/type/TSNullKeyword/spec.ts b/packages/ast-spec/src/type/TSNullKeyword/spec.ts new file mode 100644 index 000000000000..254d5cc592d5 --- /dev/null +++ b/packages/ast-spec/src/type/TSNullKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSNullKeyword extends BaseNode { + type: AST_NODE_TYPES.TSNullKeyword; +} diff --git a/packages/ast-spec/src/type/TSNumberKeyword/spec.ts b/packages/ast-spec/src/type/TSNumberKeyword/spec.ts new file mode 100644 index 000000000000..768742a425dc --- /dev/null +++ b/packages/ast-spec/src/type/TSNumberKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSNumberKeyword extends BaseNode { + type: AST_NODE_TYPES.TSNumberKeyword; +} diff --git a/packages/ast-spec/src/type/TSObjectKeyword/spec.ts b/packages/ast-spec/src/type/TSObjectKeyword/spec.ts new file mode 100644 index 000000000000..3472bc9191ff --- /dev/null +++ b/packages/ast-spec/src/type/TSObjectKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSObjectKeyword extends BaseNode { + type: AST_NODE_TYPES.TSObjectKeyword; +} diff --git a/packages/ast-spec/src/type/TSOptionalType/spec.ts b/packages/ast-spec/src/type/TSOptionalType/spec.ts new file mode 100644 index 000000000000..9cdb0f636d32 --- /dev/null +++ b/packages/ast-spec/src/type/TSOptionalType/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSOptionalType extends BaseNode { + type: AST_NODE_TYPES.TSOptionalType; + typeAnnotation: TypeNode; +} diff --git a/packages/ast-spec/src/type/TSParenthesizedType/spec.ts b/packages/ast-spec/src/type/TSParenthesizedType/spec.ts new file mode 100644 index 000000000000..2d20d5d2f2bc --- /dev/null +++ b/packages/ast-spec/src/type/TSParenthesizedType/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSParenthesizedType extends BaseNode { + type: AST_NODE_TYPES.TSParenthesizedType; + typeAnnotation: TypeNode; +} diff --git a/packages/ast-spec/src/type/TSQualifiedName/spec.ts b/packages/ast-spec/src/type/TSQualifiedName/spec.ts new file mode 100644 index 000000000000..cdd6feeee0ef --- /dev/null +++ b/packages/ast-spec/src/type/TSQualifiedName/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; +import type { EntityName } from '../../unions/EntityName'; + +export interface TSQualifiedName extends BaseNode { + type: AST_NODE_TYPES.TSQualifiedName; + left: EntityName; + right: Identifier; +} diff --git a/packages/ast-spec/src/type/TSRestType/spec.ts b/packages/ast-spec/src/type/TSRestType/spec.ts new file mode 100644 index 000000000000..f1b4f2ecfa85 --- /dev/null +++ b/packages/ast-spec/src/type/TSRestType/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSRestType extends BaseNode { + type: AST_NODE_TYPES.TSRestType; + typeAnnotation: TypeNode; +} diff --git a/packages/ast-spec/src/type/TSStringKeyword/spec.ts b/packages/ast-spec/src/type/TSStringKeyword/spec.ts new file mode 100644 index 000000000000..35721dd44137 --- /dev/null +++ b/packages/ast-spec/src/type/TSStringKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSStringKeyword extends BaseNode { + type: AST_NODE_TYPES.TSStringKeyword; +} diff --git a/packages/ast-spec/src/type/TSSymbolKeyword/spec.ts b/packages/ast-spec/src/type/TSSymbolKeyword/spec.ts new file mode 100644 index 000000000000..6b8b949dd0b8 --- /dev/null +++ b/packages/ast-spec/src/type/TSSymbolKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSSymbolKeyword extends BaseNode { + type: AST_NODE_TYPES.TSSymbolKeyword; +} diff --git a/packages/ast-spec/src/type/TSTemplateLiteralType/spec.ts b/packages/ast-spec/src/type/TSTemplateLiteralType/spec.ts new file mode 100644 index 000000000000..c2e8783da873 --- /dev/null +++ b/packages/ast-spec/src/type/TSTemplateLiteralType/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TemplateElement } from '../../special/TemplateElement/spec'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSTemplateLiteralType extends BaseNode { + type: AST_NODE_TYPES.TSTemplateLiteralType; + quasis: TemplateElement[]; + types: TypeNode[]; +} diff --git a/packages/ast-spec/src/type/TSThisType/spec.ts b/packages/ast-spec/src/type/TSThisType/spec.ts new file mode 100644 index 000000000000..319e82460f67 --- /dev/null +++ b/packages/ast-spec/src/type/TSThisType/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSThisType extends BaseNode { + type: AST_NODE_TYPES.TSThisType; +} diff --git a/packages/ast-spec/src/type/TSTupleType/spec.ts b/packages/ast-spec/src/type/TSTupleType/spec.ts new file mode 100644 index 000000000000..641a0c15b4c6 --- /dev/null +++ b/packages/ast-spec/src/type/TSTupleType/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSTupleType extends BaseNode { + type: AST_NODE_TYPES.TSTupleType; + elementTypes: TypeNode[]; +} diff --git a/packages/ast-spec/src/type/TSTypeLiteral/spec.ts b/packages/ast-spec/src/type/TSTypeLiteral/spec.ts new file mode 100644 index 000000000000..243179d23d9f --- /dev/null +++ b/packages/ast-spec/src/type/TSTypeLiteral/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeElement } from '../../unions/TypeElement'; + +export interface TSTypeLiteral extends BaseNode { + type: AST_NODE_TYPES.TSTypeLiteral; + members: TypeElement[]; +} diff --git a/packages/ast-spec/src/type/TSTypeOperator/spec.ts b/packages/ast-spec/src/type/TSTypeOperator/spec.ts new file mode 100644 index 000000000000..c83b8721eed9 --- /dev/null +++ b/packages/ast-spec/src/type/TSTypeOperator/spec.ts @@ -0,0 +1,9 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSTypeOperator extends BaseNode { + type: AST_NODE_TYPES.TSTypeOperator; + operator: 'keyof' | 'readonly' | 'unique'; + typeAnnotation?: TypeNode; +} diff --git a/packages/ast-spec/src/type/TSTypePredicate/spec.ts b/packages/ast-spec/src/type/TSTypePredicate/spec.ts new file mode 100644 index 000000000000..cd34a31bcaf0 --- /dev/null +++ b/packages/ast-spec/src/type/TSTypePredicate/spec.ts @@ -0,0 +1,12 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; +import type { TSTypeAnnotation } from '../../special/TSTypeAnnotation/spec'; +import type { TSThisType } from '../TSThisType/spec'; + +export interface TSTypePredicate extends BaseNode { + type: AST_NODE_TYPES.TSTypePredicate; + asserts: boolean; + parameterName: Identifier | TSThisType; + typeAnnotation: TSTypeAnnotation | null; +} diff --git a/packages/ast-spec/src/type/TSTypeQuery/spec.ts b/packages/ast-spec/src/type/TSTypeQuery/spec.ts new file mode 100644 index 000000000000..bf1cd3e192df --- /dev/null +++ b/packages/ast-spec/src/type/TSTypeQuery/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { EntityName } from '../../unions/EntityName'; + +export interface TSTypeQuery extends BaseNode { + type: AST_NODE_TYPES.TSTypeQuery; + exprName: EntityName; +} diff --git a/packages/ast-spec/src/type/TSTypeReference/spec.ts b/packages/ast-spec/src/type/TSTypeReference/spec.ts new file mode 100644 index 000000000000..9d88fe7f6b4f --- /dev/null +++ b/packages/ast-spec/src/type/TSTypeReference/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TSTypeParameterInstantiation } from '../../special/TSTypeParameterInstantiation/spec'; +import type { EntityName } from '../../unions/EntityName'; + +export interface TSTypeReference extends BaseNode { + type: AST_NODE_TYPES.TSTypeReference; + typeName: EntityName; + typeParameters?: TSTypeParameterInstantiation; +} diff --git a/packages/ast-spec/src/type/TSUndefinedKeyword/spec.ts b/packages/ast-spec/src/type/TSUndefinedKeyword/spec.ts new file mode 100644 index 000000000000..0aa062c84212 --- /dev/null +++ b/packages/ast-spec/src/type/TSUndefinedKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSUndefinedKeyword extends BaseNode { + type: AST_NODE_TYPES.TSUndefinedKeyword; +} diff --git a/packages/ast-spec/src/type/TSUnionType/spec.ts b/packages/ast-spec/src/type/TSUnionType/spec.ts new file mode 100644 index 000000000000..a286f796a23d --- /dev/null +++ b/packages/ast-spec/src/type/TSUnionType/spec.ts @@ -0,0 +1,8 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSUnionType extends BaseNode { + type: AST_NODE_TYPES.TSUnionType; + types: TypeNode[]; +} diff --git a/packages/ast-spec/src/type/TSUnknownKeyword/spec.ts b/packages/ast-spec/src/type/TSUnknownKeyword/spec.ts new file mode 100644 index 000000000000..c8c1f9340c6e --- /dev/null +++ b/packages/ast-spec/src/type/TSUnknownKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSUnknownKeyword extends BaseNode { + type: AST_NODE_TYPES.TSUnknownKeyword; +} diff --git a/packages/ast-spec/src/type/TSVoidKeyword/spec.ts b/packages/ast-spec/src/type/TSVoidKeyword/spec.ts new file mode 100644 index 000000000000..abf0c14c5ab3 --- /dev/null +++ b/packages/ast-spec/src/type/TSVoidKeyword/spec.ts @@ -0,0 +1,6 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface TSVoidKeyword extends BaseNode { + type: AST_NODE_TYPES.TSVoidKeyword; +} diff --git a/packages/ast-spec/src/type/spec.ts b/packages/ast-spec/src/type/spec.ts new file mode 100644 index 000000000000..bbbea76cbd8e --- /dev/null +++ b/packages/ast-spec/src/type/spec.ts @@ -0,0 +1,36 @@ +export * from './TSAnyKeyword/spec'; +export * from './TSArrayType/spec'; +export * from './TSBigIntKeyword/spec'; +export * from './TSBooleanKeyword/spec'; +export * from './TSConditionalType/spec'; +export * from './TSConstructorType/spec'; +export * from './TSFunctionType/spec'; +export * from './TSImportType/spec'; +export * from './TSIndexedAccessType/spec'; +export * from './TSInferType/spec'; +export * from './TSIntersectionType/spec'; +export * from './TSLiteralType/spec'; +export * from './TSMappedType/spec'; +export * from './TSNamedTupleMember/spec'; +export * from './TSNeverKeyword/spec'; +export * from './TSNullKeyword/spec'; +export * from './TSNumberKeyword/spec'; +export * from './TSObjectKeyword/spec'; +export * from './TSOptionalType/spec'; +export * from './TSParenthesizedType/spec'; +export * from './TSQualifiedName/spec'; +export * from './TSRestType/spec'; +export * from './TSStringKeyword/spec'; +export * from './TSSymbolKeyword/spec'; +export * from './TSTemplateLiteralType/spec'; +export * from './TSThisType/spec'; +export * from './TSTupleType/spec'; +export * from './TSTypeLiteral/spec'; +export * from './TSTypeOperator/spec'; +export * from './TSTypePredicate/spec'; +export * from './TSTypeQuery/spec'; +export * from './TSTypeReference/spec'; +export * from './TSUndefinedKeyword/spec'; +export * from './TSUnionType/spec'; +export * from './TSUnknownKeyword/spec'; +export * from './TSVoidKeyword/spec'; diff --git a/packages/ast-spec/src/unions/BindingName.ts b/packages/ast-spec/src/unions/BindingName.ts new file mode 100644 index 000000000000..2da273d80476 --- /dev/null +++ b/packages/ast-spec/src/unions/BindingName.ts @@ -0,0 +1,4 @@ +import type { Identifier } from '../expression/Identifier/spec'; +import type { BindingPattern } from './BindingPattern'; + +export type BindingName = BindingPattern | Identifier; diff --git a/packages/ast-spec/src/unions/BindingPattern.ts b/packages/ast-spec/src/unions/BindingPattern.ts new file mode 100644 index 000000000000..ef39d0af1126 --- /dev/null +++ b/packages/ast-spec/src/unions/BindingPattern.ts @@ -0,0 +1,4 @@ +import type { ArrayPattern } from '../parameter/ArrayPattern/spec'; +import type { ObjectPattern } from '../parameter/ObjectPattern/spec'; + +export type BindingPattern = ArrayPattern | ObjectPattern; diff --git a/packages/ast-spec/src/unions/CallExpressionArgument.ts b/packages/ast-spec/src/unions/CallExpressionArgument.ts new file mode 100644 index 000000000000..42a419b4b25b --- /dev/null +++ b/packages/ast-spec/src/unions/CallExpressionArgument.ts @@ -0,0 +1,4 @@ +import type { SpreadElement } from '../element/SpreadElement/spec'; +import type { Expression } from './Expression'; + +export type CallExpressionArgument = Expression | SpreadElement; diff --git a/packages/ast-spec/src/unions/ChainElement.ts b/packages/ast-spec/src/unions/ChainElement.ts new file mode 100644 index 000000000000..fccde99ed8c6 --- /dev/null +++ b/packages/ast-spec/src/unions/ChainElement.ts @@ -0,0 +1,8 @@ +import type { CallExpression } from '../expression/CallExpression/spec'; +import type { MemberExpression } from '../expression/MemberExpression/spec'; +import type { TSNonNullExpression } from '../expression/TSNonNullExpression/spec'; + +export type ChainElement = + | CallExpression + | MemberExpression + | TSNonNullExpression; diff --git a/packages/ast-spec/src/unions/ClassElement.ts b/packages/ast-spec/src/unions/ClassElement.ts new file mode 100644 index 000000000000..a4d986d09c73 --- /dev/null +++ b/packages/ast-spec/src/unions/ClassElement.ts @@ -0,0 +1,12 @@ +import type { ClassProperty } from '../element/ClassProperty/spec'; +import type { MethodDefinition } from '../element/MethodDefinition/spec'; +import type { TSAbstractClassProperty } from '../element/TSAbstractClassProperty/spec'; +import type { TSAbstractMethodDefinition } from '../element/TSAbstractMethodDefinition/spec'; +import type { TSIndexSignature } from '../element/TSIndexSignature/spec'; + +export type ClassElement = + | ClassProperty + | MethodDefinition + | TSAbstractClassProperty + | TSAbstractMethodDefinition + | TSIndexSignature; diff --git a/packages/ast-spec/src/unions/Comment.ts b/packages/ast-spec/src/unions/Comment.ts new file mode 100644 index 000000000000..d5cdca042476 --- /dev/null +++ b/packages/ast-spec/src/unions/Comment.ts @@ -0,0 +1,4 @@ +import type { BlockComment } from '../token/BlockComment/spec'; +import type { LineComment } from '../token/LineComment/spec'; + +export type Comment = BlockComment | LineComment; diff --git a/packages/ast-spec/src/unions/DeclarationStatement.ts b/packages/ast-spec/src/unions/DeclarationStatement.ts new file mode 100644 index 000000000000..be0637254ae7 --- /dev/null +++ b/packages/ast-spec/src/unions/DeclarationStatement.ts @@ -0,0 +1,29 @@ +import type { ClassDeclaration } from '../declaration/ClassDeclaration/spec'; +import type { ExportAllDeclaration } from '../declaration/ExportAllDeclaration/spec'; +import type { ExportDefaultDeclaration } from '../declaration/ExportDefaultDeclaration/spec'; +import type { ExportNamedDeclaration } from '../declaration/ExportNamedDeclaration/spec'; +import type { FunctionDeclaration } from '../declaration/FunctionDeclaration/spec'; +import type { TSDeclareFunction } from '../declaration/TSDeclareFunction/spec'; +import type { TSEnumDeclaration } from '../declaration/TSEnumDeclaration/spec'; +import type { TSImportEqualsDeclaration } from '../declaration/TSImportEqualsDeclaration/spec'; +import type { TSInterfaceDeclaration } from '../declaration/TSInterfaceDeclaration/spec'; +import type { TSModuleDeclaration } from '../declaration/TSModuleDeclaration/spec'; +import type { TSNamespaceExportDeclaration } from '../declaration/TSNamespaceExportDeclaration/spec'; +import type { TSTypeAliasDeclaration } from '../declaration/TSTypeAliasDeclaration/spec'; +import type { ClassExpression } from '../expression/ClassExpression/spec'; + +// TODO - breaking change remove this +export type DeclarationStatement = + | ClassDeclaration + | ClassExpression + | ExportAllDeclaration + | ExportDefaultDeclaration + | ExportNamedDeclaration + | FunctionDeclaration + | TSDeclareFunction + | TSEnumDeclaration + | TSImportEqualsDeclaration + | TSInterfaceDeclaration + | TSModuleDeclaration + | TSNamespaceExportDeclaration + | TSTypeAliasDeclaration; diff --git a/packages/ast-spec/src/unions/DestructuringPattern.ts b/packages/ast-spec/src/unions/DestructuringPattern.ts new file mode 100644 index 000000000000..40d07009651c --- /dev/null +++ b/packages/ast-spec/src/unions/DestructuringPattern.ts @@ -0,0 +1,14 @@ +import type { Identifier } from '../expression/Identifier/spec'; +import type { MemberExpression } from '../expression/MemberExpression/spec'; +import type { ArrayPattern } from '../parameter/ArrayPattern/spec'; +import type { AssignmentPattern } from '../parameter/AssignmentPattern/spec'; +import type { ObjectPattern } from '../parameter/ObjectPattern/spec'; +import type { RestElement } from '../parameter/RestElement/spec'; + +export type DestructuringPattern = + | ArrayPattern + | AssignmentPattern + | Identifier + | MemberExpression + | ObjectPattern + | RestElement; diff --git a/packages/ast-spec/src/unions/EntityName.ts b/packages/ast-spec/src/unions/EntityName.ts new file mode 100644 index 000000000000..82f7b1c9b0ca --- /dev/null +++ b/packages/ast-spec/src/unions/EntityName.ts @@ -0,0 +1,4 @@ +import type { Identifier } from '../expression/Identifier/spec'; +import type { TSQualifiedName } from '../type/TSQualifiedName/spec'; + +export type EntityName = Identifier | TSQualifiedName; diff --git a/packages/ast-spec/src/unions/ExportDeclaration.ts b/packages/ast-spec/src/unions/ExportDeclaration.ts new file mode 100644 index 000000000000..1ae9d9ddb9f8 --- /dev/null +++ b/packages/ast-spec/src/unions/ExportDeclaration.ts @@ -0,0 +1,20 @@ +import type { ClassDeclaration } from '../declaration/ClassDeclaration/spec'; +import type { FunctionDeclaration } from '../declaration/FunctionDeclaration/spec'; +import type { TSDeclareFunction } from '../declaration/TSDeclareFunction/spec'; +import type { TSEnumDeclaration } from '../declaration/TSEnumDeclaration/spec'; +import type { TSInterfaceDeclaration } from '../declaration/TSInterfaceDeclaration/spec'; +import type { TSModuleDeclaration } from '../declaration/TSModuleDeclaration/spec'; +import type { TSTypeAliasDeclaration } from '../declaration/TSTypeAliasDeclaration/spec'; +import type { VariableDeclaration } from '../declaration/VariableDeclaration/spec'; +import type { ClassExpression } from '../expression/ClassExpression/spec'; + +export type ExportDeclaration = + | ClassDeclaration + | ClassExpression + | FunctionDeclaration + | TSDeclareFunction + | TSEnumDeclaration + | TSInterfaceDeclaration + | TSModuleDeclaration + | TSTypeAliasDeclaration + | VariableDeclaration; diff --git a/packages/ast-spec/src/unions/Expression.ts b/packages/ast-spec/src/unions/Expression.ts new file mode 100644 index 000000000000..fd1a14b114e2 --- /dev/null +++ b/packages/ast-spec/src/unions/Expression.ts @@ -0,0 +1,78 @@ +import type { ArrayExpression } from '../expression/ArrayExpression/spec'; +import type { ArrowFunctionExpression } from '../expression/ArrowFunctionExpression/spec'; +import type { AssignmentExpression } from '../expression/AssignmentExpression/spec'; +import type { AwaitExpression } from '../expression/AwaitExpression/spec'; +import type { BinaryExpression } from '../expression/BinaryExpression/spec'; +import type { CallExpression } from '../expression/CallExpression/spec'; +import type { ChainExpression } from '../expression/ChainExpression/spec'; +import type { ClassExpression } from '../expression/ClassExpression/spec'; +import type { ConditionalExpression } from '../expression/ConditionalExpression/spec'; +import type { FunctionExpression } from '../expression/FunctionExpression/spec'; +import type { Identifier } from '../expression/Identifier/spec'; +import type { ImportExpression } from '../expression/ImportExpression/spec'; +import type { JSXElement } from '../expression/JSXElement/spec'; +import type { JSXFragment } from '../expression/JSXFragment/spec'; +import type { LogicalExpression } from '../expression/LogicalExpression/spec'; +import type { MemberExpression } from '../expression/MemberExpression/spec'; +import type { MetaProperty } from '../expression/MetaProperty/spec'; +import type { NewExpression } from '../expression/NewExpression/spec'; +import type { ObjectExpression } from '../expression/ObjectExpression/spec'; +import type { SequenceExpression } from '../expression/SequenceExpression/spec'; +import type { Super } from '../expression/Super/spec'; +import type { TaggedTemplateExpression } from '../expression/TaggedTemplateExpression/spec'; +import type { TemplateLiteral } from '../expression/TemplateLiteral/spec'; +import type { ThisExpression } from '../expression/ThisExpression/spec'; +import type { TSAsExpression } from '../expression/TSAsExpression/spec'; +import type { TSNonNullExpression } from '../expression/TSNonNullExpression/spec'; +import type { TSTypeAssertion } from '../expression/TSTypeAssertion/spec'; +import type { UnaryExpression } from '../expression/UnaryExpression/spec'; +import type { UpdateExpression } from '../expression/UpdateExpression/spec'; +import type { YieldExpression } from '../expression/YieldExpression/spec'; +import type { ArrayPattern } from '../parameter/ArrayPattern/spec'; +import type { ObjectPattern } from '../parameter/ObjectPattern/spec'; +import type { LiteralExpression } from './LiteralExpression'; + +/* +This isn't technically correct, as it includes ArrayPattern and ObjectPattern - which are only valid +in a LeftHandSideExpression, and not in a general expression location. + +However most of the time that this type is used, the intention will be to assign a LeftHandSideExpression to this type. +So excluding the Pattern types just makes it a pain, as people have to write Expression | LeftHandSideExpression everywhere. +*/ + +export type Expression = + | ArrayExpression + | ArrayPattern + | ArrowFunctionExpression + | AssignmentExpression + | AwaitExpression + | BinaryExpression + | CallExpression + | ChainExpression + | ClassExpression + | ClassExpression + | ConditionalExpression + | FunctionExpression + | FunctionExpression + | Identifier + | ImportExpression + | JSXElement + | JSXFragment + | LiteralExpression + | LogicalExpression + | MemberExpression + | MetaProperty + | NewExpression + | ObjectExpression + | ObjectPattern + | SequenceExpression + | Super + | TaggedTemplateExpression + | TemplateLiteral + | ThisExpression + | TSAsExpression + | TSNonNullExpression + | TSTypeAssertion + | UnaryExpression + | UpdateExpression + | YieldExpression; diff --git a/packages/ast-spec/src/unions/ForInitialiser.ts b/packages/ast-spec/src/unions/ForInitialiser.ts new file mode 100644 index 000000000000..05138cb52fbc --- /dev/null +++ b/packages/ast-spec/src/unions/ForInitialiser.ts @@ -0,0 +1,4 @@ +import type { VariableDeclaration } from '../declaration/VariableDeclaration/spec'; +import type { Expression } from './Expression'; + +export type ForInitialiser = Expression | VariableDeclaration; diff --git a/packages/ast-spec/src/unions/FunctionLike.ts b/packages/ast-spec/src/unions/FunctionLike.ts new file mode 100644 index 000000000000..6ab06d834960 --- /dev/null +++ b/packages/ast-spec/src/unions/FunctionLike.ts @@ -0,0 +1,12 @@ +import type { FunctionDeclaration } from '../declaration/FunctionDeclaration/spec'; +import type { TSDeclareFunction } from '../declaration/TSDeclareFunction/spec'; +import type { ArrowFunctionExpression } from '../expression/ArrowFunctionExpression/spec'; +import type { FunctionExpression } from '../expression/FunctionExpression/spec'; +import type { TSEmptyBodyFunctionExpression } from '../expression/TSEmptyBodyFunctionExpression/spec'; + +export type FunctionLike = + | ArrowFunctionExpression + | FunctionDeclaration + | FunctionExpression + | TSDeclareFunction + | TSEmptyBodyFunctionExpression; diff --git a/packages/ast-spec/src/unions/ImportClause.ts b/packages/ast-spec/src/unions/ImportClause.ts new file mode 100644 index 000000000000..80b40826ff6d --- /dev/null +++ b/packages/ast-spec/src/unions/ImportClause.ts @@ -0,0 +1,8 @@ +import type { ImportDefaultSpecifier } from '../special/ImportDefaultSpecifier/spec'; +import type { ImportNamespaceSpecifier } from '../special/ImportNamespaceSpecifier/spec'; +import type { ImportSpecifier } from '../special/ImportSpecifier/spec'; + +export type ImportClause = + | ImportDefaultSpecifier + | ImportNamespaceSpecifier + | ImportSpecifier; diff --git a/packages/ast-spec/src/unions/IterationStatement.ts b/packages/ast-spec/src/unions/IterationStatement.ts new file mode 100644 index 000000000000..6a611431ca05 --- /dev/null +++ b/packages/ast-spec/src/unions/IterationStatement.ts @@ -0,0 +1,12 @@ +import type { DoWhileStatement } from '../statement/DoWhileStatement/spec'; +import type { ForInStatement } from '../statement/ForInStatement/spec'; +import type { ForOfStatement } from '../statement/ForOfStatement/spec'; +import type { ForStatement } from '../statement/ForStatement/spec'; +import type { WhileStatement } from '../statement/WhileStatement/spec'; + +export type IterationStatement = + | DoWhileStatement + | ForInStatement + | ForOfStatement + | ForStatement + | WhileStatement; diff --git a/packages/ast-spec/src/unions/JSXChild.ts b/packages/ast-spec/src/unions/JSXChild.ts new file mode 100644 index 000000000000..2b38836c82ef --- /dev/null +++ b/packages/ast-spec/src/unions/JSXChild.ts @@ -0,0 +1,6 @@ +import type { JSXElement } from '../expression/JSXElement/spec'; +import type { JSXFragment } from '../expression/JSXFragment/spec'; +import type { JSXText } from '../jsx/JSXText/spec'; +import type { JSXExpression } from './JSXExpression'; + +export type JSXChild = JSXElement | JSXExpression | JSXFragment | JSXText; diff --git a/packages/ast-spec/src/unions/JSXExpression.ts b/packages/ast-spec/src/unions/JSXExpression.ts new file mode 100644 index 000000000000..78dfad53525b --- /dev/null +++ b/packages/ast-spec/src/unions/JSXExpression.ts @@ -0,0 +1,8 @@ +import type { JSXEmptyExpression } from '../jsx/JSXEmptyExpression/spec'; +import type { JSXExpressionContainer } from '../jsx/JSXExpressionContainer/spec'; +import type { JSXSpreadChild } from '../jsx/JSXSpreadChild/spec'; + +export type JSXExpression = + | JSXEmptyExpression + | JSXExpressionContainer + | JSXSpreadChild; diff --git a/packages/ast-spec/src/unions/JSXTagNameExpression.ts b/packages/ast-spec/src/unions/JSXTagNameExpression.ts new file mode 100644 index 000000000000..05a831f68b45 --- /dev/null +++ b/packages/ast-spec/src/unions/JSXTagNameExpression.ts @@ -0,0 +1,8 @@ +import type { JSXIdentifier } from '../jsx/JSXIdentifier/spec'; +import type { JSXMemberExpression } from '../jsx/JSXMemberExpression/spec'; +import type { JSXNamespacedName } from '../jsx/JSXNamespacedName/spec'; + +export type JSXTagNameExpression = + | JSXIdentifier + | JSXMemberExpression + | JSXNamespacedName; diff --git a/packages/ast-spec/src/unions/LeftHandSideExpression.ts b/packages/ast-spec/src/unions/LeftHandSideExpression.ts new file mode 100644 index 000000000000..a8a24bb08d2d --- /dev/null +++ b/packages/ast-spec/src/unions/LeftHandSideExpression.ts @@ -0,0 +1,44 @@ +import type { ArrayExpression } from '../expression/ArrayExpression/spec'; +import type { ArrowFunctionExpression } from '../expression/ArrowFunctionExpression/spec'; +import type { CallExpression } from '../expression/CallExpression/spec'; +import type { ClassExpression } from '../expression/ClassExpression/spec'; +import type { FunctionExpression } from '../expression/FunctionExpression/spec'; +import type { Identifier } from '../expression/Identifier/spec'; +import type { JSXElement } from '../expression/JSXElement/spec'; +import type { JSXFragment } from '../expression/JSXFragment/spec'; +import type { MemberExpression } from '../expression/MemberExpression/spec'; +import type { MetaProperty } from '../expression/MetaProperty/spec'; +import type { ObjectExpression } from '../expression/ObjectExpression/spec'; +import type { Super } from '../expression/Super/spec'; +import type { TaggedTemplateExpression } from '../expression/TaggedTemplateExpression/spec'; +import type { TemplateLiteral } from '../expression/TemplateLiteral/spec'; +import type { ThisExpression } from '../expression/ThisExpression/spec'; +import type { TSAsExpression } from '../expression/TSAsExpression/spec'; +import type { TSNonNullExpression } from '../expression/TSNonNullExpression/spec'; +import type { TSTypeAssertion } from '../expression/TSTypeAssertion/spec'; +import type { ArrayPattern } from '../parameter/ArrayPattern/spec'; +import type { ObjectPattern } from '../parameter/ObjectPattern/spec'; +import type { LiteralExpression } from './LiteralExpression'; + +export type LeftHandSideExpression = + | ArrayExpression + | ArrayPattern + | ArrowFunctionExpression + | CallExpression + | ClassExpression + | FunctionExpression + | Identifier + | JSXElement + | JSXFragment + | LiteralExpression + | MemberExpression + | MetaProperty + | ObjectExpression + | ObjectPattern + | Super + | TaggedTemplateExpression + | TemplateLiteral + | ThisExpression + | TSAsExpression + | TSNonNullExpression + | TSTypeAssertion; diff --git a/packages/ast-spec/src/unions/Literal.ts b/packages/ast-spec/src/unions/Literal.ts new file mode 100644 index 000000000000..4da361d88423 --- /dev/null +++ b/packages/ast-spec/src/unions/Literal.ts @@ -0,0 +1,14 @@ +import type { BigIntLiteral } from '../expression/literal/BigIntLiteral/spec'; +import type { BooleanLiteral } from '../expression/literal/BooleanLiteral/spec'; +import type { NullLiteral } from '../expression/literal/NullLiteral/spec'; +import type { NumberLiteral } from '../expression/literal/NumberLiteral/spec'; +import type { RegExpLiteral } from '../expression/literal/RegExpLiteral/spec'; +import type { StringLiteral } from '../expression/literal/StringLiteral/spec'; + +export type Literal = + | BigIntLiteral + | BooleanLiteral + | NullLiteral + | NumberLiteral + | RegExpLiteral + | StringLiteral; diff --git a/packages/ast-spec/src/unions/LiteralExpression.ts b/packages/ast-spec/src/unions/LiteralExpression.ts new file mode 100644 index 000000000000..e29ddeec7ee5 --- /dev/null +++ b/packages/ast-spec/src/unions/LiteralExpression.ts @@ -0,0 +1,4 @@ +import type { TemplateLiteral } from '../expression/TemplateLiteral/spec'; +import type { Literal } from './Literal'; + +export type LiteralExpression = Literal | TemplateLiteral; diff --git a/packages/ast-spec/src/unions/Modifier.ts b/packages/ast-spec/src/unions/Modifier.ts new file mode 100644 index 000000000000..0922a52eca2e --- /dev/null +++ b/packages/ast-spec/src/unions/Modifier.ts @@ -0,0 +1,16 @@ +import type { TSAbstractKeyword } from '../token/TSAbstractKeyword/spec'; +import type { TSAsyncKeyword } from '../token/TSAsyncKeyword/spec'; +import type { TSPrivateKeyword } from '../token/TSPrivateKeyword/spec'; +import type { TSProtectedKeyword } from '../token/TSProtectedKeyword/spec'; +import type { TSPublicKeyword } from '../token/TSPublicKeyword/spec'; +import type { TSReadonlyKeyword } from '../token/TSReadonlyKeyword/spec'; +import type { TSStaticKeyword } from '../token/TSStaticKeyword/spec'; + +export type Modifier = + | TSAbstractKeyword + | TSAsyncKeyword + | TSPrivateKeyword + | TSProtectedKeyword + | TSPublicKeyword + | TSReadonlyKeyword + | TSStaticKeyword; diff --git a/packages/ast-spec/src/unions/Node.ts b/packages/ast-spec/src/unions/Node.ts new file mode 100644 index 000000000000..fe3435596a98 --- /dev/null +++ b/packages/ast-spec/src/unions/Node.ts @@ -0,0 +1,329 @@ +import type { ClassDeclaration } from '../declaration/ClassDeclaration/spec'; +import type { ExportAllDeclaration } from '../declaration/ExportAllDeclaration/spec'; +import type { ExportDefaultDeclaration } from '../declaration/ExportDefaultDeclaration/spec'; +import type { ExportNamedDeclaration } from '../declaration/ExportNamedDeclaration/spec'; +import type { FunctionDeclaration } from '../declaration/FunctionDeclaration/spec'; +import type { TSDeclareFunction } from '../declaration/TSDeclareFunction/spec'; +import type { TSEnumDeclaration } from '../declaration/TSEnumDeclaration/spec'; +import type { TSImportEqualsDeclaration } from '../declaration/TSImportEqualsDeclaration/spec'; +import type { TSInterfaceDeclaration } from '../declaration/TSInterfaceDeclaration/spec'; +import type { TSModuleDeclaration } from '../declaration/TSModuleDeclaration/spec'; +import type { TSNamespaceExportDeclaration } from '../declaration/TSNamespaceExportDeclaration/spec'; +import type { TSTypeAliasDeclaration } from '../declaration/TSTypeAliasDeclaration/spec'; +import type { VariableDeclaration } from '../declaration/VariableDeclaration/spec'; +import type { ClassProperty } from '../element/ClassProperty/spec'; +import type { MethodDefinition } from '../element/MethodDefinition/spec'; +import type { Property } from '../element/Property/spec'; +import type { SpreadElement } from '../element/SpreadElement/spec'; +import type { TSAbstractClassProperty } from '../element/TSAbstractClassProperty/spec'; +import type { TSAbstractMethodDefinition } from '../element/TSAbstractMethodDefinition/spec'; +import type { TSCallSignatureDeclaration } from '../element/TSCallSignatureDeclaration/spec'; +import type { TSConstructSignatureDeclaration } from '../element/TSConstructSignatureDeclaration/spec'; +import type { TSEnumMember } from '../element/TSEnumMember/spec'; +import type { TSIndexSignature } from '../element/TSIndexSignature/spec'; +import type { TSMethodSignature } from '../element/TSMethodSignature/spec'; +import type { TSPropertySignature } from '../element/TSPropertySignature/spec'; +import type { ArrayExpression } from '../expression/ArrayExpression/spec'; +import type { ArrowFunctionExpression } from '../expression/ArrowFunctionExpression/spec'; +import type { AssignmentExpression } from '../expression/AssignmentExpression/spec'; +import type { AwaitExpression } from '../expression/AwaitExpression/spec'; +import type { BinaryExpression } from '../expression/BinaryExpression/spec'; +import type { CallExpression } from '../expression/CallExpression/spec'; +import type { ChainExpression } from '../expression/ChainExpression/spec'; +import type { ClassExpression } from '../expression/ClassExpression/spec'; +import type { ConditionalExpression } from '../expression/ConditionalExpression/spec'; +import type { FunctionExpression } from '../expression/FunctionExpression/spec'; +import type { Identifier } from '../expression/Identifier/spec'; +import type { ImportExpression } from '../expression/ImportExpression/spec'; +import type { JSXElement } from '../expression/JSXElement/spec'; +import type { JSXFragment } from '../expression/JSXFragment/spec'; +import type { LogicalExpression } from '../expression/LogicalExpression/spec'; +import type { MemberExpression } from '../expression/MemberExpression/spec'; +import type { MetaProperty } from '../expression/MetaProperty/spec'; +import type { NewExpression } from '../expression/NewExpression/spec'; +import type { ObjectExpression } from '../expression/ObjectExpression/spec'; +import type { SequenceExpression } from '../expression/SequenceExpression/spec'; +import type { Super } from '../expression/Super/spec'; +import type { TaggedTemplateExpression } from '../expression/TaggedTemplateExpression/spec'; +import type { TemplateLiteral } from '../expression/TemplateLiteral/spec'; +import type { ThisExpression } from '../expression/ThisExpression/spec'; +import type { TSAsExpression } from '../expression/TSAsExpression/spec'; +import type { TSEmptyBodyFunctionExpression } from '../expression/TSEmptyBodyFunctionExpression/spec'; +import type { TSNonNullExpression } from '../expression/TSNonNullExpression/spec'; +import type { TSTypeAssertion } from '../expression/TSTypeAssertion/spec'; +import type { UnaryExpression } from '../expression/UnaryExpression/spec'; +import type { UpdateExpression } from '../expression/UpdateExpression/spec'; +import type { YieldExpression } from '../expression/YieldExpression/spec'; +import type { JSXAttribute } from '../jsx/JSXAttribute/spec'; +import type { JSXClosingElement } from '../jsx/JSXClosingElement/spec'; +import type { JSXClosingFragment } from '../jsx/JSXClosingFragment/spec'; +import type { JSXEmptyExpression } from '../jsx/JSXEmptyExpression/spec'; +import type { JSXExpressionContainer } from '../jsx/JSXExpressionContainer/spec'; +import type { JSXIdentifier } from '../jsx/JSXIdentifier/spec'; +import type { JSXMemberExpression } from '../jsx/JSXMemberExpression/spec'; +import type { JSXNamespacedName } from '../jsx/JSXNamespacedName/spec'; +import type { JSXOpeningElement } from '../jsx/JSXOpeningElement/spec'; +import type { JSXOpeningFragment } from '../jsx/JSXOpeningFragment/spec'; +import type { JSXSpreadAttribute } from '../jsx/JSXSpreadAttribute/spec'; +import type { JSXSpreadChild } from '../jsx/JSXSpreadChild/spec'; +import type { JSXText } from '../jsx/JSXText/spec'; +import type { ArrayPattern } from '../parameter/ArrayPattern/spec'; +import type { AssignmentPattern } from '../parameter/AssignmentPattern/spec'; +import type { ObjectPattern } from '../parameter/ObjectPattern/spec'; +import type { RestElement } from '../parameter/RestElement/spec'; +import type { TSParameterProperty } from '../parameter/TSParameterProperty/spec'; +import type { CatchClause } from '../special/CatchClause/spec'; +import type { ClassBody } from '../special/ClassBody/spec'; +import type { Decorator } from '../special/Decorator/spec'; +import type { EmptyStatement } from '../special/EmptyStatement/spec'; +import type { ExportSpecifier } from '../special/ExportSpecifier/spec'; +import type { ImportDefaultSpecifier } from '../special/ImportDefaultSpecifier/spec'; +import type { ImportNamespaceSpecifier } from '../special/ImportNamespaceSpecifier/spec'; +import type { ImportSpecifier } from '../special/ImportSpecifier/spec'; +import type { Program } from '../special/Program/spec'; +import type { SwitchCase } from '../special/SwitchCase/spec'; +import type { TemplateElement } from '../special/TemplateElement/spec'; +import type { TSClassImplements } from '../special/TSClassImplements/spec'; +import type { TSExternalModuleReference } from '../special/TSExternalModuleReference/spec'; +import type { TSInterfaceBody } from '../special/TSInterfaceBody/spec'; +import type { TSInterfaceHeritage } from '../special/TSInterfaceHeritage/spec'; +import type { TSModuleBlock } from '../special/TSModuleBlock/spec'; +import type { TSTypeAnnotation } from '../special/TSTypeAnnotation/spec'; +import type { TSTypeParameter } from '../special/TSTypeParameter/spec'; +import type { TSTypeParameterDeclaration } from '../special/TSTypeParameterDeclaration/spec'; +import type { TSTypeParameterInstantiation } from '../special/TSTypeParameterInstantiation/spec'; +import type { VariableDeclarator } from '../special/VariableDeclarator/spec'; +import type { BlockStatement } from '../statement/BlockStatement/spec'; +import type { BreakStatement } from '../statement/BreakStatement/spec'; +import type { ContinueStatement } from '../statement/ContinueStatement/spec'; +import type { DebuggerStatement } from '../statement/DebuggerStatement/spec'; +import type { DoWhileStatement } from '../statement/DoWhileStatement/spec'; +import type { ExpressionStatement } from '../statement/ExpressionStatement/spec'; +import type { ForInStatement } from '../statement/ForInStatement/spec'; +import type { ForOfStatement } from '../statement/ForOfStatement/spec'; +import type { ForStatement } from '../statement/ForStatement/spec'; +import type { IfStatement } from '../statement/IfStatement/spec'; +import type { ImportDeclaration } from '../statement/ImportDeclaration/spec'; +import type { LabeledStatement } from '../statement/LabeledStatement/spec'; +import type { ReturnStatement } from '../statement/ReturnStatement/spec'; +import type { SwitchStatement } from '../statement/SwitchStatement/spec'; +import type { ThrowStatement } from '../statement/ThrowStatement/spec'; +import type { TryStatement } from '../statement/TryStatement/spec'; +import type { TSExportAssignment } from '../statement/TSExportAssignment/spec'; +import type { WhileStatement } from '../statement/WhileStatement/spec'; +import type { WithStatement } from '../statement/WithStatement/spec'; +import type { TSAbstractKeyword } from '../token/TSAbstractKeyword/spec'; +import type { TSAsyncKeyword } from '../token/TSAsyncKeyword/spec'; +import type { TSDeclareKeyword } from '../token/TSDeclareKeyword/spec'; +import type { TSExportKeyword } from '../token/TSExportKeyword/spec'; +import type { TSPrivateKeyword } from '../token/TSPrivateKeyword/spec'; +import type { TSProtectedKeyword } from '../token/TSProtectedKeyword/spec'; +import type { TSPublicKeyword } from '../token/TSPublicKeyword/spec'; +import type { TSReadonlyKeyword } from '../token/TSReadonlyKeyword/spec'; +import type { TSStaticKeyword } from '../token/TSStaticKeyword/spec'; +import type { TSAnyKeyword } from '../type/TSAnyKeyword/spec'; +import type { TSArrayType } from '../type/TSArrayType/spec'; +import type { TSBigIntKeyword } from '../type/TSBigIntKeyword/spec'; +import type { TSBooleanKeyword } from '../type/TSBooleanKeyword/spec'; +import type { TSConditionalType } from '../type/TSConditionalType/spec'; +import type { TSConstructorType } from '../type/TSConstructorType/spec'; +import type { TSFunctionType } from '../type/TSFunctionType/spec'; +import type { TSImportType } from '../type/TSImportType/spec'; +import type { TSIndexedAccessType } from '../type/TSIndexedAccessType/spec'; +import type { TSInferType } from '../type/TSInferType/spec'; +import type { TSIntersectionType } from '../type/TSIntersectionType/spec'; +import type { TSIntrinsicKeyword } from '../type/TSIntrinsicType/spec'; +import type { TSLiteralType } from '../type/TSLiteralType/spec'; +import type { TSMappedType } from '../type/TSMappedType/spec'; +import type { TSNamedTupleMember } from '../type/TSNamedTupleMember/spec'; +import type { TSNeverKeyword } from '../type/TSNeverKeyword/spec'; +import type { TSNullKeyword } from '../type/TSNullKeyword/spec'; +import type { TSNumberKeyword } from '../type/TSNumberKeyword/spec'; +import type { TSObjectKeyword } from '../type/TSObjectKeyword/spec'; +import type { TSOptionalType } from '../type/TSOptionalType/spec'; +import type { TSParenthesizedType } from '../type/TSParenthesizedType/spec'; +import type { TSQualifiedName } from '../type/TSQualifiedName/spec'; +import type { TSRestType } from '../type/TSRestType/spec'; +import type { TSStringKeyword } from '../type/TSStringKeyword/spec'; +import type { TSSymbolKeyword } from '../type/TSSymbolKeyword/spec'; +import type { TSTemplateLiteralType } from '../type/TSTemplateLiteralType/spec'; +import type { TSThisType } from '../type/TSThisType/spec'; +import type { TSTupleType } from '../type/TSTupleType/spec'; +import type { TSTypeLiteral } from '../type/TSTypeLiteral/spec'; +import type { TSTypeOperator } from '../type/TSTypeOperator/spec'; +import type { TSTypePredicate } from '../type/TSTypePredicate/spec'; +import type { TSTypeQuery } from '../type/TSTypeQuery/spec'; +import type { TSTypeReference } from '../type/TSTypeReference/spec'; +import type { TSUndefinedKeyword } from '../type/TSUndefinedKeyword/spec'; +import type { TSUnionType } from '../type/TSUnionType/spec'; +import type { TSUnknownKeyword } from '../type/TSUnknownKeyword/spec'; +import type { TSVoidKeyword } from '../type/TSVoidKeyword/spec'; +import type { Literal } from './Literal'; + +/* + * NOTE: + * Tokens are not included in the `Node` union below on purpose because they are not ever included as part of the standard AST tree. + */ + +export type Node = + | ArrayExpression + | ArrayPattern + | ArrowFunctionExpression + | AssignmentExpression + | AssignmentPattern + | AwaitExpression + | BinaryExpression + | BlockStatement + | BreakStatement + | CallExpression + | CatchClause + | ChainExpression + | ClassBody + | ClassDeclaration + | ClassExpression + | ClassProperty + | ConditionalExpression + | ContinueStatement + | DebuggerStatement + | Decorator + | DoWhileStatement + | EmptyStatement + | ExportAllDeclaration + | ExportDefaultDeclaration + | ExportNamedDeclaration + | ExportSpecifier + | ExpressionStatement + | ForInStatement + | ForOfStatement + | ForStatement + | FunctionDeclaration + | FunctionExpression + | Identifier + | IfStatement + | ImportDeclaration + | ImportDefaultSpecifier + | ImportExpression + | ImportNamespaceSpecifier + | ImportSpecifier + | JSXAttribute + | JSXClosingElement + | JSXClosingFragment + | JSXElement + | JSXEmptyExpression + | JSXExpressionContainer + | JSXFragment + | JSXIdentifier + | JSXMemberExpression + | JSXNamespacedName + | JSXOpeningElement + | JSXOpeningFragment + | JSXSpreadAttribute + | JSXSpreadChild + | JSXText + | LabeledStatement + | Literal + | LogicalExpression + | MemberExpression + | MetaProperty + | MethodDefinition + | NewExpression + | ObjectExpression + | ObjectPattern + | Program + | Property + | RestElement + | ReturnStatement + | SequenceExpression + | SpreadElement + | Super + | SwitchCase + | SwitchStatement + | TaggedTemplateExpression + | TemplateElement + | TemplateLiteral + | ThisExpression + | ThrowStatement + | TryStatement + | TSAbstractClassProperty + | TSAbstractKeyword + | TSAbstractMethodDefinition + | TSAnyKeyword + | TSArrayType + | TSAsExpression + | TSAsyncKeyword + | TSBigIntKeyword + | TSBooleanKeyword + | TSCallSignatureDeclaration + | TSClassImplements + | TSConditionalType + | TSConstructorType + | TSConstructSignatureDeclaration + | TSDeclareFunction + | TSDeclareKeyword + | TSEmptyBodyFunctionExpression + | TSEnumDeclaration + | TSEnumMember + | TSExportAssignment + | TSExportKeyword + | TSExternalModuleReference + | TSFunctionType + | TSImportEqualsDeclaration + | TSImportType + | TSIndexedAccessType + | TSIndexSignature + | TSInferType + | TSInterfaceBody + | TSInterfaceDeclaration + | TSInterfaceHeritage + | TSIntersectionType + | TSIntrinsicKeyword + | TSLiteralType + | TSMappedType + | TSMethodSignature + | TSModuleBlock + | TSModuleDeclaration + | TSNamedTupleMember + | TSNamespaceExportDeclaration + | TSNeverKeyword + | TSNonNullExpression + | TSNullKeyword + | TSNumberKeyword + | TSObjectKeyword + | TSOptionalType + | TSParameterProperty + | TSParenthesizedType + | TSPrivateKeyword + | TSPropertySignature + | TSProtectedKeyword + | TSPublicKeyword + | TSQualifiedName + | TSReadonlyKeyword + | TSRestType + | TSStaticKeyword + | TSStringKeyword + | TSSymbolKeyword + | TSTemplateLiteralType + | TSThisType + | TSTupleType + | TSTypeAliasDeclaration + | TSTypeAnnotation + | TSTypeAssertion + | TSTypeLiteral + | TSTypeOperator + | TSTypeParameter + | TSTypeParameterDeclaration + | TSTypeParameterInstantiation + | TSTypePredicate + | TSTypeQuery + | TSTypeReference + | TSUndefinedKeyword + | TSUnionType + | TSUnknownKeyword + | TSVoidKeyword + | UnaryExpression + | UpdateExpression + | VariableDeclaration + | VariableDeclarator + | WhileStatement + | WithStatement + | YieldExpression; diff --git a/packages/ast-spec/src/unions/ObjectLiteralElement.ts b/packages/ast-spec/src/unions/ObjectLiteralElement.ts new file mode 100644 index 000000000000..d7575c80c1b9 --- /dev/null +++ b/packages/ast-spec/src/unions/ObjectLiteralElement.ts @@ -0,0 +1,8 @@ +import type { MethodDefinition } from '../element/MethodDefinition/spec'; +import type { Property } from '../element/Property/spec'; +import type { SpreadElement } from '../element/SpreadElement/spec'; + +export type ObjectLiteralElement = MethodDefinition | Property | SpreadElement; + +// TODO - breaking change remove this +export type ObjectLiteralElementLike = ObjectLiteralElement; diff --git a/packages/ast-spec/src/unions/Parameter.ts b/packages/ast-spec/src/unions/Parameter.ts new file mode 100644 index 000000000000..766a8dedbe7e --- /dev/null +++ b/packages/ast-spec/src/unions/Parameter.ts @@ -0,0 +1,14 @@ +import type { Identifier } from '../expression/Identifier/spec'; +import type { ArrayPattern } from '../parameter/ArrayPattern/spec'; +import type { AssignmentPattern } from '../parameter/AssignmentPattern/spec'; +import type { ObjectPattern } from '../parameter/ObjectPattern/spec'; +import type { RestElement } from '../parameter/RestElement/spec'; +import type { TSParameterProperty } from '../parameter/TSParameterProperty/spec'; + +export type Parameter = + | ArrayPattern + | AssignmentPattern + | Identifier + | ObjectPattern + | RestElement + | TSParameterProperty; diff --git a/packages/ast-spec/src/unions/PrimaryExpression.ts b/packages/ast-spec/src/unions/PrimaryExpression.ts new file mode 100644 index 000000000000..3c1dbf07fb85 --- /dev/null +++ b/packages/ast-spec/src/unions/PrimaryExpression.ts @@ -0,0 +1,35 @@ +import type { ArrayExpression } from '../expression/ArrayExpression/spec'; +import type { ClassExpression } from '../expression/ClassExpression/spec'; +import type { FunctionExpression } from '../expression/FunctionExpression/spec'; +import type { Identifier } from '../expression/Identifier/spec'; +import type { JSXElement } from '../expression/JSXElement/spec'; +import type { JSXFragment } from '../expression/JSXFragment/spec'; +import type { MetaProperty } from '../expression/MetaProperty/spec'; +import type { ObjectExpression } from '../expression/ObjectExpression/spec'; +import type { Super } from '../expression/Super/spec'; +import type { TemplateLiteral } from '../expression/TemplateLiteral/spec'; +import type { ThisExpression } from '../expression/ThisExpression/spec'; +import type { JSXOpeningElement } from '../jsx/JSXOpeningElement/spec'; +import type { ArrayPattern } from '../parameter/ArrayPattern/spec'; +import type { ObjectPattern } from '../parameter/ObjectPattern/spec'; +import type { TSNullKeyword } from '../type/TSNullKeyword/spec'; +import type { LiteralExpression } from './LiteralExpression'; + +// TODO - breaking change remove this +export type PrimaryExpression = + | ArrayExpression + | ArrayPattern + | ClassExpression + | FunctionExpression + | Identifier + | JSXElement + | JSXFragment + | JSXOpeningElement + | LiteralExpression + | MetaProperty + | ObjectExpression + | ObjectPattern + | Super + | TemplateLiteral + | ThisExpression + | TSNullKeyword; diff --git a/packages/ast-spec/src/unions/PropertyName.ts b/packages/ast-spec/src/unions/PropertyName.ts new file mode 100644 index 000000000000..56ba04cabbea --- /dev/null +++ b/packages/ast-spec/src/unions/PropertyName.ts @@ -0,0 +1,11 @@ +import type { Identifier } from '../expression/Identifier/spec'; +import type { NumberLiteral } from '../expression/literal/NumberLiteral/spec'; +import type { StringLiteral } from '../expression/literal/StringLiteral/spec'; +import type { Expression } from '../unions/Expression'; + +export type PropertyName = PropertyNameComputed | PropertyNameNonComputed; +export type PropertyNameComputed = Expression; +export type PropertyNameNonComputed = + | Identifier + | NumberLiteral + | StringLiteral; diff --git a/packages/ast-spec/src/unions/Statement.ts b/packages/ast-spec/src/unions/Statement.ts new file mode 100644 index 000000000000..7345a159982e --- /dev/null +++ b/packages/ast-spec/src/unions/Statement.ts @@ -0,0 +1,78 @@ +import type { ClassDeclaration } from '../declaration/ClassDeclaration/spec'; +import type { ExportAllDeclaration } from '../declaration/ExportAllDeclaration/spec'; +import type { ExportDefaultDeclaration } from '../declaration/ExportDefaultDeclaration/spec'; +import type { ExportNamedDeclaration } from '../declaration/ExportNamedDeclaration/spec'; +import type { FunctionDeclaration } from '../declaration/FunctionDeclaration/spec'; +import type { TSDeclareFunction } from '../declaration/TSDeclareFunction/spec'; +import type { TSEnumDeclaration } from '../declaration/TSEnumDeclaration/spec'; +import type { TSImportEqualsDeclaration } from '../declaration/TSImportEqualsDeclaration/spec'; +import type { TSInterfaceDeclaration } from '../declaration/TSInterfaceDeclaration/spec'; +import type { TSModuleDeclaration } from '../declaration/TSModuleDeclaration/spec'; +import type { TSNamespaceExportDeclaration } from '../declaration/TSNamespaceExportDeclaration/spec'; +import type { TSTypeAliasDeclaration } from '../declaration/TSTypeAliasDeclaration/spec'; +import type { VariableDeclaration } from '../declaration/VariableDeclaration/spec'; +import type { BlockStatement } from '../statement/BlockStatement/spec'; +import type { BreakStatement } from '../statement/BreakStatement/spec'; +import type { ContinueStatement } from '../statement/ContinueStatement/spec'; +import type { DebuggerStatement } from '../statement/DebuggerStatement/spec'; +import type { DoWhileStatement } from '../statement/DoWhileStatement/spec'; +import type { ExpressionStatement } from '../statement/ExpressionStatement/spec'; +import type { ForInStatement } from '../statement/ForInStatement/spec'; +import type { ForOfStatement } from '../statement/ForOfStatement/spec'; +import type { ForStatement } from '../statement/ForStatement/spec'; +import type { IfStatement } from '../statement/IfStatement/spec'; +import type { ImportDeclaration } from '../statement/ImportDeclaration/spec'; +import type { LabeledStatement } from '../statement/LabeledStatement/spec'; +import type { ReturnStatement } from '../statement/ReturnStatement/spec'; +import type { SwitchStatement } from '../statement/SwitchStatement/spec'; +import type { ThrowStatement } from '../statement/ThrowStatement/spec'; +import type { TryStatement } from '../statement/TryStatement/spec'; +import type { TSExportAssignment } from '../statement/TSExportAssignment/spec'; +import type { WhileStatement } from '../statement/WhileStatement/spec'; +import type { WithStatement } from '../statement/WithStatement/spec'; + +export type Statement = + | BlockStatement + | BreakStatement + | ClassDeclaration + | ContinueStatement + | DebuggerStatement + | DoWhileStatement + | ExportAllDeclaration + | ExportDefaultDeclaration + | ExportNamedDeclaration + | ExpressionStatement + | ForInStatement + | ForOfStatement + | ForStatement + | FunctionDeclaration + | IfStatement + | ImportDeclaration + | LabeledStatement + | ReturnStatement + | SwitchStatement + | ThrowStatement + | TryStatement + | TSDeclareFunction + | TSEnumDeclaration + | TSExportAssignment + | TSImportEqualsDeclaration + | TSInterfaceDeclaration + | TSModuleDeclaration + | TSNamespaceExportDeclaration + | TSTypeAliasDeclaration + | VariableDeclaration + | WhileStatement + | WithStatement; + +// These nodes are ***only*** allowed at the top-level +export type ProgramStatement = + | ExportAllDeclaration + | ExportDefaultDeclaration + | ExportNamedDeclaration + | ImportDeclaration + | Statement + | TSImportEqualsDeclaration + | TSNamespaceExportDeclaration; + +// TODO - once we have syntax errors, the types in ProgramStatement should not be in Statement diff --git a/packages/ast-spec/src/unions/TSUnaryExpression.ts b/packages/ast-spec/src/unions/TSUnaryExpression.ts new file mode 100644 index 000000000000..b4dd05627bf6 --- /dev/null +++ b/packages/ast-spec/src/unions/TSUnaryExpression.ts @@ -0,0 +1,13 @@ +import type { AwaitExpression } from '../expression/AwaitExpression/spec'; +import type { TSTypeAssertion } from '../expression/TSTypeAssertion/spec'; +import type { UnaryExpression } from '../expression/UnaryExpression/spec'; +import type { UpdateExpression } from '../expression/UpdateExpression/spec'; +import type { LeftHandSideExpression } from './LeftHandSideExpression'; + +// TODO - breaking change remove this +export type TSUnaryExpression = + | AwaitExpression + | LeftHandSideExpression + | TSTypeAssertion + | UnaryExpression + | UpdateExpression; diff --git a/packages/ast-spec/src/unions/Token.ts b/packages/ast-spec/src/unions/Token.ts new file mode 100644 index 000000000000..3d71cb019a7f --- /dev/null +++ b/packages/ast-spec/src/unions/Token.ts @@ -0,0 +1,26 @@ +import type { BooleanToken } from '../token/BooleanToken/spec'; +import type { IdentifierToken } from '../token/IdentifierToken/spec'; +import type { JSXIdentifierToken } from '../token/JSXIdentifierToken/spec'; +import type { JSXTextToken } from '../token/JSXTextToken/spec'; +import type { KeywordToken } from '../token/KeywordToken/spec'; +import type { NullToken } from '../token/NullToken/spec'; +import type { NumericToken } from '../token/NumericToken/spec'; +import type { PunctuatorToken } from '../token/PunctuatorToken/spec'; +import type { RegularExpressionToken } from '../token/RegularExpressionToken/spec'; +import type { StringToken } from '../token/StringToken/spec'; +import type { TemplateToken } from '../token/TemplateToken/spec'; +import type { Comment } from './Comment'; + +export type Token = + | BooleanToken + | Comment + | IdentifierToken + | JSXIdentifierToken + | JSXTextToken + | KeywordToken + | NullToken + | NumericToken + | PunctuatorToken + | RegularExpressionToken + | StringToken + | TemplateToken; diff --git a/packages/ast-spec/src/unions/TypeElement.ts b/packages/ast-spec/src/unions/TypeElement.ts new file mode 100644 index 000000000000..9a4bbc99c223 --- /dev/null +++ b/packages/ast-spec/src/unions/TypeElement.ts @@ -0,0 +1,12 @@ +import type { TSCallSignatureDeclaration } from '../element/TSCallSignatureDeclaration/spec'; +import type { TSConstructSignatureDeclaration } from '../element/TSConstructSignatureDeclaration/spec'; +import type { TSIndexSignature } from '../element/TSIndexSignature/spec'; +import type { TSMethodSignature } from '../element/TSMethodSignature/spec'; +import type { TSPropertySignature } from '../element/TSPropertySignature/spec'; + +export type TypeElement = + | TSCallSignatureDeclaration + | TSConstructSignatureDeclaration + | TSIndexSignature + | TSMethodSignature + | TSPropertySignature; diff --git a/packages/ast-spec/src/unions/TypeNode.ts b/packages/ast-spec/src/unions/TypeNode.ts new file mode 100644 index 000000000000..c50630e6cd6a --- /dev/null +++ b/packages/ast-spec/src/unions/TypeNode.ts @@ -0,0 +1,74 @@ +import type { TSAnyKeyword } from '../type/TSAnyKeyword/spec'; +import type { TSArrayType } from '../type/TSArrayType/spec'; +import type { TSBigIntKeyword } from '../type/TSBigIntKeyword/spec'; +import type { TSBooleanKeyword } from '../type/TSBooleanKeyword/spec'; +import type { TSConditionalType } from '../type/TSConditionalType/spec'; +import type { TSConstructorType } from '../type/TSConstructorType/spec'; +import type { TSFunctionType } from '../type/TSFunctionType/spec'; +import type { TSImportType } from '../type/TSImportType/spec'; +import type { TSIndexedAccessType } from '../type/TSIndexedAccessType/spec'; +import type { TSInferType } from '../type/TSInferType/spec'; +import type { TSIntersectionType } from '../type/TSIntersectionType/spec'; +import type { TSIntrinsicKeyword } from '../type/TSIntrinsicType/spec'; +import type { TSLiteralType } from '../type/TSLiteralType/spec'; +import type { TSMappedType } from '../type/TSMappedType/spec'; +import type { TSNamedTupleMember } from '../type/TSNamedTupleMember/spec'; +import type { TSNeverKeyword } from '../type/TSNeverKeyword/spec'; +import type { TSNullKeyword } from '../type/TSNullKeyword/spec'; +import type { TSNumberKeyword } from '../type/TSNumberKeyword/spec'; +import type { TSObjectKeyword } from '../type/TSObjectKeyword/spec'; +import type { TSOptionalType } from '../type/TSOptionalType/spec'; +import type { TSParenthesizedType } from '../type/TSParenthesizedType/spec'; +import type { TSRestType } from '../type/TSRestType/spec'; +import type { TSStringKeyword } from '../type/TSStringKeyword/spec'; +import type { TSSymbolKeyword } from '../type/TSSymbolKeyword/spec'; +import type { TSTemplateLiteralType } from '../type/TSTemplateLiteralType/spec'; +import type { TSThisType } from '../type/TSThisType/spec'; +import type { TSTupleType } from '../type/TSTupleType/spec'; +import type { TSTypeLiteral } from '../type/TSTypeLiteral/spec'; +import type { TSTypeOperator } from '../type/TSTypeOperator/spec'; +import type { TSTypePredicate } from '../type/TSTypePredicate/spec'; +import type { TSTypeQuery } from '../type/TSTypeQuery/spec'; +import type { TSTypeReference } from '../type/TSTypeReference/spec'; +import type { TSUndefinedKeyword } from '../type/TSUndefinedKeyword/spec'; +import type { TSUnionType } from '../type/TSUnionType/spec'; +import type { TSUnknownKeyword } from '../type/TSUnknownKeyword/spec'; +import type { TSVoidKeyword } from '../type/TSVoidKeyword/spec'; + +export type TypeNode = + | TSAnyKeyword + | TSArrayType + | TSBigIntKeyword + | TSBooleanKeyword + | TSConditionalType + | TSConstructorType + | TSFunctionType + | TSImportType + | TSIndexedAccessType + | TSInferType + | TSIntersectionType + | TSIntrinsicKeyword + | TSLiteralType + | TSMappedType + | TSNamedTupleMember + | TSNeverKeyword + | TSNullKeyword + | TSNumberKeyword + | TSObjectKeyword + | TSOptionalType + | TSParenthesizedType + | TSRestType + | TSStringKeyword + | TSSymbolKeyword + | TSTemplateLiteralType + | TSThisType + | TSTupleType + | TSTypeLiteral + | TSTypeOperator + | TSTypePredicate + | TSTypeQuery + | TSTypeReference + | TSUndefinedKeyword + | TSUnionType + | TSUnknownKeyword + | TSVoidKeyword; diff --git a/packages/ast-spec/tests/ast-node-types.test.ts b/packages/ast-spec/tests/ast-node-types.test.ts new file mode 100644 index 000000000000..7cc247f2d094 --- /dev/null +++ b/packages/ast-spec/tests/ast-node-types.test.ts @@ -0,0 +1,16 @@ +import type { AST_NODE_TYPES } from '../src/ast-node-types'; +import type { Node } from '../src/unions/Node'; + +type GetKeys = keyof Extract; + +type AllKeys = { + readonly [T in AST_NODE_TYPES]: GetKeys; +}; + +type TakesString> = T; + +// @ts-expect-error: purposely unused +type _Test = + // forcing the test onto a new line so it isn't covered by the expect error + // If there are any enum members that don't have a corresponding TSESTree.Node, then this line will error with "Type 'string | number | symbol' is not assignable to type 'string'." + TakesString | void; diff --git a/packages/ast-spec/tsconfig.build.json b/packages/ast-spec/tsconfig.build.json new file mode 100644 index 000000000000..215a0282df2b --- /dev/null +++ b/packages/ast-spec/tsconfig.build.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./dist", + "rootDir": "./src", + "resolveJsonModule": true + }, + "include": ["src", "typings"] +} diff --git a/packages/ast-spec/tsconfig.json b/packages/ast-spec/tsconfig.json new file mode 100644 index 000000000000..4b76ef4253b9 --- /dev/null +++ b/packages/ast-spec/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.build.json", + "compilerOptions": { + "composite": false, + "rootDir": "." + }, + "include": ["src", "typings", "tests", "tools", "./rollup.config.ts"] +} diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json index f0c64a185df3..ed377ea25988 100644 --- a/packages/eslint-plugin-internal/package.json +++ b/packages/eslint-plugin-internal/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "tsc -b tsconfig.build.json", "clean": "tsc -b tsconfig.build.json --clean", - "postclean": "rimraf dist", + "postclean": "rimraf dist && rimraf coverage", "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", "lint": "eslint . --ext .js,.ts --ignore-path='../../.eslintignore'", "test": "jest --coverage", diff --git a/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts b/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts index bc26d9d9d9a1..64fefc08f8ef 100644 --- a/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts +++ b/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts @@ -408,7 +408,9 @@ export default createRule({ } } - function isNoFormatTemplateTag(tag: TSESTree.Expression): boolean { + function isNoFormatTemplateTag( + tag: TSESTree.LeftHandSideExpression, + ): boolean { return tag.type === AST_NODE_TYPES.Identifier && tag.name === 'noFormat'; } diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index fcd692ca596e..b35badc6bfd4 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -31,7 +31,7 @@ "scripts": { "build": "tsc -b tsconfig.build.json", "clean": "tsc -b tsconfig.build.json --clean", - "postclean": "rimraf dist", + "postclean": "rimraf dist && rimraf coverage", "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", "lint": "eslint . --ext .js,.ts --ignore-path='../../.eslintignore'", "test": "jest --coverage", diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 38db92807b9e..72ca9feaf597 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -35,7 +35,7 @@ "check:docs": "jest tests/docs.test.ts --runTestsByPath --silent --runInBand", "check:configs": "jest tests/configs.test.ts --runTestsByPath --silent --runInBand", "clean": "tsc -b tsconfig.build.json --clean", - "postclean": "rimraf dist", + "postclean": "rimraf dist && rimraf coverage", "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", "generate:configs": "../../node_modules/.bin/ts-node --files --transpile-only tools/generate-configs.ts", "generate:rules-lists": "../../node_modules/.bin/ts-node --files --transpile-only tools/generate-rules-lists.ts", diff --git a/packages/eslint-plugin/src/rules/no-loss-of-precision.ts b/packages/eslint-plugin/src/rules/no-loss-of-precision.ts index 47ab5b1a74fa..1e04d080e747 100644 --- a/packages/eslint-plugin/src/rules/no-loss-of-precision.ts +++ b/packages/eslint-plugin/src/rules/no-loss-of-precision.ts @@ -46,7 +46,7 @@ export default util.createRule({ rules.Literal({ ...node, raw: isSeperatedNumeric(node) ? node.raw.replace(/_/g, '') : node.raw, - }); + } as never); }, }; }, diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts b/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts index aee4963a0c05..f5ca89e88d60 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts @@ -167,7 +167,7 @@ export default createRule({ }); } - function getNodeType(node: TSESTree.Expression): ts.Type { + function getNodeType(node: TSESTree.Node): ts.Type { const tsNode = service.esTreeNodeToTSNodeMap.get(node); return getConstrainedTypeAtLocation(checker, tsNode); } diff --git a/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts b/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts index d78c4496164d..636fe2b3825a 100644 --- a/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts +++ b/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts @@ -40,7 +40,7 @@ export default createRule({ * Check if a given node is a string. * @param node The node to check. */ - function isStringType(node: TSESTree.Expression): boolean { + function isStringType(node: TSESTree.Node): boolean { const objectType = typeChecker.getTypeAtLocation( parserServices.esTreeNodeToTSNodeMap.get(node), ); @@ -51,7 +51,7 @@ export default createRule({ * Check if a given node is a RegExp. * @param node The node to check. */ - function isRegExpType(node: TSESTree.Expression): boolean { + function isRegExpType(node: TSESTree.Node): boolean { const objectType = typeChecker.getTypeAtLocation( parserServices.esTreeNodeToTSNodeMap.get(node), ); diff --git a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts index fb83da6f318b..af80720c2904 100644 --- a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts +++ b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts @@ -82,7 +82,6 @@ function getGroup(node: TSESTree.TypeNode): Group { return Group.union; // These types should never occur as part of a union/intersection - case AST_NODE_TYPES.TSInterfaceHeritage: case AST_NODE_TYPES.TSNamedTupleMember: case AST_NODE_TYPES.TSOptionalType: case AST_NODE_TYPES.TSRestType: diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index b3402e64bde0..d2ebd2a40720 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -32,7 +32,7 @@ "build": "tsc -b tsconfig.build.json", "postbuild": "downlevel-dts dist _ts3.4/dist", "clean": "tsc -b tsconfig.build.json --clean", - "postclean": "rimraf dist && rimraf _ts3.4", + "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", "lint": "eslint . --ext .js,.ts --ignore-path='../../.eslintignore'", "test": "jest --coverage", diff --git a/packages/parser/package.json b/packages/parser/package.json index 7aaac815772d..9e9fd7f81858 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -34,7 +34,7 @@ "build": "tsc -b tsconfig.build.json", "postbuild": "downlevel-dts dist _ts3.4/dist", "clean": "tsc -b tsconfig.build.json --clean", - "postclean": "rimraf dist", + "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", "lint": "eslint . --ext .js,.ts --ignore-path='../../.eslintignore'", "test": "jest --coverage", diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index 51f58e98474b..b130cdea237e 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -31,7 +31,7 @@ "build": "tsc -b tsconfig.build.json", "postbuild": "downlevel-dts dist _ts3.4/dist", "clean": "tsc -b tsconfig.build.json --clean", - "postclean": "rimraf dist", + "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", "generate:lib": "../../node_modules/.bin/ts-node --files --transpile-only tools/generate-lib.ts", "lint": "eslint . --ext .js,.ts --ignore-path='../../.eslintignore'", diff --git a/packages/scope-manager/src/scope/ScopeBase.ts b/packages/scope-manager/src/scope/ScopeBase.ts index 04f38e8a65f3..602dd81a206a 100644 --- a/packages/scope-manager/src/scope/ScopeBase.ts +++ b/packages/scope-manager/src/scope/ScopeBase.ts @@ -87,22 +87,20 @@ function isStrictScope( if (stmt.type !== AST_NODE_TYPES.ExpressionStatement) { break; } - const expr = stmt.expression; - if ( - expr.type !== AST_NODE_TYPES.Literal || - typeof expr.value !== 'string' - ) { + if (stmt.directive === 'use strict') { + return true; + } + + const expr = stmt.expression; + if (expr.type !== AST_NODE_TYPES.Literal) { break; } - if (expr.raw !== null && expr.raw !== undefined) { - if (expr.raw === '"use strict"' || expr.raw === "'use strict'") { - return true; - } - } else { - if (expr.value === 'use strict') { - return true; - } + if (expr.raw === '"use strict"' || expr.raw === "'use strict'") { + return true; + } + if (expr.value === 'use strict') { + return true; } } return false; diff --git a/packages/types/package.json b/packages/types/package.json index 5251c580de59..cd37019cbf4b 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -19,7 +19,7 @@ "repository": { "type": "git", "url": "https://github.com/typescript-eslint/typescript-eslint.git", - "directory": "packages/visitor-keys" + "directory": "packages/types" }, "bugs": { "url": "https://github.com/typescript-eslint/typescript-eslint/issues" @@ -28,10 +28,11 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { + "prebuild": "yarn ts-node --transpile-only ./tools/copy-ast-spec.ts", "build": "tsc -b tsconfig.build.json", "postbuild": "downlevel-dts dist _ts3.4/dist", "clean": "tsc -b tsconfig.build.json --clean", - "postclean": "rimraf dist", + "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", "generate:lib": "../../node_modules/.bin/ts-node --files --transpile-only ../scope-manager/tools/generate-lib.ts", "lint": "eslint . --ext .js,.ts --ignore-path='../../.eslintignore'", diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 59df48302df5..4bda24b13818 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -1,5 +1,5 @@ -export { AST_NODE_TYPES } from './ast-node-types'; -export { AST_TOKEN_TYPES } from './ast-token-types'; +export { AST_NODE_TYPES } from './ast-spec'; +export { AST_TOKEN_TYPES } from './ast-spec'; export * from './lib'; export * from './parser-options'; -export * as TSESTree from './ts-estree'; +export * from './ts-estree'; diff --git a/packages/types/src/ts-estree.ts b/packages/types/src/ts-estree.ts index e296b5668ae0..037bd3f92c97 100644 --- a/packages/types/src/ts-estree.ts +++ b/packages/types/src/ts-estree.ts @@ -1,1769 +1,21 @@ -import { AST_NODE_TYPES } from './ast-node-types'; -import { AST_TOKEN_TYPES } from './ast-token-types'; +import * as TSESTree from './ast-spec'; -export interface LineAndColumnData { - /** - * Line number (1-indexed) - */ - line: number; - /** - * Column number on the line (0-indexed) - */ - column: number; -} -export interface SourceLocation { - /** - * The position of the first character of the parsed source region - */ - start: LineAndColumnData; - /** - * The position of the first character after the parsed source region - */ - end: LineAndColumnData; -} -export type Range = [number, number]; - -export interface BaseNode { - /** - * The source location information of the node. - */ - loc: SourceLocation; - /** - * An array of two numbers. - * Both numbers are a 0-based index which is the position in the array of source code characters. - * The first is the start position of the node, the second is the end position of the node. - */ - range: Range; - /** - * The parent node of the current node - */ - parent?: Node; - - // every node *will* have a type, but let the nodes define their own exact string - // type: string; - - // we don't ever set this from within ts-estree - // source?: string | null; -} - -/* - * Token and Comment are pseudo-nodes to represent pieces of source code - * - * NOTE: - * They are not included in the `Node` union below on purpose because they - * are not ever included as part of the standard AST tree. - */ -interface BaseToken extends BaseNode { - value: string; -} - -export interface BooleanToken extends BaseToken { - type: AST_TOKEN_TYPES.Boolean; -} - -export interface IdentifierToken extends BaseToken { - type: AST_TOKEN_TYPES.Identifier; -} - -export interface JSXIdentifierToken extends BaseToken { - type: AST_TOKEN_TYPES.JSXIdentifier; -} - -export interface JSXTextToken extends BaseToken { - type: AST_TOKEN_TYPES.JSXText; -} - -export interface KeywordToken extends BaseToken { - type: AST_TOKEN_TYPES.Keyword; -} - -export interface NullToken extends BaseToken { - type: AST_TOKEN_TYPES.Null; -} - -export interface NumericToken extends BaseToken { - type: AST_TOKEN_TYPES.Numeric; -} - -export interface PunctuatorToken extends BaseToken { - type: AST_TOKEN_TYPES.Punctuator; -} - -export interface RegularExpressionToken extends BaseToken { - type: AST_TOKEN_TYPES.RegularExpression; - regex: { - pattern: string; - flags: string; - }; -} - -export interface StringToken extends BaseToken { - type: AST_TOKEN_TYPES.String; -} - -export interface TemplateToken extends BaseToken { - type: AST_TOKEN_TYPES.Template; -} - -export interface BlockComment extends BaseToken { - type: AST_TOKEN_TYPES.Block; -} - -export interface LineComment extends BaseToken { - type: AST_TOKEN_TYPES.Line; -} - -export type Comment = BlockComment | LineComment; -export type Token = - | BooleanToken - | Comment - | IdentifierToken - | JSXIdentifierToken - | JSXTextToken - | KeywordToken - | NullToken - | NumericToken - | PunctuatorToken - | RegularExpressionToken - | StringToken - | TemplateToken; - -export type OptionalRangeAndLoc = Pick< - T, - Exclude -> & { - range?: Range; - loc?: SourceLocation; -}; - -// Every single valid AST Node -// Please keep it sorted alphabetically. -export type Node = - | ArrayExpression - | ArrayPattern - | ArrowFunctionExpression - | AssignmentExpression - | AssignmentPattern - | AwaitExpression - | BigIntLiteral - | BinaryExpression - | BlockStatement - | BreakStatement - | CallExpression - | CatchClause - | ChainExpression - | ClassBody - | ClassDeclaration - | ClassExpression - | ClassProperty - | ConditionalExpression - | ContinueStatement - | DebuggerStatement - | Decorator - | DoWhileStatement - | EmptyStatement - | ExportAllDeclaration - | ExportDefaultDeclaration - | ExportNamedDeclaration - | ExportSpecifier - | ExpressionStatement - | ForInStatement - | ForOfStatement - | ForStatement - | FunctionDeclaration - | FunctionExpression - | Identifier - | IfStatement - | ImportDeclaration - | ImportDefaultSpecifier - | ImportExpression - | ImportNamespaceSpecifier - | ImportSpecifier - | JSXAttribute - | JSXClosingElement - | JSXClosingFragment - | JSXElement - | JSXEmptyExpression - | JSXExpressionContainer - | JSXFragment - | JSXIdentifier - | JSXMemberExpression - | JSXNamespacedName - | JSXOpeningElement - | JSXOpeningFragment - | JSXSpreadAttribute - | JSXSpreadChild - | JSXText - | LabeledStatement - | Literal - | LogicalExpression - | MemberExpression - | MetaProperty - | MethodDefinition - | NewExpression - | ObjectExpression - | ObjectPattern - | Program - | Property - | RestElement - | ReturnStatement - | SequenceExpression - | SpreadElement - | Super - | SwitchCase - | SwitchStatement - | TaggedTemplateExpression - | TemplateElement - | TemplateLiteral - | ThisExpression - | ThrowStatement - | TryStatement - | TSAbstractClassProperty - | TSAbstractKeyword - | TSAbstractMethodDefinition - | TSAnyKeyword - | TSArrayType - | TSAsExpression - | TSAsyncKeyword - | TSBigIntKeyword - | TSBooleanKeyword - | TSCallSignatureDeclaration - | TSClassImplements - | TSConditionalType - | TSConstructorType - | TSConstructSignatureDeclaration - | TSDeclareFunction - | TSDeclareKeyword - | TSEmptyBodyFunctionExpression - | TSEnumDeclaration - | TSEnumMember - | TSExportAssignment - | TSExportKeyword - | TSExternalModuleReference - | TSFunctionType - | TSImportEqualsDeclaration - | TSImportType - | TSIndexedAccessType - | TSIndexSignature - | TSInferType - | TSInterfaceBody - | TSInterfaceDeclaration - | TSInterfaceHeritage - | TSIntersectionType - | TSIntrinsicKeyword - | TSLiteralType - | TSMappedType - | TSMethodSignature - | TSModuleBlock - | TSModuleDeclaration - | TSNamedTupleMember - | TSNamespaceExportDeclaration - | TSNeverKeyword - | TSNonNullExpression - | TSNullKeyword - | TSNumberKeyword - | TSObjectKeyword - | TSOptionalType - | TSParameterProperty - | TSParenthesizedType - | TSPrivateKeyword - | TSPropertySignature - | TSProtectedKeyword - | TSPublicKeyword - | TSQualifiedName - | TSReadonlyKeyword - | TSRestType - | TSStaticKeyword - | TSStringKeyword - | TSSymbolKeyword - | TSTemplateLiteralType - | TSThisType - | TSTupleType - | TSTypeAliasDeclaration - | TSTypeAnnotation - | TSTypeAssertion - | TSTypeLiteral - | TSTypeOperator - | TSTypeParameter - | TSTypeParameterDeclaration - | TSTypeParameterInstantiation - | TSTypePredicate - | TSTypeQuery - | TSTypeReference - | TSUndefinedKeyword - | TSUnionType - | TSUnknownKeyword - | TSVoidKeyword - | UnaryExpression - | UpdateExpression - | VariableDeclaration - | VariableDeclarator - | WhileStatement - | WithStatement - | YieldExpression; - -////////// -// Reusable Unions -// These are based off of types used in the Typescript AST definitions -// **Ensure you sort the union members alphabetically** -////////// - -export type Accessibility = 'public' | 'protected' | 'private'; -export type BindingPattern = ArrayPattern | ObjectPattern; -export type BindingName = BindingPattern | Identifier; -export type ChainElement = - | CallExpression - | MemberExpression - | TSNonNullExpression; -export type ClassElement = - | ClassProperty - | MethodDefinition - | TSAbstractClassProperty - | TSAbstractMethodDefinition - | TSIndexSignature; -export type ClassProperty = - | ClassPropertyComputedName - | ClassPropertyNonComputedName; -export type DeclarationStatement = - | ClassDeclaration - | ClassExpression - | ExportDefaultDeclaration - | ExportAllDeclaration - | ExportNamedDeclaration - | FunctionDeclaration - | TSDeclareFunction - | TSImportEqualsDeclaration - | TSInterfaceDeclaration - | TSModuleDeclaration - | TSNamespaceExportDeclaration - | TSTypeAliasDeclaration - | TSEnumDeclaration; -export type DestructuringPattern = - | Identifier - | ObjectPattern - | ArrayPattern - | RestElement - | AssignmentPattern - | MemberExpression; -export type EntityName = Identifier | TSQualifiedName; -export type ExportDeclaration = - | ClassDeclaration - | ClassExpression - | FunctionDeclaration - | TSDeclareFunction - | TSEnumDeclaration - | TSInterfaceDeclaration - | TSModuleDeclaration - | TSTypeAliasDeclaration - | VariableDeclaration; -export type Expression = - | ArrowFunctionExpression - | AssignmentExpression - | BinaryExpression - | ChainExpression - | ConditionalExpression - | ImportExpression - | JSXClosingElement - | JSXClosingFragment - | JSXExpressionContainer - | JSXOpeningElement - | JSXOpeningFragment - | JSXSpreadChild - | LogicalExpression - | NewExpression - | RestElement - | SequenceExpression - | SpreadElement - | TSAsExpression - | TSTypeAssertion - | TSUnaryExpression - | YieldExpression; -export type ForInitialiser = Expression | VariableDeclaration; -export type FunctionLike = - | ArrowFunctionExpression - | FunctionDeclaration - | FunctionExpression - | TSDeclareFunction - | TSEmptyBodyFunctionExpression; -export type ImportClause = - | ImportDefaultSpecifier - | ImportNamespaceSpecifier - | ImportSpecifier; -export type IterationStatement = - | DoWhileStatement - | ForInStatement - | ForOfStatement - | ForStatement - | WhileStatement; -export type JSXChild = JSXElement | JSXExpression | JSXFragment | JSXText; -export type JSXExpression = - | JSXEmptyExpression - | JSXSpreadChild - | JSXExpressionContainer; -export type JSXTagNameExpression = - | JSXIdentifier - | JSXMemberExpression - | JSXNamespacedName; -export type LeftHandSideExpression = - | CallExpression - | ClassExpression - | ClassDeclaration - | FunctionExpression - | LiteralExpression - | MemberExpression - | PrimaryExpression - | TaggedTemplateExpression - | TSNonNullExpression - | TSAsExpression - | ArrowFunctionExpression; -export type Literal = - | BigIntLiteral - | BooleanLiteral - | NumberLiteral - | NullLiteral - | RegExpLiteral - | StringLiteral; -export type LiteralExpression = Literal | TemplateLiteral; -export type MemberExpression = - | MemberExpressionComputedName - | MemberExpressionNonComputedName; -export type MethodDefinition = - | MethodDefinitionComputedName - | MethodDefinitionNonComputedName; -export type Modifier = - | TSAbstractKeyword - | TSAsyncKeyword - | TSPrivateKeyword - | TSProtectedKeyword - | TSPublicKeyword - | TSReadonlyKeyword - | TSStaticKeyword; -export type ObjectLiteralElementLike = - | MethodDefinition - | Property - | SpreadElement - | TSAbstractMethodDefinition; -export type Parameter = - | ArrayPattern - | AssignmentPattern - | Identifier - | ObjectPattern - | RestElement - | TSParameterProperty; -export type PrimaryExpression = - | ArrayExpression - | ArrayPattern - | ClassExpression - | FunctionExpression - | Identifier - | JSXElement - | JSXFragment - | JSXOpeningElement - | Literal - | LiteralExpression - | MetaProperty - | ObjectExpression - | ObjectPattern - | Super - | TemplateLiteral - | ThisExpression - | TSNullKeyword; -/** TODO: re-align this with EStree spec in next major release */ -export type ProgramStatement = Statement; -export type Property = PropertyComputedName | PropertyNonComputedName; -export type PropertyName = PropertyNameComputed | PropertyNameNonComputed; -export type PropertyNameComputed = Expression; -export type PropertyNameNonComputed = - | Identifier - | StringLiteral - | NumberLiteral; -export type Statement = - | BlockStatement - | BreakStatement - | ClassDeclaration - | ContinueStatement - | DebuggerStatement - | DeclarationStatement - | EmptyStatement - | ExportAllDeclaration - | ExportDefaultDeclaration - | ExportNamedDeclaration - | ExpressionStatement - | IfStatement - | IterationStatement - | ImportDeclaration - | LabeledStatement - | TSDeclareFunction - | TSEnumDeclaration - | TSExportAssignment - | TSImportEqualsDeclaration - | TSInterfaceDeclaration - | TSModuleBlock - | TSNamespaceExportDeclaration - | TSTypeAliasDeclaration - | ReturnStatement - | SwitchStatement - | ThrowStatement - | TryStatement - | VariableDeclaration - | WithStatement; -export type TSAbstractClassProperty = - | TSAbstractClassPropertyComputedName - | TSAbstractClassPropertyNonComputedName; -export type TSAbstractMethodDefinition = - | TSAbstractMethodDefinitionComputedName - | TSAbstractMethodDefinitionNonComputedName; -export type TSMethodSignature = - | TSMethodSignatureComputedName - | TSMethodSignatureNonComputedName; -export type TSPropertySignature = - | TSPropertySignatureComputedName - | TSPropertySignatureNonComputedName; -export type TSEnumMember = - | TSEnumMemberComputedName - | TSEnumMemberNonComputedName; -export type TSUnaryExpression = - | AwaitExpression - | LeftHandSideExpression - | TSTypeAssertion - | UnaryExpression - | UpdateExpression; -export type TypeElement = - | TSCallSignatureDeclaration - | TSConstructSignatureDeclaration - | TSIndexSignature - | TSMethodSignature - | TSPropertySignature; -export type TypeNode = - | TSAnyKeyword - | TSArrayType - | TSBigIntKeyword - | TSBooleanKeyword - | TSConditionalType - | TSConstructorType - | TSFunctionType - | TSImportType - | TSIndexedAccessType - | TSInferType - | TSInterfaceHeritage - | TSIntersectionType - | TSIntrinsicKeyword - | TSLiteralType - | TSMappedType - | TSNamedTupleMember - | TSNeverKeyword - | TSNullKeyword - | TSNumberKeyword - | TSObjectKeyword - | TSOptionalType - | TSParenthesizedType - | TSRestType - | TSStringKeyword - | TSSymbolKeyword - | TSTemplateLiteralType - | TSThisType - | TSTupleType - | TSTypeLiteral - | TSTypeOperator - | TSTypePredicate - | TSTypeQuery - | TSTypeReference - | TSUndefinedKeyword - | TSUnionType - | TSUnknownKeyword - | TSVoidKeyword; - -/////////////// -// Base, common types -// **Ensure you sort the interfaces alphabetically** -/////////////// - -interface BinaryExpressionBase extends BaseNode { - operator: string; - left: Expression; - right: Expression; -} - -interface CallExpressionBase extends BaseNode { - callee: LeftHandSideExpression; - arguments: Expression[]; - typeParameters?: TSTypeParameterInstantiation; - optional: boolean; -} - -interface ClassDeclarationBase extends BaseNode { - typeParameters?: TSTypeParameterDeclaration; - superTypeParameters?: TSTypeParameterInstantiation; - id: Identifier | null; - body: ClassBody; - superClass: LeftHandSideExpression | null; - implements?: TSClassImplements[]; - abstract?: boolean; - declare?: boolean; - decorators?: Decorator[]; -} - -/** this should not be directly used - instead use ClassPropertyComputedNameBase or ClassPropertyNonComputedNameBase */ -interface ClassPropertyBase extends BaseNode { - key: PropertyName; - value: Expression | null; - computed: boolean; - static: boolean; - declare: boolean; - readonly?: boolean; - decorators?: Decorator[]; - accessibility?: Accessibility; - optional?: boolean; - definite?: boolean; - typeAnnotation?: TSTypeAnnotation; -} - -interface ClassPropertyComputedNameBase extends ClassPropertyBase { - key: PropertyNameComputed; - computed: true; -} - -interface ClassPropertyNonComputedNameBase extends ClassPropertyBase { - key: PropertyNameNonComputed; - computed: false; -} - -interface FunctionDeclarationBase extends BaseNode { - id: Identifier | null; - generator: boolean; - expression: boolean; - async: boolean; - params: Parameter[]; - body?: BlockStatement | null; - returnType?: TSTypeAnnotation; - typeParameters?: TSTypeParameterDeclaration; - declare?: boolean; -} +// augment to add the parent property, which isn't part of the spec +declare module './ast-spec' { + interface BaseNode { + parent?: TSESTree.Node; + } -interface FunctionSignatureBase extends BaseNode { - params: Parameter[]; - returnType?: TSTypeAnnotation; - typeParameters?: TSTypeParameterDeclaration; -} - -interface LiteralBase extends BaseNode { - raw: string; - value: string | boolean | null | number | RegExp | bigint; - regex?: { - pattern: string; - flags: string; - }; -} - -/** this should not be directly used - instead use MemberExpressionComputedNameBase or MemberExpressionNonComputedNameBase */ -interface MemberExpressionBase extends BaseNode { - object: LeftHandSideExpression; - property: Expression | Identifier; - computed: boolean; - optional: boolean; -} - -interface MemberExpressionComputedNameBase extends MemberExpressionBase { - property: Expression; - computed: true; -} - -interface MemberExpressionNonComputedNameBase extends MemberExpressionBase { - property: Identifier; - computed: false; -} - -/** this should not be directly used - instead use MethodDefinitionComputedNameBase or MethodDefinitionNonComputedNameBase */ -interface MethodDefinitionBase extends BaseNode { - key: PropertyName; - value: FunctionExpression | TSEmptyBodyFunctionExpression; - computed: boolean; - static: boolean; - kind: 'method' | 'get' | 'set' | 'constructor'; - optional?: boolean; - decorators?: Decorator[]; - accessibility?: Accessibility; - typeParameters?: TSTypeParameterDeclaration; -} - -interface MethodDefinitionComputedNameBase extends MethodDefinitionBase { - key: PropertyNameComputed; - computed: true; -} - -interface MethodDefinitionNonComputedNameBase extends MethodDefinitionBase { - key: PropertyNameNonComputed; - computed: false; -} - -interface PropertyBase extends BaseNode { - type: AST_NODE_TYPES.Property; - key: PropertyName; - value: - | Expression - | AssignmentPattern - | BindingName - | TSEmptyBodyFunctionExpression; - computed: boolean; - method: boolean; - shorthand: boolean; - optional?: boolean; - kind: 'init' | 'get' | 'set'; -} - -interface TSEnumMemberBase extends BaseNode { - type: AST_NODE_TYPES.TSEnumMember; - id: - | PropertyNameNonComputed - // this should only happen in semantically invalid code (ts error 1164) - | PropertyNameComputed; - initializer?: Expression; - computed?: boolean; -} - -interface TSHeritageBase extends BaseNode { - expression: Expression; - typeParameters?: TSTypeParameterInstantiation; -} - -interface TSMethodSignatureBase extends BaseNode { - type: AST_NODE_TYPES.TSMethodSignature; - key: PropertyName; - computed: boolean; - params: Parameter[]; - optional?: boolean; - returnType?: TSTypeAnnotation; - readonly?: boolean; - typeParameters?: TSTypeParameterDeclaration; - accessibility?: Accessibility; - export?: boolean; - static?: boolean; -} - -interface TSPropertySignatureBase extends BaseNode { - type: AST_NODE_TYPES.TSPropertySignature; - key: PropertyName; - optional?: boolean; - computed: boolean; - typeAnnotation?: TSTypeAnnotation; - initializer?: Expression; - readonly?: boolean; - static?: boolean; - export?: boolean; - accessibility?: Accessibility; -} - -interface UnaryExpressionBase extends BaseNode { - operator: string; - prefix: boolean; - argument: LeftHandSideExpression | Literal | UnaryExpression; -} - -/////////////// -// Typescript ESTree Nodes -// **Ensure you sort the interfaces alphabetically** -/////////////// - -export interface ArrayExpression extends BaseNode { - type: AST_NODE_TYPES.ArrayExpression; - elements: Expression[]; -} - -export interface ArrayPattern extends BaseNode { - type: AST_NODE_TYPES.ArrayPattern; - elements: (DestructuringPattern | null)[]; - typeAnnotation?: TSTypeAnnotation; - optional?: boolean; - decorators?: Decorator[]; -} - -export interface ArrowFunctionExpression extends BaseNode { - type: AST_NODE_TYPES.ArrowFunctionExpression; - generator: boolean; - id: null; - params: Parameter[]; - body: Expression | BlockStatement; - async: boolean; - expression: boolean; - returnType?: TSTypeAnnotation; - typeParameters?: TSTypeParameterDeclaration; -} - -export interface AssignmentExpression extends BinaryExpressionBase { - type: AST_NODE_TYPES.AssignmentExpression; - operator: - | '-=' - | '??=' - | '**=' - | '*=' - | '/=' - | '&&=' - | '&=' - | '%=' - | '^=' - | '+=' - | '<<=' - | '=' - | '>>=' - | '>>>=' - | '|=' - | '||='; -} - -export interface AssignmentPattern extends BaseNode { - type: AST_NODE_TYPES.AssignmentPattern; - left: BindingName; - right: Expression; - typeAnnotation?: TSTypeAnnotation; - optional?: boolean; - decorators?: Decorator[]; -} - -export interface AwaitExpression extends BaseNode { - type: AST_NODE_TYPES.AwaitExpression; - argument: TSUnaryExpression; -} - -export interface BigIntLiteral extends LiteralBase { - type: AST_NODE_TYPES.Literal; - value: bigint | null; - bigint: string; -} - -export interface BinaryExpression extends BinaryExpressionBase { - type: AST_NODE_TYPES.BinaryExpression; -} - -export interface BlockStatement extends BaseNode { - type: AST_NODE_TYPES.BlockStatement; - body: Statement[]; -} - -export interface BooleanLiteral extends LiteralBase { - type: AST_NODE_TYPES.Literal; - value: boolean; -} - -export interface BreakStatement extends BaseNode { - type: AST_NODE_TYPES.BreakStatement; - label: Identifier | null; -} - -export interface ChainExpression extends BaseNode { - type: AST_NODE_TYPES.ChainExpression; - expression: ChainElement; -} - -export interface CallExpression extends CallExpressionBase { - type: AST_NODE_TYPES.CallExpression; -} + // TODO - make this change as a breaking change + /* + interface BaseNode { + parent: TSESTree.Node; + } -export interface CatchClause extends BaseNode { - type: AST_NODE_TYPES.CatchClause; - param: BindingName | null; - body: BlockStatement; + interface Program { + parent?: undefined; + } + */ } -export interface ClassBody extends BaseNode { - type: AST_NODE_TYPES.ClassBody; - body: ClassElement[]; -} - -export interface ClassDeclaration extends ClassDeclarationBase { - type: AST_NODE_TYPES.ClassDeclaration; -} - -export interface ClassExpression extends ClassDeclarationBase { - type: AST_NODE_TYPES.ClassExpression; -} - -export interface ClassPropertyComputedName - extends ClassPropertyComputedNameBase { - type: AST_NODE_TYPES.ClassProperty; -} - -export interface ClassPropertyNonComputedName - extends ClassPropertyNonComputedNameBase { - type: AST_NODE_TYPES.ClassProperty; -} - -export interface ConditionalExpression extends BaseNode { - type: AST_NODE_TYPES.ConditionalExpression; - test: Expression; - consequent: Expression; - alternate: Expression; -} - -export interface ContinueStatement extends BaseNode { - type: AST_NODE_TYPES.ContinueStatement; - label: Identifier | null; -} - -export interface DebuggerStatement extends BaseNode { - type: AST_NODE_TYPES.DebuggerStatement; -} - -export interface Decorator extends BaseNode { - type: AST_NODE_TYPES.Decorator; - expression: LeftHandSideExpression; -} - -export interface DoWhileStatement extends BaseNode { - type: AST_NODE_TYPES.DoWhileStatement; - test: Expression; - body: Statement; -} - -export interface EmptyStatement extends BaseNode { - type: AST_NODE_TYPES.EmptyStatement; -} - -export interface ExportAllDeclaration extends BaseNode { - type: AST_NODE_TYPES.ExportAllDeclaration; - source: Expression | null; - exportKind: 'type' | 'value'; - exported: Identifier | null; -} - -export interface ExportDefaultDeclaration extends BaseNode { - type: AST_NODE_TYPES.ExportDefaultDeclaration; - declaration: ExportDeclaration | Expression; - exportKind: 'type' | 'value'; -} - -export interface ExportNamedDeclaration extends BaseNode { - type: AST_NODE_TYPES.ExportNamedDeclaration; - declaration: ExportDeclaration | null; - specifiers: ExportSpecifier[]; - source: Expression | null; - exportKind: 'type' | 'value'; -} - -export interface ExportSpecifier extends BaseNode { - type: AST_NODE_TYPES.ExportSpecifier; - local: Identifier; - exported: Identifier; -} - -export interface ExpressionStatement extends BaseNode { - type: AST_NODE_TYPES.ExpressionStatement; - expression: Expression; - directive?: string; -} - -export interface ForInStatement extends BaseNode { - type: AST_NODE_TYPES.ForInStatement; - left: ForInitialiser; - right: Expression; - body: Statement; -} - -export interface ForOfStatement extends BaseNode { - type: AST_NODE_TYPES.ForOfStatement; - left: ForInitialiser; - right: Expression; - body: Statement; - await: boolean; -} - -export interface ForStatement extends BaseNode { - type: AST_NODE_TYPES.ForStatement; - init: Expression | ForInitialiser | null; - test: Expression | null; - update: Expression | null; - body: Statement; -} - -export interface FunctionDeclaration extends FunctionDeclarationBase { - type: AST_NODE_TYPES.FunctionDeclaration; - body: BlockStatement; -} - -export interface FunctionExpression extends FunctionDeclarationBase { - type: AST_NODE_TYPES.FunctionExpression; - body: BlockStatement; -} - -export interface Identifier extends BaseNode { - type: AST_NODE_TYPES.Identifier; - name: string; - typeAnnotation?: TSTypeAnnotation; - optional?: boolean; - decorators?: Decorator[]; -} - -export interface IfStatement extends BaseNode { - type: AST_NODE_TYPES.IfStatement; - test: Expression; - consequent: Statement; - alternate: Statement | null; -} - -export interface ImportDeclaration extends BaseNode { - type: AST_NODE_TYPES.ImportDeclaration; - source: Literal; - specifiers: ImportClause[]; - importKind: 'type' | 'value'; -} - -export interface ImportDefaultSpecifier extends BaseNode { - type: AST_NODE_TYPES.ImportDefaultSpecifier; - local: Identifier; -} - -export interface ImportExpression extends BaseNode { - type: AST_NODE_TYPES.ImportExpression; - source: Expression; -} - -export interface ImportNamespaceSpecifier extends BaseNode { - type: AST_NODE_TYPES.ImportNamespaceSpecifier; - local: Identifier; -} - -export interface ImportSpecifier extends BaseNode { - type: AST_NODE_TYPES.ImportSpecifier; - local: Identifier; - imported: Identifier; -} - -export interface JSXAttribute extends BaseNode { - type: AST_NODE_TYPES.JSXAttribute; - name: JSXIdentifier | JSXNamespacedName; - value: Literal | JSXExpression | null; -} - -export interface JSXClosingElement extends BaseNode { - type: AST_NODE_TYPES.JSXClosingElement; - name: JSXTagNameExpression; -} - -export interface JSXClosingFragment extends BaseNode { - type: AST_NODE_TYPES.JSXClosingFragment; -} - -export interface JSXElement extends BaseNode { - type: AST_NODE_TYPES.JSXElement; - openingElement: JSXOpeningElement; - closingElement: JSXClosingElement | null; - children: JSXChild[]; -} - -export interface JSXEmptyExpression extends BaseNode { - type: AST_NODE_TYPES.JSXEmptyExpression; -} - -export interface JSXExpressionContainer extends BaseNode { - type: AST_NODE_TYPES.JSXExpressionContainer; - expression: Expression | JSXEmptyExpression; -} - -export interface JSXFragment extends BaseNode { - type: AST_NODE_TYPES.JSXFragment; - openingFragment: JSXOpeningFragment; - closingFragment: JSXClosingFragment; - children: JSXChild[]; -} - -export interface JSXIdentifier extends BaseNode { - type: AST_NODE_TYPES.JSXIdentifier; - name: string; -} - -export interface JSXMemberExpression extends BaseNode { - type: AST_NODE_TYPES.JSXMemberExpression; - object: JSXTagNameExpression; - property: JSXIdentifier; -} - -export interface JSXNamespacedName extends BaseNode { - type: AST_NODE_TYPES.JSXNamespacedName; - namespace: JSXIdentifier; - name: JSXIdentifier; -} - -export interface JSXOpeningElement extends BaseNode { - type: AST_NODE_TYPES.JSXOpeningElement; - typeParameters?: TSTypeParameterInstantiation; - selfClosing: boolean; - name: JSXTagNameExpression; - attributes: (JSXAttribute | JSXSpreadAttribute)[]; -} - -export interface JSXOpeningFragment extends BaseNode { - type: AST_NODE_TYPES.JSXOpeningFragment; -} - -export interface JSXSpreadAttribute extends BaseNode { - type: AST_NODE_TYPES.JSXSpreadAttribute; - argument: Expression; -} - -export interface JSXSpreadChild extends BaseNode { - type: AST_NODE_TYPES.JSXSpreadChild; - expression: Expression | JSXEmptyExpression; -} - -export interface JSXText extends BaseNode { - type: AST_NODE_TYPES.JSXText; - value: string; - raw: string; -} - -export interface LabeledStatement extends BaseNode { - type: AST_NODE_TYPES.LabeledStatement; - label: Identifier; - body: Statement; -} - -export interface LogicalExpression extends BinaryExpressionBase { - type: AST_NODE_TYPES.LogicalExpression; -} - -export interface MemberExpressionComputedName - extends MemberExpressionComputedNameBase { - type: AST_NODE_TYPES.MemberExpression; -} - -export interface MemberExpressionNonComputedName - extends MemberExpressionNonComputedNameBase { - type: AST_NODE_TYPES.MemberExpression; -} - -export interface MetaProperty extends BaseNode { - type: AST_NODE_TYPES.MetaProperty; - meta: Identifier; - property: Identifier; -} - -export interface MethodDefinitionComputedName - extends MethodDefinitionComputedNameBase { - type: AST_NODE_TYPES.MethodDefinition; -} - -export interface MethodDefinitionNonComputedName - extends MethodDefinitionNonComputedNameBase { - type: AST_NODE_TYPES.MethodDefinition; -} - -export interface NewExpression extends BaseNode { - type: AST_NODE_TYPES.NewExpression; - callee: LeftHandSideExpression; - arguments: Expression[]; - typeParameters?: TSTypeParameterInstantiation; -} - -export interface NumberLiteral extends LiteralBase { - type: AST_NODE_TYPES.Literal; - value: number; -} - -export interface NullLiteral extends LiteralBase { - type: AST_NODE_TYPES.Literal; - value: null; -} - -export interface ObjectExpression extends BaseNode { - type: AST_NODE_TYPES.ObjectExpression; - properties: ObjectLiteralElementLike[]; -} - -export interface ObjectPattern extends BaseNode { - type: AST_NODE_TYPES.ObjectPattern; - properties: (Property | RestElement)[]; - typeAnnotation?: TSTypeAnnotation; - optional?: boolean; - decorators?: Decorator[]; -} - -export interface Program extends BaseNode { - type: AST_NODE_TYPES.Program; - body: Statement[]; - sourceType: 'module' | 'script'; - comments?: Comment[]; - tokens?: Token[]; -} - -export interface PropertyComputedName extends PropertyBase { - key: PropertyNameComputed; - computed: true; -} - -export interface PropertyNonComputedName extends PropertyBase { - key: PropertyNameNonComputed; - computed: false; -} - -export interface RegExpLiteral extends LiteralBase { - type: AST_NODE_TYPES.Literal; - value: RegExp | null; -} - -export interface RestElement extends BaseNode { - type: AST_NODE_TYPES.RestElement; - argument: DestructuringPattern; - typeAnnotation?: TSTypeAnnotation; - optional?: boolean; - value?: AssignmentPattern; - decorators?: Decorator[]; -} - -export interface ReturnStatement extends BaseNode { - type: AST_NODE_TYPES.ReturnStatement; - argument: Expression | null; -} - -export interface SequenceExpression extends BaseNode { - type: AST_NODE_TYPES.SequenceExpression; - expressions: Expression[]; -} - -export interface SpreadElement extends BaseNode { - type: AST_NODE_TYPES.SpreadElement; - argument: Expression; -} - -export interface StringLiteral extends LiteralBase { - type: AST_NODE_TYPES.Literal; - value: string; -} - -export interface Super extends BaseNode { - type: AST_NODE_TYPES.Super; -} - -export interface SwitchCase extends BaseNode { - type: AST_NODE_TYPES.SwitchCase; - test: Expression | null; - consequent: Statement[]; -} - -export interface SwitchStatement extends BaseNode { - type: AST_NODE_TYPES.SwitchStatement; - discriminant: Expression; - cases: SwitchCase[]; -} - -export interface TaggedTemplateExpression extends BaseNode { - type: AST_NODE_TYPES.TaggedTemplateExpression; - typeParameters?: TSTypeParameterInstantiation; - tag: LeftHandSideExpression; - quasi: TemplateLiteral; -} - -export interface TemplateElement extends BaseNode { - type: AST_NODE_TYPES.TemplateElement; - value: { - raw: string; - cooked: string; - }; - tail: boolean; -} - -export interface TemplateLiteral extends BaseNode { - type: AST_NODE_TYPES.TemplateLiteral; - quasis: TemplateElement[]; - expressions: Expression[]; -} - -export interface ThisExpression extends BaseNode { - type: AST_NODE_TYPES.ThisExpression; -} - -export interface ThrowStatement extends BaseNode { - type: AST_NODE_TYPES.ThrowStatement; - argument: Statement | TSAsExpression | null; -} - -export interface TryStatement extends BaseNode { - type: AST_NODE_TYPES.TryStatement; - block: BlockStatement; - handler: CatchClause | null; - finalizer: BlockStatement | null; -} - -export interface TSAbstractClassPropertyComputedName - extends ClassPropertyComputedNameBase { - type: AST_NODE_TYPES.TSAbstractClassProperty; -} - -export interface TSAbstractClassPropertyNonComputedName - extends ClassPropertyNonComputedNameBase { - type: AST_NODE_TYPES.TSAbstractClassProperty; -} - -export interface TSAbstractKeyword extends BaseNode { - type: AST_NODE_TYPES.TSAbstractKeyword; -} - -export interface TSAbstractMethodDefinitionComputedName - extends MethodDefinitionComputedNameBase { - type: AST_NODE_TYPES.TSAbstractMethodDefinition; -} - -export interface TSAbstractMethodDefinitionNonComputedName - extends MethodDefinitionNonComputedNameBase { - type: AST_NODE_TYPES.TSAbstractMethodDefinition; -} - -export interface TSAnyKeyword extends BaseNode { - type: AST_NODE_TYPES.TSAnyKeyword; -} - -export interface TSArrayType extends BaseNode { - type: AST_NODE_TYPES.TSArrayType; - elementType: TypeNode; -} - -export interface TSAsExpression extends BaseNode { - type: AST_NODE_TYPES.TSAsExpression; - expression: Expression; - typeAnnotation: TypeNode; -} - -export interface TSAsyncKeyword extends BaseNode { - type: AST_NODE_TYPES.TSAsyncKeyword; -} - -export interface TSBigIntKeyword extends BaseNode { - type: AST_NODE_TYPES.TSBigIntKeyword; -} - -export interface TSBooleanKeyword extends BaseNode { - type: AST_NODE_TYPES.TSBooleanKeyword; -} - -export interface TSCallSignatureDeclaration extends FunctionSignatureBase { - type: AST_NODE_TYPES.TSCallSignatureDeclaration; -} - -export interface TSClassImplements extends TSHeritageBase { - type: AST_NODE_TYPES.TSClassImplements; -} - -export interface TSConditionalType extends BaseNode { - type: AST_NODE_TYPES.TSConditionalType; - checkType: TypeNode; - extendsType: TypeNode; - trueType: TypeNode; - falseType: TypeNode; -} - -export interface TSConstructorType extends FunctionSignatureBase { - type: AST_NODE_TYPES.TSConstructorType; - abstract: boolean; -} - -export interface TSConstructSignatureDeclaration extends FunctionSignatureBase { - type: AST_NODE_TYPES.TSConstructSignatureDeclaration; -} - -export interface TSDeclareFunction extends FunctionDeclarationBase { - type: AST_NODE_TYPES.TSDeclareFunction; -} - -export interface TSDeclareKeyword extends BaseNode { - type: AST_NODE_TYPES.TSDeclareKeyword; -} - -export interface TSEmptyBodyFunctionExpression extends FunctionDeclarationBase { - type: AST_NODE_TYPES.TSEmptyBodyFunctionExpression; - body: null; -} - -export interface TSEnumDeclaration extends BaseNode { - type: AST_NODE_TYPES.TSEnumDeclaration; - id: Identifier; - members: TSEnumMember[]; - const?: boolean; - declare?: boolean; - modifiers?: Modifier[]; -} - -/** - * this should only really happen in semantically invalid code (errors 1164 and 2452) - * - * VALID: - * enum Foo { ['a'] } - * - * INVALID: - * const x = 'a'; - * enum Foo { [x] } - * enum Bar { ['a' + 'b'] } - */ -export interface TSEnumMemberComputedName extends TSEnumMemberBase { - id: PropertyNameComputed; - computed: true; -} - -export interface TSEnumMemberNonComputedName extends TSEnumMemberBase { - id: PropertyNameNonComputed; - computed?: false; -} - -export interface TSExportAssignment extends BaseNode { - type: AST_NODE_TYPES.TSExportAssignment; - expression: Expression; -} - -export interface TSExportKeyword extends BaseNode { - type: AST_NODE_TYPES.TSExportKeyword; -} - -export interface TSExternalModuleReference extends BaseNode { - type: AST_NODE_TYPES.TSExternalModuleReference; - expression: Expression; -} - -export interface TSFunctionType extends FunctionSignatureBase { - type: AST_NODE_TYPES.TSFunctionType; -} - -export interface TSImportEqualsDeclaration extends BaseNode { - type: AST_NODE_TYPES.TSImportEqualsDeclaration; - id: Identifier; - moduleReference: EntityName | TSExternalModuleReference; - importKind: 'type' | 'value'; - isExport: boolean; -} - -export interface TSImportType extends BaseNode { - type: AST_NODE_TYPES.TSImportType; - isTypeOf: boolean; - parameter: TypeNode; - qualifier: EntityName | null; - typeParameters: TSTypeParameterInstantiation | null; -} - -export interface TSIndexedAccessType extends BaseNode { - type: AST_NODE_TYPES.TSIndexedAccessType; - objectType: TypeNode; - indexType: TypeNode; -} - -export interface TSIndexSignature extends BaseNode { - type: AST_NODE_TYPES.TSIndexSignature; - parameters: Parameter[]; - typeAnnotation?: TSTypeAnnotation; - readonly?: boolean; - accessibility?: Accessibility; - export?: boolean; - static?: boolean; -} - -export interface TSInferType extends BaseNode { - type: AST_NODE_TYPES.TSInferType; - typeParameter: TSTypeParameter; -} - -export interface TSInterfaceDeclaration extends BaseNode { - type: AST_NODE_TYPES.TSInterfaceDeclaration; - body: TSInterfaceBody; - id: Identifier; - typeParameters?: TSTypeParameterDeclaration; - extends?: TSInterfaceHeritage[]; - implements?: TSInterfaceHeritage[]; - abstract?: boolean; - declare?: boolean; -} - -export interface TSInterfaceBody extends BaseNode { - type: AST_NODE_TYPES.TSInterfaceBody; - body: TypeElement[]; -} - -export interface TSInterfaceHeritage extends TSHeritageBase { - type: AST_NODE_TYPES.TSInterfaceHeritage; -} - -export interface TSIntersectionType extends BaseNode { - type: AST_NODE_TYPES.TSIntersectionType; - types: TypeNode[]; -} - -export interface TSIntrinsicKeyword extends BaseNode { - type: AST_NODE_TYPES.TSIntrinsicKeyword; -} - -export interface TSLiteralType extends BaseNode { - type: AST_NODE_TYPES.TSLiteralType; - literal: LiteralExpression | UnaryExpression | UpdateExpression; -} - -export interface TSMappedType extends BaseNode { - type: AST_NODE_TYPES.TSMappedType; - typeParameter: TSTypeParameter; - readonly?: boolean | '-' | '+'; - optional?: boolean | '-' | '+'; - typeAnnotation?: TypeNode; - nameType: TypeNode | null; -} - -export interface TSMethodSignatureComputedName extends TSMethodSignatureBase { - key: PropertyNameComputed; - computed: true; -} - -export interface TSMethodSignatureNonComputedName - extends TSMethodSignatureBase { - key: PropertyNameNonComputed; - computed: false; -} - -export interface TSModuleBlock extends BaseNode { - type: AST_NODE_TYPES.TSModuleBlock; - body: Statement[]; -} - -export interface TSModuleDeclaration extends BaseNode { - type: AST_NODE_TYPES.TSModuleDeclaration; - id: Identifier | Literal; - body?: TSModuleBlock | TSModuleDeclaration; - global?: boolean; - declare?: boolean; - modifiers?: Modifier[]; -} - -export interface TSNamedTupleMember extends BaseNode { - type: AST_NODE_TYPES.TSNamedTupleMember; - elementType: TypeNode; - label: Identifier; - optional: boolean; -} - -export interface TSNamespaceExportDeclaration extends BaseNode { - type: AST_NODE_TYPES.TSNamespaceExportDeclaration; - id: Identifier; -} - -export interface TSNeverKeyword extends BaseNode { - type: AST_NODE_TYPES.TSNeverKeyword; -} - -export interface TSNonNullExpression extends BaseNode { - type: AST_NODE_TYPES.TSNonNullExpression; - expression: Expression; -} - -export interface TSNullKeyword extends BaseNode { - type: AST_NODE_TYPES.TSNullKeyword; -} - -export interface TSNumberKeyword extends BaseNode { - type: AST_NODE_TYPES.TSNumberKeyword; -} - -export interface TSObjectKeyword extends BaseNode { - type: AST_NODE_TYPES.TSObjectKeyword; -} - -export interface TSOptionalType extends BaseNode { - type: AST_NODE_TYPES.TSOptionalType; - typeAnnotation: TypeNode; -} - -export interface TSParameterProperty extends BaseNode { - type: AST_NODE_TYPES.TSParameterProperty; - accessibility?: Accessibility; - readonly?: boolean; - static?: boolean; - export?: boolean; - parameter: AssignmentPattern | BindingName | RestElement; - decorators?: Decorator[]; -} - -export interface TSParenthesizedType extends BaseNode { - type: AST_NODE_TYPES.TSParenthesizedType; - typeAnnotation: TypeNode; -} - -export interface TSPropertySignatureComputedName - extends TSPropertySignatureBase { - key: PropertyNameComputed; - computed: true; -} - -export interface TSPropertySignatureNonComputedName - extends TSPropertySignatureBase { - key: PropertyNameNonComputed; - computed: false; -} - -export interface TSPublicKeyword extends BaseNode { - type: AST_NODE_TYPES.TSPublicKeyword; -} - -export interface TSPrivateKeyword extends BaseNode { - type: AST_NODE_TYPES.TSPrivateKeyword; -} - -export interface TSProtectedKeyword extends BaseNode { - type: AST_NODE_TYPES.TSProtectedKeyword; -} - -export interface TSQualifiedName extends BaseNode { - type: AST_NODE_TYPES.TSQualifiedName; - left: EntityName; - right: Identifier; -} - -export interface TSReadonlyKeyword extends BaseNode { - type: AST_NODE_TYPES.TSReadonlyKeyword; -} - -export interface TSRestType extends BaseNode { - type: AST_NODE_TYPES.TSRestType; - typeAnnotation: TypeNode; -} - -export interface TSStaticKeyword extends BaseNode { - type: AST_NODE_TYPES.TSStaticKeyword; -} - -export interface TSStringKeyword extends BaseNode { - type: AST_NODE_TYPES.TSStringKeyword; -} - -export interface TSSymbolKeyword extends BaseNode { - type: AST_NODE_TYPES.TSSymbolKeyword; -} - -export interface TSTemplateLiteralType extends BaseNode { - type: AST_NODE_TYPES.TSTemplateLiteralType; - quasis: TemplateElement[]; - types: TypeNode[]; -} - -export interface TSThisType extends BaseNode { - type: AST_NODE_TYPES.TSThisType; -} - -export interface TSTupleType extends BaseNode { - type: AST_NODE_TYPES.TSTupleType; - elementTypes: TypeNode[]; -} - -export interface TSTypeAliasDeclaration extends BaseNode { - type: AST_NODE_TYPES.TSTypeAliasDeclaration; - id: Identifier; - typeAnnotation: TypeNode; - declare?: boolean; - typeParameters?: TSTypeParameterDeclaration; -} - -export interface TSTypeAnnotation extends BaseNode { - type: AST_NODE_TYPES.TSTypeAnnotation; - typeAnnotation: TypeNode; -} - -export interface TSTypeAssertion extends BaseNode { - type: AST_NODE_TYPES.TSTypeAssertion; - typeAnnotation: TypeNode; - expression: Expression; -} - -export interface TSTypeLiteral extends BaseNode { - type: AST_NODE_TYPES.TSTypeLiteral; - members: TypeElement[]; -} - -export interface TSTypeOperator extends BaseNode { - type: AST_NODE_TYPES.TSTypeOperator; - operator: 'keyof' | 'unique' | 'readonly'; - typeAnnotation?: TypeNode; -} - -export interface TSTypeParameter extends BaseNode { - type: AST_NODE_TYPES.TSTypeParameter; - name: Identifier; - constraint?: TypeNode; - default?: TypeNode; -} - -export interface TSTypeParameterDeclaration extends BaseNode { - type: AST_NODE_TYPES.TSTypeParameterDeclaration; - params: TSTypeParameter[]; -} - -export interface TSTypeParameterInstantiation extends BaseNode { - type: AST_NODE_TYPES.TSTypeParameterInstantiation; - params: TypeNode[]; -} - -export interface TSTypePredicate extends BaseNode { - type: AST_NODE_TYPES.TSTypePredicate; - asserts: boolean; - parameterName: Identifier | TSThisType; - typeAnnotation: TSTypeAnnotation | null; -} - -export interface TSTypeQuery extends BaseNode { - type: AST_NODE_TYPES.TSTypeQuery; - exprName: EntityName; -} - -export interface TSTypeReference extends BaseNode { - type: AST_NODE_TYPES.TSTypeReference; - typeName: EntityName; - typeParameters?: TSTypeParameterInstantiation; -} - -export interface TSUndefinedKeyword extends BaseNode { - type: AST_NODE_TYPES.TSUndefinedKeyword; -} - -export interface TSUnionType extends BaseNode { - type: AST_NODE_TYPES.TSUnionType; - types: TypeNode[]; -} - -export interface TSUnknownKeyword extends BaseNode { - type: AST_NODE_TYPES.TSUnknownKeyword; -} - -export interface TSVoidKeyword extends BaseNode { - type: AST_NODE_TYPES.TSVoidKeyword; -} - -export interface UpdateExpression extends UnaryExpressionBase { - type: AST_NODE_TYPES.UpdateExpression; - operator: '++' | '--'; -} - -export interface UnaryExpression extends UnaryExpressionBase { - type: AST_NODE_TYPES.UnaryExpression; - operator: '+' | '-' | '!' | '~' | 'delete' | 'void' | 'typeof'; -} - -export interface VariableDeclaration extends BaseNode { - type: AST_NODE_TYPES.VariableDeclaration; - // NOTE - this is not guaranteed to have any elements in it. i.e. `const;` - declarations: VariableDeclarator[]; - kind: 'let' | 'const' | 'var'; - declare?: boolean; -} - -export interface VariableDeclarator extends BaseNode { - type: AST_NODE_TYPES.VariableDeclarator; - id: BindingName; - init: Expression | null; - definite?: boolean; -} - -export interface WhileStatement extends BaseNode { - type: AST_NODE_TYPES.WhileStatement; - test: Expression; - body: Statement; -} - -export interface WithStatement extends BaseNode { - type: AST_NODE_TYPES.WithStatement; - object: Expression; - body: Statement; -} - -export interface YieldExpression extends BaseNode { - type: AST_NODE_TYPES.YieldExpression; - delegate: boolean; - argument?: Expression; -} +export * as TSESTree from './ast-spec'; diff --git a/packages/types/tools/copy-ast-spec.ts b/packages/types/tools/copy-ast-spec.ts new file mode 100644 index 000000000000..b02358ea0937 --- /dev/null +++ b/packages/types/tools/copy-ast-spec.ts @@ -0,0 +1,59 @@ +import chlidProcess from 'child_process'; +import fs from 'fs'; +import path from 'path'; +import { promisify } from 'util'; + +const readFile = promisify(fs.readFile); +const writeFile = promisify(fs.writeFile); +const execAsync = promisify(chlidProcess.exec); + +const AST_SPEC_PATH = path.resolve(__dirname, '../../ast-spec'); +const OUTPUT_PATH = path.join(path.resolve(__dirname, '../src/')); + +// ensure the package is built +chlidProcess.execSync('yarn build', { cwd: AST_SPEC_PATH }); + +const HEADER = `\ +/********************************************** + * DO NOT MODIFY THIS FILE MANUALLY * + * * + * THIS FILE HAS BEEN COPIED FROM ast-spec. * + * ANY CHANGES WILL BE LOST ON THE NEXT BUILD * + * * + * MAKE CHANGES TO ast-spec AND THEN RUN * + * yarn build * + **********************************************/ + +`; + +async function copyFile( + folderName: string, + fileName: string, + transformer: (code: string) => string = (s): string => s, +): Promise { + const code = await readFile( + path.join(AST_SPEC_PATH, folderName, fileName), + 'utf-8', + ); + + const transformedCode = transformer(code); + + const outpath = path.join(OUTPUT_PATH, fileName); + await writeFile(outpath, HEADER + transformedCode, { + encoding: 'utf-8', + }); + + await execAsync(`yarn prettier --write ${outpath}`); + + console.log('Copied', fileName); +} + +async function main(): Promise { + await Promise.all([ + copyFile('dist', 'ast-spec.ts', code => + code.replace(/export declare enum/g, 'export enum'), + ), + ]); +} + +main(); diff --git a/packages/types/tsconfig.build.json b/packages/types/tsconfig.build.json index 215a0282df2b..b9ac3e1b9770 100644 --- a/packages/types/tsconfig.build.json +++ b/packages/types/tsconfig.build.json @@ -6,5 +6,6 @@ "rootDir": "./src", "resolveJsonModule": true }, - "include": ["src", "typings"] + "include": ["src", "typings"], + "references": [] } diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json index 9cea515ba6b2..d1305674c8bb 100644 --- a/packages/types/tsconfig.json +++ b/packages/types/tsconfig.json @@ -4,5 +4,6 @@ "composite": false, "rootDir": "." }, - "include": ["src", "typings", "tests", "tools"] + "include": ["src", "typings", "tests", "tools"], + "references": [] } diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 4f65000f6bc6..61d6febc6d67 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -34,7 +34,7 @@ "build": "tsc -b tsconfig.build.json", "postbuild": "downlevel-dts dist _ts3.4/dist", "clean": "tsc -b tsconfig.build.json --clean", - "postclean": "rimraf dist", + "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", "lint": "eslint . --ext .js,.ts --ignore-path='../../.eslintignore'", "test": "jest --coverage", diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index e0c34e513ec9..aad29f9b1467 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -1987,7 +1987,7 @@ export class Converter { let regex = null; try { regex = new RegExp(pattern, flags); - } catch (exception) { + } catch (exception: unknown) { regex = null; } @@ -2166,7 +2166,7 @@ export class Converter { range: [start, end], }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: unescapeStringLiteralText(text), raw: text, diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index 594ca4ce55b1..e4a90301784d 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -31,7 +31,7 @@ "build": "tsc -b tsconfig.build.json", "postbuild": "downlevel-dts dist _ts3.4/dist", "clean": "tsc -b tsconfig.build.json --clean", - "postclean": "rimraf dist", + "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", "lint": "eslint . --ext .js,.ts --ignore-path='../../.eslintignore'", "test": "jest --coverage", diff --git a/tests/integration/docker-compose.yml b/tests/integration/docker-compose.yml index abe82a67cfb6..b1df8c206699 100644 --- a/tests/integration/docker-compose.yml +++ b/tests/integration/docker-compose.yml @@ -22,9 +22,11 @@ services: - ../../packages/types/:/usr/types - /usr/types/tests - ../../packages/visitor-keys/:/usr/visitor-keys - - /usr/types/visitor-keys + - /usr/visitor-keys/tests - ../../packages/scope-manager/:/usr/scope-manager - - /usr/types/scope-manager + - /usr/scope-manager/tests + - ../../packages/ast-spec/:/usr/ast-spec + - /usr/ast-spec/tests # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - ./fixtures/typescript-and-tslint-plugins-together:/usr/linked @@ -47,9 +49,11 @@ services: - ../../packages/types/:/usr/types - /usr/types/tests - ../../packages/visitor-keys/:/usr/visitor-keys - - /usr/types/visitor-keys + - /usr/visitor-keys/tests - ../../packages/scope-manager/:/usr/scope-manager - - /usr/types/scope-manager + - /usr/scope-manager/tests + - ../../packages/ast-spec/:/usr/ast-spec + - /usr/ast-spec/tests # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - ./fixtures/vue-sfc:/usr/linked @@ -72,9 +76,11 @@ services: - ../../packages/types/:/usr/types - /usr/types/tests - ../../packages/visitor-keys/:/usr/visitor-keys - - /usr/types/visitor-keys + - /usr/visitor-keys/tests - ../../packages/scope-manager/:/usr/scope-manager - - /usr/types/scope-manager + - /usr/scope-manager/tests + - ../../packages/ast-spec/:/usr/ast-spec + - /usr/ast-spec/tests # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - ./fixtures/vue-jsx:/usr/linked @@ -97,9 +103,11 @@ services: - ../../packages/types/:/usr/types - /usr/types/tests - ../../packages/visitor-keys/:/usr/visitor-keys - - /usr/types/visitor-keys + - /usr/visitor-keys/tests - ../../packages/scope-manager/:/usr/scope-manager - - /usr/types/scope-manager + - /usr/scope-manager/tests + - ../../packages/ast-spec/:/usr/ast-spec + - /usr/ast-spec/tests # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - ./fixtures/recommended-does-not-require-program:/usr/linked @@ -122,9 +130,11 @@ services: - ../../packages/types/:/usr/types - /usr/types/tests - ../../packages/visitor-keys/:/usr/visitor-keys - - /usr/types/visitor-keys + - /usr/visitor-keys/tests - ../../packages/scope-manager/:/usr/scope-manager - - /usr/types/scope-manager + - /usr/scope-manager/tests + - ../../packages/ast-spec/:/usr/ast-spec + - /usr/ast-spec/tests # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - ./fixtures/markdown:/usr/linked @@ -147,8 +157,10 @@ services: - ../../packages/types/:/usr/types - /usr/types/tests - ../../packages/visitor-keys/:/usr/visitor-keys - - /usr/types/visitor-keys + - /usr/visitor-keys/tests - ../../packages/scope-manager/:/usr/scope-manager - - /usr/types/scope-manager + - /usr/scope-manager/tests + - ../../packages/ast-spec/:/usr/ast-spec + - /usr/ast-spec/tests # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - ./fixtures/eslint-v6:/usr/linked diff --git a/tests/integration/fixtures/eslint-v6/test.sh b/tests/integration/fixtures/eslint-v6/test.sh index ab184f9ceb15..e2c988854164 100755 --- a/tests/integration/fixtures/eslint-v6/test.sh +++ b/tests/integration/fixtures/eslint-v6/test.sh @@ -9,6 +9,7 @@ npm install npm install eslint@6.0.0 # Use the local volumes for our own packages +npm install $(npm pack /usr/ast-spec | tail -1) npm install $(npm pack /usr/types | tail -1) npm install $(npm pack /usr/visitor-keys | tail -1) npm install $(npm pack /usr/scope-manager | tail -1) diff --git a/tests/integration/fixtures/markdown/test.sh b/tests/integration/fixtures/markdown/test.sh index 30cd435eaac7..91e4c4f0a045 100755 --- a/tests/integration/fixtures/markdown/test.sh +++ b/tests/integration/fixtures/markdown/test.sh @@ -8,6 +8,7 @@ node /usr/utils/generate-package-json.js npm install # Use the local volumes for our own packages +npm install $(npm pack /usr/ast-spec | tail -1) npm install $(npm pack /usr/types | tail -1) npm install $(npm pack /usr/visitor-keys | tail -1) npm install $(npm pack /usr/scope-manager | tail -1) diff --git a/tests/integration/fixtures/recommended-does-not-require-program/test.sh b/tests/integration/fixtures/recommended-does-not-require-program/test.sh index cfe4d0e6d570..ea25b6d7292d 100755 --- a/tests/integration/fixtures/recommended-does-not-require-program/test.sh +++ b/tests/integration/fixtures/recommended-does-not-require-program/test.sh @@ -8,6 +8,7 @@ node /usr/utils/generate-package-json.js npm install # Use the local volumes for our own packages +npm install $(npm pack /usr/ast-spec | tail -1) npm install $(npm pack /usr/types | tail -1) npm install $(npm pack /usr/visitor-keys | tail -1) npm install $(npm pack /usr/scope-manager | tail -1) diff --git a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh b/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh index 6abbeb42aa61..27c243e38081 100755 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh +++ b/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh @@ -8,6 +8,7 @@ node /usr/utils/generate-package-json.js npm install # Use the local volumes for our own packages +npm install $(npm pack /usr/ast-spec | tail -1) npm install $(npm pack /usr/types | tail -1) npm install $(npm pack /usr/visitor-keys | tail -1) npm install $(npm pack /usr/scope-manager | tail -1) diff --git a/tests/integration/fixtures/vue-jsx/test.sh b/tests/integration/fixtures/vue-jsx/test.sh index 96376fb0f83c..fc41933a87ec 100755 --- a/tests/integration/fixtures/vue-jsx/test.sh +++ b/tests/integration/fixtures/vue-jsx/test.sh @@ -8,6 +8,7 @@ node /usr/utils/generate-package-json.js npm install # Use the local volumes for our own packages +npm install $(npm pack /usr/ast-spec | tail -1) npm install $(npm pack /usr/types | tail -1) npm install $(npm pack /usr/visitor-keys | tail -1) npm install $(npm pack /usr/scope-manager | tail -1) diff --git a/tests/integration/fixtures/vue-sfc/test.sh b/tests/integration/fixtures/vue-sfc/test.sh index 80f7cfe4adf4..e22a51a62c62 100755 --- a/tests/integration/fixtures/vue-sfc/test.sh +++ b/tests/integration/fixtures/vue-sfc/test.sh @@ -8,6 +8,7 @@ node /usr/utils/generate-package-json.js npm install # Use the local volumes for our own packages +npm install $(npm pack /usr/ast-spec | tail -1) npm install $(npm pack /usr/types | tail -1) npm install $(npm pack /usr/visitor-keys | tail -1) npm install $(npm pack /usr/scope-manager | tail -1) diff --git a/yarn.lock b/yarn.lock index 6d63f30fdd4b..589b6e6b4e17 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1638,6 +1638,36 @@ npmlog "^4.1.2" write-file-atomic "^2.3.0" +"@microsoft/api-extractor-model@7.12.2": + version "7.12.2" + resolved "https://registry.yarnpkg.com/@microsoft/api-extractor-model/-/api-extractor-model-7.12.2.tgz#d48b35e8ed20643b1c19d7a4f80c90c42dc7d1d8" + integrity sha512-EU+U09Mj65zUH0qwPF4PFJiL6Y+PQQE/RRGEHEDGJJzab/mRQDpKOyrzSdb00xvcd/URehIHJqC55cY2Y4jGOA== + dependencies: + "@microsoft/tsdoc" "0.12.24" + "@rushstack/node-core-library" "3.36.0" + +"@microsoft/api-extractor@^7.13.2": + version "7.13.2" + resolved "https://registry.yarnpkg.com/@microsoft/api-extractor/-/api-extractor-7.13.2.tgz#c44762d27aee05c4da16c03fc8786bd0fa31c7eb" + integrity sha512-2fD0c8OxZW+e6NTaxbtrdNxXVuX7aqil3+cqig3pKsHymvUuRJVCEAcAJmZrJ/ENqYXNiB265EyqOT6VxbMysw== + dependencies: + "@microsoft/api-extractor-model" "7.12.2" + "@microsoft/tsdoc" "0.12.24" + "@rushstack/node-core-library" "3.36.0" + "@rushstack/rig-package" "0.2.10" + "@rushstack/ts-command-line" "4.7.8" + colors "~1.2.1" + lodash "~4.17.15" + resolve "~1.17.0" + semver "~7.3.0" + source-map "~0.6.1" + typescript "~4.1.3" + +"@microsoft/tsdoc@0.12.24": + version "0.12.24" + resolved "https://registry.yarnpkg.com/@microsoft/tsdoc/-/tsdoc-0.12.24.tgz#30728e34ebc90351dd3aff4e18d038eed2c3e098" + integrity sha512-Mfmij13RUTmHEMi9vRUhMXD7rnGR2VvxeNYtaGtaJ4redwwjT4UXYJ+nzmVJF7hhd4pn/Fx5sncDKxMVFJSWPg== + "@mrmlnc/readdir-enhanced@^2.2.1": version "2.2.1" resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde" @@ -1781,6 +1811,39 @@ dependencies: "@types/node" ">= 8" +"@rushstack/node-core-library@3.36.0": + version "3.36.0" + resolved "https://registry.yarnpkg.com/@rushstack/node-core-library/-/node-core-library-3.36.0.tgz#95dace39d763c8695d6607c421f95c6ac65b0ed4" + integrity sha512-bID2vzXpg8zweXdXgQkKToEdZwVrVCN9vE9viTRk58gqzYaTlz4fMId6V3ZfpXN6H0d319uGi2KDlm+lUEeqCg== + dependencies: + "@types/node" "10.17.13" + colors "~1.2.1" + fs-extra "~7.0.1" + import-lazy "~4.0.0" + jju "~1.4.0" + resolve "~1.17.0" + semver "~7.3.0" + timsort "~0.3.0" + z-schema "~3.18.3" + +"@rushstack/rig-package@0.2.10": + version "0.2.10" + resolved "https://registry.yarnpkg.com/@rushstack/rig-package/-/rig-package-0.2.10.tgz#e861eb94953d8c22c509dc3e9d91d6f337eab3cd" + integrity sha512-WXYerEJEPf8bS3ruqfM57NnwXtA7ehn8VJjLjrjls6eSduE5CRydcob/oBTzlHKsQ7N196XKlqQl9P6qIyYG2A== + dependencies: + resolve "~1.17.0" + strip-json-comments "~3.1.1" + +"@rushstack/ts-command-line@4.7.8": + version "4.7.8" + resolved "https://registry.yarnpkg.com/@rushstack/ts-command-line/-/ts-command-line-4.7.8.tgz#3aa77cf544c571be3206fc2bcba20c7a096ed254" + integrity sha512-8ghIWhkph7NnLCMDJtthpsb7TMOsVGXVDvmxjE/CeklTqjbbUFBjGXizJfpbEkRQTELuZQ2+vGn7sGwIWKN2uA== + dependencies: + "@types/argparse" "1.0.38" + argparse "~1.0.9" + colors "~1.2.1" + string-argv "~0.3.1" + "@sinonjs/commons@^1.7.0": version "1.8.2" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.2.tgz#858f5c4b48d80778fde4b9d541f27edc0d56488b" @@ -1795,6 +1858,11 @@ dependencies: "@sinonjs/commons" "^1.7.0" +"@types/argparse@1.0.38": + version "1.0.38" + resolved "https://registry.yarnpkg.com/@types/argparse/-/argparse-1.0.38.tgz#a81fd8606d481f873a3800c6ebae4f1d768a56a9" + integrity sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA== + "@types/babel__code-frame@*", "@types/babel__code-frame@^7.0.2": version "7.0.2" resolved "https://registry.yarnpkg.com/@types/babel__code-frame/-/babel__code-frame-7.0.2.tgz#e0c0f1648cbc09a9d4e5b4ed2ae9a6f7c8f5aeb0" @@ -1945,6 +2013,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.41.tgz#d0b939d94c1d7bd53d04824af45f1139b8c45615" integrity sha512-dueRKfaJL4RTtSa7bWeTK1M+VH+Gns73oCgzvYfHZywRCoPSd8EkXBL0mZ9unPTveBn+D9phZBaxuzpwjWkW0g== +"@types/node@10.17.13": + version "10.17.13" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.13.tgz#ccebcdb990bd6139cd16e84c39dc2fb1023ca90c" + integrity sha512-pMCcqU2zT4TjqYFrWtYHKal7Sl30Ims6ulZ4UFXxI4xbtQqK/qqKwkDoBFCfooRqqmRu9vY3xaJRwxSh673aYg== + "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" @@ -2206,7 +2279,7 @@ arg@^4.1.0: resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== -argparse@^1.0.7: +argparse@^1.0.7, argparse@~1.0.9: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== @@ -2861,6 +2934,11 @@ colorette@^1.2.1: resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.1.tgz#4d0b921325c14faf92633086a536db6e89564b1b" integrity sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw== +colors@~1.2.1: + version "1.2.5" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.2.5.tgz#89c7ad9a374bc030df8013241f68136ed8835afc" + integrity sha512-erNRLao/Y3Fv54qUa0LBB+//Uf3YwMUmdJinN20yMXm9zdKKqH9wt7R9IIVZ+K7ShzfpLV/Zg8+VyrBJYB4lpg== + columnify@^1.5.4: version "1.5.4" resolved "https://registry.yarnpkg.com/columnify/-/columnify-1.5.4.tgz#4737ddf1c7b69a8a7c340570782e947eec8e78bb" @@ -2876,7 +2954,7 @@ combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -commander@^2.12.1: +commander@^2.12.1, commander@^2.7.1: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== @@ -3762,6 +3840,11 @@ eslint-plugin-jest@^24.1.3: dependencies: "@typescript-eslint/experimental-utils" "^4.0.1" +eslint-plugin-simple-import-sort@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-7.0.0.tgz#a1dad262f46d2184a90095a60c66fef74727f0f8" + integrity sha512-U3vEDB5zhYPNfxT5TYR7u01dboFZp+HNpnGhkDB2g/2E4wZ/g1Q9Ton8UwCLfRV9yAKyYqDh62oHOamvkFxsvw== + eslint-scope@^5.0.0, eslint-scope@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" @@ -4241,6 +4324,15 @@ fs-extra@^9.0.0, fs-extra@^9.1.0: jsonfile "^6.0.1" universalify "^2.0.0" +fs-extra@~7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" + integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + fs-minipass@^1.2.5: version "1.2.7" resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" @@ -4776,6 +4868,11 @@ import-from@3.0.0: dependencies: resolve-from "^5.0.0" +import-lazy@~4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-4.0.0.tgz#e8eb627483a0a43da3c03f3e35548be5cb0cc153" + integrity sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw== + import-local@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/import-local/-/import-local-2.0.0.tgz#55070be38a5993cf18ef6db7e961f5bee5c5a09d" @@ -5619,6 +5716,11 @@ jest@^26.6.3: import-local "^3.0.2" jest-cli "^26.6.3" +jju@~1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/jju/-/jju-1.4.0.tgz#a3abe2718af241a2b2904f84a625970f389ae32a" + integrity sha1-o6vicYryQaKykE+EpiWXDzia4yo= + js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -5989,11 +6091,16 @@ lodash.flatten@~4.4.0: resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8= -lodash.get@^4.4.2: +lodash.get@^4.0.0, lodash.get@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk= +lodash.isequal@^4.0.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" + integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA= + lodash.ismatch@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37" @@ -6034,7 +6141,7 @@ lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= -lodash@4.x, lodash@^4.11.2, lodash@^4.17.12, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.2.1: +lodash@4.x, lodash@^4.11.2, lodash@^4.17.12, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.2.1, lodash@~4.17.15: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -7664,6 +7771,13 @@ resolve@^1.1.6, resolve@^1.10.0, resolve@^1.13.1, resolve@^1.17.0, resolve@^1.18 is-core-module "^2.1.0" path-parse "^1.0.6" +resolve@~1.17.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" + integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + dependencies: + path-parse "^1.0.6" + restore-cursor@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" @@ -7792,7 +7906,7 @@ semver-compare@^1.0.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@7.3.5, semver@7.x, semver@^7.2.1, semver@^7.3.2: +semver@7.3.5, semver@7.x, semver@^7.2.1, semver@^7.3.2, semver@~7.3.0: version "7.3.5" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== @@ -8111,7 +8225,7 @@ stream-shift@^1.0.0: resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.1.tgz#d7088281559ab2778424279b0877da3c392d5a3d" integrity sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ== -string-argv@0.3.1: +string-argv@0.3.1, string-argv@~0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da" integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg== @@ -8277,7 +8391,7 @@ strip-json-comments@3.0.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.0.1.tgz#85713975a91fb87bf1b305cca77395e40d2a64a7" integrity sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw== -strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: +strip-json-comments@^3.1.0, strip-json-comments@^3.1.1, strip-json-comments@~3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== @@ -8430,6 +8544,11 @@ through@2, "through@>=2.2.7 <3", through@^2.3.4, through@^2.3.6, through@^2.3.8: resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= +timsort@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4" + integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q= + tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -8681,7 +8800,7 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@*, typescript@4.2.2, "typescript@>=3.3.1 <4.3.0", typescript@^4.1.0-dev.20201026: +typescript@*, typescript@4.2.2, "typescript@>=3.3.1 <4.3.0", typescript@^4.1.0-dev.20201026, typescript@~4.1.3: version "4.2.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.2.tgz#1450f020618f872db0ea17317d16d8da8ddb8c4c" integrity sha512-tbb+NVrLfnsJy3M59lsDgrzWIflR4d4TIUjz+heUnHZwdF7YsrMTKoRERiIvI2lvBG95dfpLxB21WZhys1bgaQ== @@ -8845,6 +8964,11 @@ validate-npm-package-name@^3.0.0: dependencies: builtins "^1.0.3" +validator@^8.0.0: + version "8.2.0" + resolved "https://registry.yarnpkg.com/validator/-/validator-8.2.0.tgz#3c1237290e37092355344fef78c231249dab77b9" + integrity sha512-Yw5wW34fSv5spzTXNkokD6S6/Oq92d8q/t14TqsS3fAiA1RYnxSFSIZ+CY3n6PGGRCq5HhJTSepQvFUS2QUDxA== + verror@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" @@ -9185,3 +9309,14 @@ yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== + +z-schema@~3.18.3: + version "3.18.4" + resolved "https://registry.yarnpkg.com/z-schema/-/z-schema-3.18.4.tgz#ea8132b279533ee60be2485a02f7e3e42541a9a2" + integrity sha512-DUOKC/IhbkdLKKiV89gw9DUauTV8U/8yJl1sjf6MtDmzevLKOF2duNJ495S3MFVjqZarr+qNGCPbkg4mu4PpLw== + dependencies: + lodash.get "^4.0.0" + lodash.isequal "^4.0.0" + validator "^8.0.0" + optionalDependencies: + commander "^2.7.1"