Skip to content

Commit a3ebec9

Browse files
andrewbranchCopilot
andcommitted
Use named imports in AST predicates
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 9b50a6a commit a3ebec9

2 files changed

Lines changed: 167 additions & 79 deletions

File tree

‎packages/typescript/src/ast/ast.ts‎

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,42 @@ import type { LanguageVariant } from "../../enums/languageVariant.js";
77
import type { NodeFlags } from "../../enums/nodeFlags.js";
88
import type { ScriptKind } from "../../enums/scriptKind.js";
99
import { SyntaxKind } from "../../enums/syntaxKind.js";
10-
import type * as generated from "./ast.generated.ts";
1110
import type {
1211
AssertionExpression,
1312
BindingElement,
13+
BindingPattern,
14+
CallExpression,
1415
CaseClause,
1516
ComputedPropertyName,
1617
Decorator,
1718
DoStatement,
19+
ElementAccessExpression,
1820
EndOfFile,
1921
EntityName,
2022
EnumMember,
23+
ExportDeclaration,
24+
ExportSpecifier,
2125
Expression,
2226
ExpressionStatement,
2327
ForInStatement,
2428
ForOfStatement,
2529
ForStatement,
2630
Identifier,
2731
IfStatement,
32+
ImportClause,
33+
ImportEqualsDeclaration,
34+
ImportSpecifier,
2835
JSDoc,
2936
JsxAttribute,
3037
JsxExpression,
3138
JsxSpreadAttribute,
3239
KeywordSyntaxKind,
3340
ModifierSyntaxKind,
41+
NamedExports,
42+
NamedImports,
43+
NamespaceExport,
44+
NamespaceImport,
45+
NonNullExpression,
3446
ParameterDeclaration,
3547
PropertyAccessExpression,
3648
PropertyAssignment,
@@ -65,18 +77,18 @@ export interface AutoAccessorPropertyDeclaration extends PropertyDeclaration {
6577
}
6678

6779
declare const optionalChainBrand: unique symbol;
68-
export interface CallChain extends generated.CallExpression {
80+
export interface CallChain extends CallExpression {
6981
readonly [optionalChainBrand]: void;
7082
}
7183

72-
export interface ElementAccessChain extends generated.ElementAccessExpression {
84+
export interface ElementAccessChain extends ElementAccessExpression {
7385
readonly [optionalChainBrand]: void;
7486
}
7587

7688
declare const emptyBindingPatternBrand: unique symbol;
77-
export type EmptyBindingPattern = generated.BindingPattern & { readonly [emptyBindingPatternBrand]: void; };
89+
export type EmptyBindingPattern = BindingPattern & { readonly [emptyBindingPatternBrand]: void; };
7890

79-
export interface NonNullChain extends generated.NonNullExpression {
91+
export interface NonNullChain extends NonNullExpression {
8092
readonly [optionalChainBrand]: void;
8193
}
8294

@@ -92,23 +104,23 @@ export interface ParameterPropertyDeclaration extends ParameterDeclaration {
92104
}
93105

94106
export type TypeOnlyImportDeclaration =
95-
| generated.ImportClause & { readonly phaseModifier: SyntaxKind.TypeKeyword; }
96-
| generated.ImportEqualsDeclaration & { readonly isTypeOnly: true; }
97-
| generated.NamespaceImport & { readonly parent: generated.ImportClause & { readonly phaseModifier: SyntaxKind.TypeKeyword; }; }
98-
| generated.ImportSpecifier
107+
| ImportClause & { readonly phaseModifier: SyntaxKind.TypeKeyword; }
108+
| ImportEqualsDeclaration & { readonly isTypeOnly: true; }
109+
| NamespaceImport & { readonly parent: ImportClause & { readonly phaseModifier: SyntaxKind.TypeKeyword; }; }
110+
| ImportSpecifier
99111
& (
100112
| { readonly isTypeOnly: true; }
101-
| { readonly parent: generated.NamedImports & { readonly parent: generated.ImportClause & { readonly phaseModifier: SyntaxKind.TypeKeyword; }; }; }
113+
| { readonly parent: NamedImports & { readonly parent: ImportClause & { readonly phaseModifier: SyntaxKind.TypeKeyword; }; }; }
102114
);
103115

104116
export type TypeOnlyExportDeclaration =
105-
| generated.ExportSpecifier
117+
| ExportSpecifier
106118
& (
107119
| { readonly isTypeOnly: true; }
108-
| { readonly parent: generated.NamedExports & { readonly parent: generated.ExportDeclaration & { readonly isTypeOnly: true; }; }; }
120+
| { readonly parent: NamedExports & { readonly parent: ExportDeclaration & { readonly isTypeOnly: true; }; }; }
109121
)
110-
| generated.ExportDeclaration & { readonly isTypeOnly: true; readonly moduleSpecifier: generated.Expression; readonly exportClause?: undefined; }
111-
| generated.NamespaceExport & { readonly parent: generated.ExportDeclaration & { readonly isTypeOnly: true; }; };
122+
| ExportDeclaration & { readonly isTypeOnly: true; readonly moduleSpecifier: Expression; readonly exportClause?: undefined; }
123+
| NamespaceExport & { readonly parent: ExportDeclaration & { readonly isTypeOnly: true; }; };
112124

113125
export type TypeOnlyAliasDeclaration = TypeOnlyImportDeclaration | TypeOnlyExportDeclaration;
114126

0 commit comments

Comments
 (0)