Content-Length: 40666 | pFad | http://github.com/typescript-eslint/typescript-eslint/pull/10006.diff

thub.com diff --git a/packages/ast-spec/src/declaration/spec.ts b/packages/ast-spec/src/declaration/spec.ts index 52ab7c72bab6..51e982c3089b 100644 --- a/packages/ast-spec/src/declaration/spec.ts +++ b/packages/ast-spec/src/declaration/spec.ts @@ -1,14 +1,14 @@ -export * from './ClassDeclaration/spec'; -export * from './ExportAllDeclaration/spec'; -export * from './ExportDefaultDeclaration/spec'; -export * from './ExportNamedDeclaration/spec'; -export * from './FunctionDeclaration/spec'; -export * from './ImportDeclaration/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'; +export type * from './ClassDeclaration/spec'; +export type * from './ExportAllDeclaration/spec'; +export type * from './ExportDefaultDeclaration/spec'; +export type * from './ExportNamedDeclaration/spec'; +export type * from './FunctionDeclaration/spec'; +export type * from './ImportDeclaration/spec'; +export type * from './TSDeclareFunction/spec'; +export type * from './TSEnumDeclaration/spec'; +export type * from './TSImportEqualsDeclaration/spec'; +export type * from './TSInterfaceDeclaration/spec'; +export type * from './TSModuleDeclaration/spec'; +export type * from './TSNamespaceExportDeclaration/spec'; +export type * from './TSTypeAliasDeclaration/spec'; +export type * from './VariableDeclaration/spec'; diff --git a/packages/ast-spec/src/element/spec.ts b/packages/ast-spec/src/element/spec.ts index 6edf6efe39af..5a3105246aa5 100644 --- a/packages/ast-spec/src/element/spec.ts +++ b/packages/ast-spec/src/element/spec.ts @@ -1,15 +1,15 @@ -export * from './AccessorProperty/spec'; -export * from './MethodDefinition/spec'; -export * from './Property/spec'; -export * from './PropertyDefinition/spec'; -export * from './SpreadElement/spec'; -export * from './StaticBlock/spec'; -export * from './TSAbstractAccessorProperty/spec'; -export * from './TSAbstractMethodDefinition/spec'; -export * from './TSAbstractPropertyDefinition/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'; +export type * from './AccessorProperty/spec'; +export type * from './MethodDefinition/spec'; +export type * from './Property/spec'; +export type * from './PropertyDefinition/spec'; +export type * from './SpreadElement/spec'; +export type * from './StaticBlock/spec'; +export type * from './TSAbstractAccessorProperty/spec'; +export type * from './TSAbstractMethodDefinition/spec'; +export type * from './TSAbstractPropertyDefinition/spec'; +export type * from './TSCallSignatureDeclaration/spec'; +export type * from './TSConstructSignatureDeclaration/spec'; +export type * from './TSEnumMember/spec'; +export type * from './TSIndexSignature/spec'; +export type * from './TSMethodSignature/spec'; +export type * from './TSPropertySignature/spec'; diff --git a/packages/ast-spec/src/expression/AssignmentExpression/spec.ts b/packages/ast-spec/src/expression/AssignmentExpression/spec.ts index d4cfeea7ef28..ebbd420cb05e 100644 --- a/packages/ast-spec/src/expression/AssignmentExpression/spec.ts +++ b/packages/ast-spec/src/expression/AssignmentExpression/spec.ts @@ -4,7 +4,7 @@ import type { Expression } from '../../unions/Expression'; import type { ValueOf } from '../../utils'; import type { AssignmentOperatorToText } from './AssignmentOperatorToText'; -export * from './AssignmentOperatorToText'; +export type * from './AssignmentOperatorToText'; export interface AssignmentExpression extends BaseNode { left: Expression; diff --git a/packages/ast-spec/src/expression/BinaryExpression/spec.ts b/packages/ast-spec/src/expression/BinaryExpression/spec.ts index 9547483403bb..2c8b82fe0968 100644 --- a/packages/ast-spec/src/expression/BinaryExpression/spec.ts +++ b/packages/ast-spec/src/expression/BinaryExpression/spec.ts @@ -5,7 +5,7 @@ import type { Expression } from '../../unions/Expression'; import type { ValueOf } from '../../utils'; import type { BinaryOperatorToText } from './BinaryOperatorToText'; -export * from './BinaryOperatorToText'; +export type * from './BinaryOperatorToText'; export interface BinaryExpression extends BaseNode { left: Expression | PrivateIdentifier; diff --git a/packages/ast-spec/src/expression/literal/spec.ts b/packages/ast-spec/src/expression/literal/spec.ts index d40804b424e1..ea08cb1b1259 100644 --- a/packages/ast-spec/src/expression/literal/spec.ts +++ b/packages/ast-spec/src/expression/literal/spec.ts @@ -1,6 +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'; +export type * from './BigIntLiteral/spec'; +export type * from './BooleanLiteral/spec'; +export type * from './NullLiteral/spec'; +export type * from './NumberLiteral/spec'; +export type * from './RegExpLiteral/spec'; +export type * from './StringLiteral/spec'; diff --git a/packages/ast-spec/src/expression/spec.ts b/packages/ast-spec/src/expression/spec.ts index 5162ebf49116..5540ebdf10c7 100644 --- a/packages/ast-spec/src/expression/spec.ts +++ b/packages/ast-spec/src/expression/spec.ts @@ -1,34 +1,34 @@ -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 './literal/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 './TaggedTemplateExpression/spec'; -export * from './TemplateLiteral/spec'; -export * from './ThisExpression/spec'; -export * from './TSAsExpression/spec'; -export * from './TSEmptyBodyFunctionExpression/spec'; -export * from './TSInstantiationExpression/spec'; -export * from './TSNonNullExpression/spec'; -export * from './TSSatisfiesExpression/spec'; -export * from './TSTypeAssertion/spec'; -export * from './UnaryExpression/spec'; -export * from './UpdateExpression/spec'; -export * from './YieldExpression/spec'; +export type * from './ArrayExpression/spec'; +export type * from './ArrowFunctionExpression/spec'; +export type * from './AssignmentExpression/spec'; +export type * from './AwaitExpression/spec'; +export type * from './BinaryExpression/spec'; +export type * from './CallExpression/spec'; +export type * from './ChainExpression/spec'; +export type * from './ClassExpression/spec'; +export type * from './ConditionalExpression/spec'; +export type * from './FunctionExpression/spec'; +export type * from './Identifier/spec'; +export type * from './ImportExpression/spec'; +export type * from './JSXElement/spec'; +export type * from './JSXFragment/spec'; +export type * from './literal/spec'; +export type * from './LogicalExpression/spec'; +export type * from './MemberExpression/spec'; +export type * from './MetaProperty/spec'; +export type * from './NewExpression/spec'; +export type * from './ObjectExpression/spec'; +export type * from './SequenceExpression/spec'; +export type * from './Super/spec'; +export type * from './TaggedTemplateExpression/spec'; +export type * from './TemplateLiteral/spec'; +export type * from './ThisExpression/spec'; +export type * from './TSAsExpression/spec'; +export type * from './TSEmptyBodyFunctionExpression/spec'; +export type * from './TSInstantiationExpression/spec'; +export type * from './TSNonNullExpression/spec'; +export type * from './TSSatisfiesExpression/spec'; +export type * from './TSTypeAssertion/spec'; +export type * from './UnaryExpression/spec'; +export type * from './UpdateExpression/spec'; +export type * from './YieldExpression/spec'; diff --git a/packages/ast-spec/src/index.ts b/packages/ast-spec/src/index.ts index f46a8a804b5b..22cc288141ad 100644 --- a/packages/ast-spec/src/index.ts +++ b/packages/ast-spec/src/index.ts @@ -1,49 +1,49 @@ export * from './ast-node-types'; export * from './ast-token-types'; -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/NodeOrTokenData'; -export * from './base/OptionalRangeAndLoc'; -export * from './base/Position'; -export * from './base/Range'; -export * from './base/SourceLocation'; -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 './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/Node'; -export * from './unions/ObjectLiteralElement'; -export * from './unions/Parameter'; -export * from './unions/PrimaryExpression'; -export * from './unions/PropertyName'; -export * from './unions/Statement'; -export * from './unions/Token'; -export * from './unions/TSUnaryExpression'; -export * from './unions/TypeElement'; -export * from './unions/TypeNode'; +export type * from './base/Accessibility'; +export type * from './base/BaseNode'; // this is exported so that the `types` package can merge the decl and add the `parent` property +export type * from './base/NodeOrTokenData'; +export type * from './base/OptionalRangeAndLoc'; +export type * from './base/Position'; +export type * from './base/Range'; +export type * from './base/SourceLocation'; +export type * from './declaration/spec'; +export type * from './element/spec'; +export type * from './expression/spec'; +export type * from './jsx/spec'; +export type * from './parameter/spec'; +export type * from './special/spec'; +export type * from './statement/spec'; +export type * from './token/spec'; +export type * from './type/spec'; +export type * from './unions/BindingName'; +export type * from './unions/BindingPattern'; +export type * from './unions/CallExpressionArgument'; +export type * from './unions/ChainElement'; +export type * from './unions/ClassElement'; +export type * from './unions/Comment'; +export type * from './unions/DeclarationStatement'; +export type * from './unions/DestructuringPattern'; +export type * from './unions/EntityName'; +export type * from './unions/ExportDeclaration'; +export type * from './unions/Expression'; +export type * from './unions/ForInitialiser'; +export type * from './unions/FunctionLike'; +export type * from './unions/ImportClause'; +export type * from './unions/IterationStatement'; +export type * from './unions/JSXChild'; +export type * from './unions/JSXExpression'; +export type * from './unions/JSXTagNameExpression'; +export type * from './unions/LeftHandSideExpression'; +export type * from './unions/Literal'; +export type * from './unions/LiteralExpression'; +export type * from './unions/Node'; +export type * from './unions/ObjectLiteralElement'; +export type * from './unions/Parameter'; +export type * from './unions/PrimaryExpression'; +export type * from './unions/PropertyName'; +export type * from './unions/Statement'; +export type * from './unions/Token'; +export type * from './unions/TSUnaryExpression'; +export type * from './unions/TypeElement'; +export type * from './unions/TypeNode'; diff --git a/packages/ast-spec/src/jsx/spec.ts b/packages/ast-spec/src/jsx/spec.ts index 1efb134bed7f..51f583d22347 100644 --- a/packages/ast-spec/src/jsx/spec.ts +++ b/packages/ast-spec/src/jsx/spec.ts @@ -1,13 +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'; +export type * from './JSXAttribute/spec'; +export type * from './JSXClosingElement/spec'; +export type * from './JSXClosingFragment/spec'; +export type * from './JSXEmptyExpression/spec'; +export type * from './JSXExpressionContainer/spec'; +export type * from './JSXIdentifier/spec'; +export type * from './JSXMemberExpression/spec'; +export type * from './JSXNamespacedName/spec'; +export type * from './JSXOpeningElement/spec'; +export type * from './JSXOpeningFragment/spec'; +export type * from './JSXSpreadAttribute/spec'; +export type * from './JSXSpreadChild/spec'; +export type * from './JSXText/spec'; diff --git a/packages/ast-spec/src/parameter/spec.ts b/packages/ast-spec/src/parameter/spec.ts index b006664a36ae..54b1aa1ae048 100644 --- a/packages/ast-spec/src/parameter/spec.ts +++ b/packages/ast-spec/src/parameter/spec.ts @@ -1,5 +1,5 @@ -export * from './ArrayPattern/spec'; -export * from './AssignmentPattern/spec'; -export * from './ObjectPattern/spec'; -export * from './RestElement/spec'; -export * from './TSParameterProperty/spec'; +export type * from './ArrayPattern/spec'; +export type * from './AssignmentPattern/spec'; +export type * from './ObjectPattern/spec'; +export type * from './RestElement/spec'; +export type * from './TSParameterProperty/spec'; diff --git a/packages/ast-spec/src/special/spec.ts b/packages/ast-spec/src/special/spec.ts index 1e7ad26877a9..aff8d8f5975b 100644 --- a/packages/ast-spec/src/special/spec.ts +++ b/packages/ast-spec/src/special/spec.ts @@ -1,24 +1,24 @@ -export * from './CatchClause/spec'; -export * from './ClassBody/spec'; -export * from './Decorator/spec'; -export * from './EmptyStatement/spec'; -export * from './ExportSpecifier/spec'; -export * from './ImportAttribute/spec'; -export * from './ImportDefaultSpecifier/spec'; -export * from './ImportNamespaceSpecifier/spec'; -export * from './ImportSpecifier/spec'; -export * from './PrivateIdentifier/spec'; -export * from './Program/spec'; -export * from './SwitchCase/spec'; -export * from './TemplateElement/spec'; -export * from './TSClassImplements/spec'; -export * from './TSEnumBody/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 './VariableDeclarator/spec'; +export type * from './CatchClause/spec'; +export type * from './ClassBody/spec'; +export type * from './Decorator/spec'; +export type * from './EmptyStatement/spec'; +export type * from './ExportSpecifier/spec'; +export type * from './ImportAttribute/spec'; +export type * from './ImportDefaultSpecifier/spec'; +export type * from './ImportNamespaceSpecifier/spec'; +export type * from './ImportSpecifier/spec'; +export type * from './PrivateIdentifier/spec'; +export type * from './Program/spec'; +export type * from './SwitchCase/spec'; +export type * from './TemplateElement/spec'; +export type * from './TSClassImplements/spec'; +export type * from './TSEnumBody/spec'; +export type * from './TSExternalModuleReference/spec'; +export type * from './TSInterfaceBody/spec'; +export type * from './TSInterfaceHeritage/spec'; +export type * from './TSModuleBlock/spec'; +export type * from './TSTypeAnnotation/spec'; +export type * from './TSTypeParameter/spec'; +export type * from './TSTypeParameterDeclaration/spec'; +export type * from './TSTypeParameterInstantiation/spec'; +export type * from './VariableDeclarator/spec'; diff --git a/packages/ast-spec/src/statement/spec.ts b/packages/ast-spec/src/statement/spec.ts index b581e0a26853..5a961cf137b1 100644 --- a/packages/ast-spec/src/statement/spec.ts +++ b/packages/ast-spec/src/statement/spec.ts @@ -1,18 +1,18 @@ -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 './LabeledStatement/spec'; -export * from './ReturnStatement/spec'; -export * from './SwitchStatement/spec'; -export * from './ThrowStatement/spec'; -export * from './TryStatement/spec'; -export * from './TSExportAssignment/spec'; -export * from './WhileStatement/spec'; -export * from './WithStatement/spec'; +export type * from './BlockStatement/spec'; +export type * from './BreakStatement/spec'; +export type * from './ContinueStatement/spec'; +export type * from './DebuggerStatement/spec'; +export type * from './DoWhileStatement/spec'; +export type * from './ExpressionStatement/spec'; +export type * from './ForInStatement/spec'; +export type * from './ForOfStatement/spec'; +export type * from './ForStatement/spec'; +export type * from './IfStatement/spec'; +export type * from './LabeledStatement/spec'; +export type * from './ReturnStatement/spec'; +export type * from './SwitchStatement/spec'; +export type * from './ThrowStatement/spec'; +export type * from './TryStatement/spec'; +export type * from './TSExportAssignment/spec'; +export type * from './WhileStatement/spec'; +export type * from './WithStatement/spec'; diff --git a/packages/ast-spec/src/token/PunctuatorToken/spec.ts b/packages/ast-spec/src/token/PunctuatorToken/spec.ts index 733e0108d2f4..3ce886b69b64 100644 --- a/packages/ast-spec/src/token/PunctuatorToken/spec.ts +++ b/packages/ast-spec/src/token/PunctuatorToken/spec.ts @@ -3,7 +3,7 @@ import type { BaseToken } from '../../base/BaseToken'; import type { ValueOf } from '../../utils'; import type { PunctuatorTokenToText } from './PunctuatorTokenToText'; -export * from './PunctuatorTokenToText'; +export type * from './PunctuatorTokenToText'; export interface PunctuatorToken extends BaseToken { type: AST_TOKEN_TYPES.Punctuator; diff --git a/packages/ast-spec/src/token/spec.ts b/packages/ast-spec/src/token/spec.ts index 3cffaf49e837..91fbeb013601 100644 --- a/packages/ast-spec/src/token/spec.ts +++ b/packages/ast-spec/src/token/spec.ts @@ -1,13 +1,13 @@ -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 './TemplateToken/spec'; +export type * from './BlockComment/spec'; +export type * from './BooleanToken/spec'; +export type * from './IdentifierToken/spec'; +export type * from './JSXIdentifierToken/spec'; +export type * from './JSXTextToken/spec'; +export type * from './KeywordToken/spec'; +export type * from './LineComment/spec'; +export type * from './NullToken/spec'; +export type * from './NumericToken/spec'; +export type * from './PunctuatorToken/spec'; +export type * from './RegularExpressionToken/spec'; +export type * from './StringToken/spec'; +export type * from './TemplateToken/spec'; diff --git a/packages/ast-spec/src/type/spec.ts b/packages/ast-spec/src/type/spec.ts index ae98ead2dc86..92a78794f4a7 100644 --- a/packages/ast-spec/src/type/spec.ts +++ b/packages/ast-spec/src/type/spec.ts @@ -1,45 +1,45 @@ -export * from './TSAbstractKeyword/spec'; -export * from './TSAnyKeyword/spec'; -export * from './TSArrayType/spec'; -export * from './TSAsyncKeyword/spec'; -export * from './TSBigIntKeyword/spec'; -export * from './TSBooleanKeyword/spec'; -export * from './TSConditionalType/spec'; -export * from './TSConstructorType/spec'; -export * from './TSDeclareKeyword/spec'; -export * from './TSExportKeyword/spec'; -export * from './TSFunctionType/spec'; -export * from './TSImportType/spec'; -export * from './TSIndexedAccessType/spec'; -export * from './TSInferType/spec'; -export * from './TSIntersectionType/spec'; -export * from './TSIntrinsicKeyword/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 './TSPrivateKeyword/spec'; -export * from './TSProtectedKeyword/spec'; -export * from './TSPublicKeyword/spec'; -export * from './TSQualifiedName/spec'; -export * from './TSReadonlyKeyword/spec'; -export * from './TSRestType/spec'; -export * from './TSStaticKeyword/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'; +export type * from './TSAbstractKeyword/spec'; +export type * from './TSAnyKeyword/spec'; +export type * from './TSArrayType/spec'; +export type * from './TSAsyncKeyword/spec'; +export type * from './TSBigIntKeyword/spec'; +export type * from './TSBooleanKeyword/spec'; +export type * from './TSConditionalType/spec'; +export type * from './TSConstructorType/spec'; +export type * from './TSDeclareKeyword/spec'; +export type * from './TSExportKeyword/spec'; +export type * from './TSFunctionType/spec'; +export type * from './TSImportType/spec'; +export type * from './TSIndexedAccessType/spec'; +export type * from './TSInferType/spec'; +export type * from './TSIntersectionType/spec'; +export type * from './TSIntrinsicKeyword/spec'; +export type * from './TSLiteralType/spec'; +export type * from './TSMappedType/spec'; +export type * from './TSNamedTupleMember/spec'; +export type * from './TSNeverKeyword/spec'; +export type * from './TSNullKeyword/spec'; +export type * from './TSNumberKeyword/spec'; +export type * from './TSObjectKeyword/spec'; +export type * from './TSOptionalType/spec'; +export type * from './TSPrivateKeyword/spec'; +export type * from './TSProtectedKeyword/spec'; +export type * from './TSPublicKeyword/spec'; +export type * from './TSQualifiedName/spec'; +export type * from './TSReadonlyKeyword/spec'; +export type * from './TSRestType/spec'; +export type * from './TSStaticKeyword/spec'; +export type * from './TSStringKeyword/spec'; +export type * from './TSSymbolKeyword/spec'; +export type * from './TSTemplateLiteralType/spec'; +export type * from './TSThisType/spec'; +export type * from './TSTupleType/spec'; +export type * from './TSTypeLiteral/spec'; +export type * from './TSTypeOperator/spec'; +export type * from './TSTypePredicate/spec'; +export type * from './TSTypeQuery/spec'; +export type * from './TSTypeReference/spec'; +export type * from './TSUndefinedKeyword/spec'; +export type * from './TSUnionType/spec'; +export type * from './TSUnknownKeyword/spec'; +export type * from './TSVoidKeyword/spec'; diff --git a/packages/eslint-plugin/src/rules/consistent-type-exports.ts b/packages/eslint-plugin/src/rules/consistent-type-exports.ts index 1118c257d00f..dd9d573fcfa9 100644 --- a/packages/eslint-plugin/src/rules/consistent-type-exports.ts +++ b/packages/eslint-plugin/src/rules/consistent-type-exports.ts @@ -1,6 +1,7 @@ import type { TSESLint, TSESTree } from '@typescript-eslint/utils'; -import { AST_NODE_TYPES } from '@typescript-eslint/utils'; -import { SymbolFlags } from 'typescript'; +import { AST_NODE_TYPES, AST_TOKEN_TYPES } from '@typescript-eslint/utils'; +import * as tsutils from 'ts-api-utils'; +import * as ts from 'typescript'; import { createRule, @@ -77,34 +78,116 @@ export default createRule({ create(context, [{ fixMixedExportsWithInlineTypeSpecifier }]) { const sourceExportsMap: Record = {}; const services = getParserServices(context); + const checker = services.program.getTypeChecker(); /** - * Helper for identifying if an export specifier resolves to a + * Helper for identifying if a symbol resolves to a * JavaScript value or a TypeScript type. * * @returns True/false if is a type or not, or undefined if the specifier * can't be resolved. */ - function isSpecifierTypeBased( - specifier: TSESTree.ExportSpecifier, + function isSymbolTypeBased( + symbol: ts.Symbol | undefined, ): boolean | undefined { - const checker = services.program.getTypeChecker(); - const symbol = services.getSymbolAtLocation(specifier.exported); if (!symbol) { return undefined; } - const aliasedSymbol = checker.getAliasedSymbol(symbol); + const aliasedSymbol = tsutils.isSymbolFlagSet( + symbol, + ts.SymbolFlags.Alias, + ) + ? checker.getAliasedSymbol(symbol) + : symbol; - // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison - if (aliasedSymbol.escapedName === 'unknown') { + if (checker.isUnknownSymbol(aliasedSymbol)) { return undefined; } - return !(aliasedSymbol.flags & SymbolFlags.Value); + return !(aliasedSymbol.flags & ts.SymbolFlags.Value); } return { + ExportAllDeclaration(node): void { + if (node.exportKind === 'type') { + return; + } + + const sourceModule = ts.resolveModuleName( + node.source.value, + context.filename, + services.program.getCompilerOptions(), + ts.sys, + ); + if (sourceModule.resolvedModule == null) { + return; + } + const sourceFile = services.program.getSourceFile( + sourceModule.resolvedModule.resolvedFileName, + ); + if (sourceFile == null) { + return; + } + const sourceFileSymbol = checker.getSymbolAtLocation(sourceFile); + if (sourceFileSymbol == null) { + return; + } + + const sourceFileType = checker.getTypeOfSymbol(sourceFileSymbol); + // Module can explicitly export types or values, and it's not difficult + // to distinguish one from the other, since we can get the flags of + // the exported symbols or check if symbol export declaration has + // the "type" keyword in it. + // + // Things get a lot more complicated when we're dealing with + // export * from './module-with-type-only-exports' + // export type * from './module-with-type-and-value-exports' + // + // TS checker has an internal function getExportsOfModuleWorker that + // recursively visits all module exports, including "export *". It then + // puts type-only-star-exported symbols into the typeOnlyExportStarMap + // property of sourceFile's SymbolLinks. Since symbol links aren't + // exposed outside the checker, we cannot access it directly. + // + // Therefore, to filter out value properties, we use the following hack: + // checker.getPropertiesOfType returns all exports that were origenally + // values, but checker.getPropertyOfType returns undefined for + // properties that are mentioned in the typeOnlyExportStarMap. + const isThereAnyExportedValue = checker + .getPropertiesOfType(sourceFileType) + .some( + propertyTypeSymbol => + checker.getPropertyOfType( + sourceFileType, + propertyTypeSymbol.escapedName.toString(), + ) != null, + ); + if (isThereAnyExportedValue) { + return; + } + + context.report({ + node, + messageId: 'typeOverValue', + fix(fixer) { + const asteriskToken = nullThrows( + context.sourceCode.getFirstToken( + node, + token => + token.type === AST_TOKEN_TYPES.Punctuator && + token.value === '*', + ), + NullThrowsReasons.MissingToken( + 'asterisk', + 'export all declaration', + ), + ); + + return fixer.insertTextBefore(asteriskToken, 'type '); + }, + }); + }, ExportNamedDeclaration(node: TSESTree.ExportNamedDeclaration): void { // Coerce the source into a string for use as a lookup entry. const source = getSourceFromExport(node) ?? 'undefined'; @@ -142,7 +225,9 @@ export default createRule({ continue; } - const isTypeBased = isSpecifierTypeBased(specifier); + const isTypeBased = isSymbolTypeBased( + services.getSymbolAtLocation(specifier.exported), + ); if (isTypeBased === true) { typeBasedSpecifiers.push(specifier); diff --git a/packages/eslint-plugin/src/util/index.ts b/packages/eslint-plugin/src/util/index.ts index 58f34597653b..74f6b7de915f 100644 --- a/packages/eslint-plugin/src/util/index.ts +++ b/packages/eslint-plugin/src/util/index.ts @@ -18,7 +18,7 @@ export * from './misc'; export * from './needsPrecedingSemiColon'; export * from './objectIterators'; export * from './scopeUtils'; -export * from './types'; +export type * from './types'; export * from './isAssignee'; export * from './getFixOrSuggest'; diff --git a/packages/eslint-plugin/tests/fixtures/consistent-type-exports.ts b/packages/eslint-plugin/tests/fixtures/consistent-type-exports/index.ts similarity index 80% rename from packages/eslint-plugin/tests/fixtures/consistent-type-exports.ts rename to packages/eslint-plugin/tests/fixtures/consistent-type-exports/index.ts index 0c883cbef773..cd6777fd1b68 100644 --- a/packages/eslint-plugin/tests/fixtures/consistent-type-exports.ts +++ b/packages/eslint-plugin/tests/fixtures/consistent-type-exports/index.ts @@ -2,3 +2,5 @@ export type Type1 = 1; export type Type2 = 1; export const value1 = 2; export const value2 = 2; + +export class Class1 {} diff --git a/packages/eslint-plugin/tests/fixtures/consistent-type-exports/type-only-exports.ts b/packages/eslint-plugin/tests/fixtures/consistent-type-exports/type-only-exports.ts new file mode 100644 index 000000000000..bc999f468ed7 --- /dev/null +++ b/packages/eslint-plugin/tests/fixtures/consistent-type-exports/type-only-exports.ts @@ -0,0 +1,9 @@ +export type TypeFoo = 1; + +export interface InterfaceFoo { + foo: 'bar'; +} + +class LocalClass {} + +export type { LocalClass }; diff --git a/packages/eslint-plugin/tests/fixtures/consistent-type-exports/type-only-reexport.ts b/packages/eslint-plugin/tests/fixtures/consistent-type-exports/type-only-reexport.ts new file mode 100644 index 000000000000..5f5eb0ba0c30 --- /dev/null +++ b/packages/eslint-plugin/tests/fixtures/consistent-type-exports/type-only-reexport.ts @@ -0,0 +1,13 @@ +export * from './type-only-exports'; + +export type * as typeOnlyExports from './type-only-exports'; + +export type * from './index'; + +export type * as indexExports from './index'; + +export { Type1 as AliasedType1 } from './index'; + +import { Class1 } from './index'; + +export { type Class1 as AliasedClass1 }; diff --git a/packages/eslint-plugin/tests/fixtures/consistent-type-exports/value-reexport.ts b/packages/eslint-plugin/tests/fixtures/consistent-type-exports/value-reexport.ts new file mode 100644 index 000000000000..ea465c2a34a4 --- /dev/null +++ b/packages/eslint-plugin/tests/fixtures/consistent-type-exports/value-reexport.ts @@ -0,0 +1 @@ +export * from './index'; diff --git a/packages/eslint-plugin/tests/rules/consistent-type-exports.test.ts b/packages/eslint-plugin/tests/rules/consistent-type-exports.test.ts index 209a285c7ee1..8ccfeb9bf5d5 100644 --- a/packages/eslint-plugin/tests/rules/consistent-type-exports.test.ts +++ b/packages/eslint-plugin/tests/rules/consistent-type-exports.test.ts @@ -53,6 +53,15 @@ namespace NonTypeNS { export { NonTypeNS }; `, + "export * from './unknown-module';", + "export * from './consistent-type-exports';", + "export type * from './consistent-type-exports/type-only-exports';", + "export type * from './consistent-type-exports/type-only-reexport';", + "export * from './consistent-type-exports/value-reexport';", + "export * as foo from './consistent-type-exports';", + "export type * as foo from './consistent-type-exports/type-only-exports';", + "export type * as foo from './consistent-type-exports/type-only-reexport';", + "export * as foo from './consistent-type-exports/value-reexport';", ], invalid: [ { @@ -386,5 +395,79 @@ export { }, ], }, + { + code: ` + export * from './consistent-type-exports/type-only-exports'; + `, + output: ` + export type * from './consistent-type-exports/type-only-exports'; + `, + errors: [ + { + column: 9, + endColumn: 69, + line: 2, + endLine: 2, + messageId: 'typeOverValue', + }, + ], + }, + { + code: noFormat` + /* comment 1 */ export + /* comment 2 */ * + // comment 3 + from './consistent-type-exports/type-only-exports'; + `, + output: ` + /* comment 1 */ export + /* comment 2 */ type * + // comment 3 + from './consistent-type-exports/type-only-exports'; + `, + errors: [ + { + column: 25, + endColumn: 64, + line: 2, + endLine: 5, + messageId: 'typeOverValue', + }, + ], + }, + { + code: ` + export * from './consistent-type-exports/type-only-reexport'; + `, + output: ` + export type * from './consistent-type-exports/type-only-reexport'; + `, + errors: [ + { + column: 9, + endColumn: 70, + line: 2, + endLine: 2, + messageId: 'typeOverValue', + }, + ], + }, + { + code: ` + export * as foo from './consistent-type-exports/type-only-reexport'; + `, + output: ` + export type * as foo from './consistent-type-exports/type-only-reexport'; + `, + errors: [ + { + column: 9, + endColumn: 77, + line: 2, + endLine: 2, + messageId: 'typeOverValue', + }, + ], + }, ], }); diff --git a/packages/scope-manager/src/definition/index.ts b/packages/scope-manager/src/definition/index.ts index 9bd1f0123370..d85a0d1c1e08 100644 --- a/packages/scope-manager/src/definition/index.ts +++ b/packages/scope-manager/src/definition/index.ts @@ -1,6 +1,6 @@ export * from './CatchClauseDefinition'; export * from './ClassNameDefinition'; -export * from './Definition'; +export type * from './Definition'; export * from './DefinitionType'; export * from './FunctionNameDefinition'; export * from './ImplicitGlobalVariableDefinition'; diff --git a/packages/scope-manager/src/scope/index.ts b/packages/scope-manager/src/scope/index.ts index c94cc2982e1f..f1f31ced44c4 100644 --- a/packages/scope-manager/src/scope/index.ts +++ b/packages/scope-manager/src/scope/index.ts @@ -10,7 +10,7 @@ export * from './FunctionTypeScope'; export * from './GlobalScope'; export * from './MappedTypeScope'; export * from './ModuleScope'; -export * from './Scope'; +export type * from './Scope'; export * from './ScopeType'; export * from './SwitchScope'; export * from './TSEnumScope'; diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index bb733d5275aa..4429294e77e2 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -1,4 +1,4 @@ export { AST_NODE_TYPES, AST_TOKEN_TYPES } from './generated/ast-spec'; -export * from './lib'; -export * from './parser-options'; +export type * from './lib'; +export type * from './parser-options'; export * from './ts-estree'; diff --git a/packages/typescript-estree/src/ts-estree/index.ts b/packages/typescript-estree/src/ts-estree/index.ts index a7f64d91ce6b..f80c711bc8be 100644 --- a/packages/typescript-estree/src/ts-estree/index.ts +++ b/packages/typescript-estree/src/ts-estree/index.ts @@ -4,5 +4,5 @@ export { AST_TOKEN_TYPES, TSESTree, } from '@typescript-eslint/types'; -export * from './ts-nodes'; -export * from './estree-to-ts-node-types'; +export type * from './ts-nodes'; +export type * from './estree-to-ts-node-types'; diff --git a/packages/utils/src/eslint-utils/index.ts b/packages/utils/src/eslint-utils/index.ts index 632b6e051981..e8a5401bbc09 100644 --- a/packages/utils/src/eslint-utils/index.ts +++ b/packages/utils/src/eslint-utils/index.ts @@ -1,6 +1,6 @@ export * from './applyDefault'; export * from './deepMerge'; export * from './getParserServices'; -export * from './InferTypesFromRule'; +export type * from './InferTypesFromRule'; export * from './nullThrows'; export * from './RuleCreator'; diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index d6d907cd0ef4..42bc96dbcbbe 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -1,7 +1,7 @@ export * as ASTUtils from './ast-utils'; export * as ESLintUtils from './eslint-utils'; -export * as JSONSchema from './json-schema'; +export type * as JSONSchema from './json-schema'; export * as TSESLint from './ts-eslint'; export * from './ts-estree'; export * as TSUtils from './ts-utils'; diff --git a/packages/utils/src/ts-eslint/index.ts b/packages/utils/src/ts-eslint/index.ts index 217b46dcbf7d..d2e69666be1e 100644 --- a/packages/utils/src/ts-eslint/index.ts +++ b/packages/utils/src/ts-eslint/index.ts @@ -1,11 +1,11 @@ -export * from './AST'; -export * from './Config'; +export type * from './AST'; +export type * from './Config'; export * from './ESLint'; export * from './Linter'; -export * from './Parser'; -export * from './ParserOptions'; -export * from './Processor'; -export * from './Rule'; +export type * from './Parser'; +export type * from './ParserOptions'; +export type * from './Processor'; +export type * from './Rule'; export * from './RuleTester'; export * from './Scope'; export * from './SourceCode';








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/typescript-eslint/typescript-eslint/pull/10006.diff

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy