@flint.fyi/typescript-language 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/lib/_virtual/rolldown_runtime.js +18 -0
- package/lib/collectReferencedFilePaths.d.ts +4 -0
- package/lib/collectReferencedFilePaths.js +41 -0
- package/lib/convertTypeScriptDiagnosticToLanguageFileDiagnostic.d.ts +18 -0
- package/lib/convertTypeScriptDiagnosticToLanguageFileDiagnostic.js +110 -0
- package/lib/createTypeScriptFileFromProgram.d.ts +12 -0
- package/lib/createTypeScriptFileFromProgram.js +41 -0
- package/lib/createTypeScriptFileFromProjectService.d.ts +8 -0
- package/lib/createTypeScriptFileFromProjectService.js +16 -0
- package/lib/directives/parseDirectivesFromTypeScriptFile.d.ts +13 -0
- package/lib/directives/parseDirectivesFromTypeScriptFile.js +36 -0
- package/lib/getFirstEnumValues.d.ts +36 -0
- package/lib/getFirstEnumValues.js +48 -0
- package/lib/getTSNodeRange.d.ts +9 -0
- package/lib/getTSNodeRange.js +11 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.js +20 -0
- package/lib/language.d.ts +16 -0
- package/lib/language.js +23 -0
- package/lib/lib/convertTypeScriptDiagnosticToLanguageFileDiagnostic.d.ts +2 -0
- package/lib/lib/createTypeScriptFileFromProgram.d.ts +5 -0
- package/lib/lib/directives/parseDirectivesFromTypeScriptFile.d.ts +2 -0
- package/lib/lib/getTSNodeRange.d.ts +3 -0
- package/lib/lib/index.d.ts +21 -0
- package/lib/lib/language.d.ts +5 -0
- package/lib/lib/nodes.d.ts +1 -0
- package/lib/lib/prepareTypeScriptBasedLanguage.d.ts +2 -0
- package/lib/lib/types/ast.d.ts +2066 -0
- package/lib/lib/types/checker.d.ts +23 -0
- package/lib/lib/utils/declarationIncludesGlobal.d.ts +1 -0
- package/lib/lib/utils/getDeclarationsIfGlobal.d.ts +2 -0
- package/lib/lib/utils/getModifyingReferences.d.ts +3 -0
- package/lib/lib/utils/hasSameTokens.d.ts +1 -0
- package/lib/lib/utils/isBuiltinArrayMethod.d.ts +2 -0
- package/lib/lib/utils/isFunction.d.ts +1 -0
- package/lib/lib/utils/isGlobalDeclaration.d.ts +1 -0
- package/lib/lib/utils/isGlobalDeclarationOfName.d.ts +2 -0
- package/lib/lib/utils/isGlobalVariable.d.ts +1 -0
- package/lib/lib/utils/isInlineArrayCreation.d.ts +1 -0
- package/lib/lib/utils/unwrapParentParenthesizedExpressions.d.ts +1 -0
- package/lib/lib/utils/unwrapParenthesizedExpression.d.ts +1 -0
- package/lib/nodes.d.ts +202 -0
- package/lib/normalizeRange.d.ts +4 -0
- package/lib/normalizeRange.js +20 -0
- package/lib/prepareTypeScriptBasedLanguage.d.ts +16 -0
- package/lib/prepareTypeScriptBasedLanguage.js +55 -0
- package/lib/prepareTypeScriptFile.d.ts +14 -0
- package/lib/prepareTypeScriptFile.js +18 -0
- package/lib/types/ast.d.ts +2070 -0
- package/lib/types/checker.d.ts +23 -0
- package/lib/utils/declarationIncludesGlobal.d.ts +7 -0
- package/lib/utils/declarationIncludesGlobal.js +9 -0
- package/lib/utils/declarationsIncludeGlobal.d.ts +3 -0
- package/lib/utils/declarationsIncludeGlobal.js +10 -0
- package/lib/utils/getDeclarationsIfGlobal.d.ts +10 -0
- package/lib/utils/getDeclarationsIfGlobal.js +11 -0
- package/lib/utils/getModifyingReferences.d.ts +17 -0
- package/lib/utils/getModifyingReferences.js +33 -0
- package/lib/utils/hasSameTokens.d.ts +7 -0
- package/lib/utils/hasSameTokens.js +33 -0
- package/lib/utils/isBuiltinArrayMethod.d.ts +15 -0
- package/lib/utils/isBuiltinArrayMethod.js +10 -0
- package/lib/utils/isFunction.d.ts +9 -0
- package/lib/utils/isFunction.js +8 -0
- package/lib/utils/isGlobalDeclaration.d.ts +9 -0
- package/lib/utils/isGlobalDeclaration.js +10 -0
- package/lib/utils/isGlobalDeclarationOfName.d.ts +12 -0
- package/lib/utils/isGlobalDeclarationOfName.js +24 -0
- package/lib/utils/isGlobalVariable.d.ts +16 -0
- package/lib/utils/isGlobalVariable.js +20 -0
- package/lib/utils/isInlineArrayCreation.d.ts +13 -0
- package/lib/utils/isInlineArrayCreation.js +46 -0
- package/lib/utils/unwrapParentParenthesizedExpressions.d.ts +7 -0
- package/lib/utils/unwrapParentParenthesizedExpressions.js +10 -0
- package/lib/utils/unwrapParenthesizedExpression.d.ts +7 -0
- package/lib/utils/unwrapParenthesizedExpression.js +10 -0
- package/package.json +53 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CallExpression, Decorator, JsxOpeningElement, JsxSelfClosingElement, NewExpression, TaggedTemplateExpression } from "./ast.js";
|
|
2
|
+
import ts, { Node, Signature, TupleTypeReference, Type, TypeChecker, TypeReference } from "typescript";
|
|
3
|
+
|
|
4
|
+
//#region lib/types/checker.d.ts
|
|
5
|
+
type Checker = CheckerOverrides & Omit<TypeChecker, keyof CheckerOverrides>;
|
|
6
|
+
interface CheckerOverrides {
|
|
7
|
+
getResolvedSignature(node: CallExpression | Decorator | JsxOpeningElement | JsxSelfClosingElement | NewExpression | TaggedTemplateExpression | ts.CallLikeExpression): Signature | undefined;
|
|
8
|
+
/** Improve narrowing, borrow from typescript-eslint */
|
|
9
|
+
isArrayType(type: Type): type is TypeReference;
|
|
10
|
+
isTupleType(type: Type): type is TupleTypeReference;
|
|
11
|
+
/**
|
|
12
|
+
* TS internal api
|
|
13
|
+
* Return the type of the given property in the given type, or undefined if no such property exists
|
|
14
|
+
*/
|
|
15
|
+
getTypeOfPropertyOfType(type: Type, propertyName: string): Type | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* TS internal api
|
|
18
|
+
*/
|
|
19
|
+
getContextualTypeForArgumentAtIndex(node: Node, argIndex: number): Type;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Checker };
|
|
23
|
+
//# sourceMappingURL=checker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../types/ast.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "typescript";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../types/ast.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../types/ast.js";
|
package/lib/nodes.d.ts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { AnyKeyword, ArrayBindingPattern, ArrayLiteralExpression, ArrayTypeNode, ArrowFunction, AsExpression, AwaitExpression, BigIntKeyword, BigIntLiteral, BinaryExpression, BindingElement, Block, BooleanKeyword, BreakStatement, CallExpression, CallSignatureDeclaration, CaseBlock, CaseClause, CatchClause, ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, CommaListExpression, ComputedPropertyName, ConditionalExpression, ConditionalTypeNode, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ContinueStatement, DebuggerStatement, Decorator, DefaultClause, DeleteExpression, DoStatement, ElementAccessExpression, EmptyStatement, EnumDeclaration, EnumMember, ExportAssignment, ExportDeclaration, ExportSpecifier, ExpressionStatement, ExpressionWithTypeArguments, ExternalModuleReference, FalseLiteral, ForInStatement, ForOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, Identifier, IfStatement, ImportAttribute, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportExpression, ImportSpecifier, ImportTypeNode, IndexSignatureDeclaration, IndexedAccessTypeNode, InferTypeNode, InterfaceDeclaration, IntersectionTypeNode, IntrinsicKeyword, JSDocAllType, JSDocFunctionType, JSDocLink, JSDocLinkCode, JSDocLinkPlain, JSDocMemberName, JSDocNamepathType, JSDocNonNullableType, JSDocNullableType, JSDocOptionalType, JSDocParameterTag, JSDocPropertyTag, JSDocReturnTag, JSDocSignature, JSDocTemplateTag, JSDocText, JSDocTypeExpression, JSDocTypeLiteral, JSDocUnknownType, JSDocVariadicType, JsxAttribute, JsxAttributes, JsxClosingElement, JsxClosingFragment, JsxElement, JsxExpression, JsxFragment, JsxNamespacedName, JsxOpeningElement, JsxOpeningFragment, JsxSelfClosingElement, JsxSpreadAttribute, JsxText, LabeledStatement, LiteralTypeNode, MappedTypeNode, MetaProperty, MethodDeclaration, MethodSignature, MissingDeclaration, ModuleBlock, ModuleDeclaration, NamedExports, NamedImports, NamedTupleMember, NamespaceExport, NamespaceExportDeclaration, NamespaceImport, NeverKeyword, NewExpression, NoSubstitutionTemplateLiteral, NonNullExpression, NotEmittedStatement, NotEmittedTypeElement, NullLiteral, NumberKeyword, NumericLiteral, ObjectBindingPattern, ObjectKeyword, ObjectLiteralExpression, OmittedExpression, OptionalTypeNode, ParameterDeclaration, ParenthesizedExpression, ParenthesizedTypeNode, PartiallyEmittedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertySignature, QualifiedName, RegularExpressionLiteral, RestTypeNode, ReturnStatement, SatisfiesExpression, SemicolonClassElement, SetAccessorDeclaration, ShorthandPropertyAssignment, SourceFile, SpreadAssignment, SpreadElement, StringKeyword, StringLiteral, SuperExpression, SwitchStatement, SymbolKeyword, SyntheticExpression, TaggedTemplateExpression, TemplateExpression, TemplateHead, TemplateLiteralTypeNode, TemplateLiteralTypeSpan, TemplateMiddle, TemplateSpan, TemplateTail, ThisExpression, ThisTypeNode, ThrowStatement, TrueLiteral, TryStatement, TupleTypeNode, TypeAliasDeclaration, TypeAssertion, TypeLiteralNode, TypeOfExpression, TypeOperatorNode, TypeParameterDeclaration, TypePredicateNode, TypeQueryNode, TypeReferenceNode, UndefinedKeyword, UnionTypeNode, UnknownKeyword, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, VoidKeyword, WhileStatement, WithStatement, YieldExpression } from "./types/ast.js";
|
|
2
|
+
|
|
3
|
+
//#region src/nodes.d.ts
|
|
4
|
+
interface TypeScriptNodesByName {
|
|
5
|
+
AnyKeyword: AnyKeyword;
|
|
6
|
+
ArrayBindingPattern: ArrayBindingPattern;
|
|
7
|
+
ArrayLiteralExpression: ArrayLiteralExpression;
|
|
8
|
+
ArrayType: ArrayTypeNode;
|
|
9
|
+
ArrowFunction: ArrowFunction;
|
|
10
|
+
AsExpression: AsExpression;
|
|
11
|
+
AwaitExpression: AwaitExpression;
|
|
12
|
+
BigIntKeyword: BigIntKeyword;
|
|
13
|
+
BigIntLiteral: BigIntLiteral;
|
|
14
|
+
BinaryExpression: BinaryExpression;
|
|
15
|
+
BindingElement: BindingElement;
|
|
16
|
+
Block: Block;
|
|
17
|
+
BooleanKeyword: BooleanKeyword;
|
|
18
|
+
BreakStatement: BreakStatement;
|
|
19
|
+
CallExpression: CallExpression;
|
|
20
|
+
CallSignature: CallSignatureDeclaration;
|
|
21
|
+
CaseBlock: CaseBlock;
|
|
22
|
+
CaseClause: CaseClause;
|
|
23
|
+
CatchClause: CatchClause;
|
|
24
|
+
ClassDeclaration: ClassDeclaration;
|
|
25
|
+
ClassExpression: ClassExpression;
|
|
26
|
+
ClassStaticBlockDeclaration: ClassStaticBlockDeclaration;
|
|
27
|
+
CommaListExpression: CommaListExpression;
|
|
28
|
+
ComputedPropertyName: ComputedPropertyName;
|
|
29
|
+
ConditionalExpression: ConditionalExpression;
|
|
30
|
+
ConditionalType: ConditionalTypeNode;
|
|
31
|
+
Constructor: ConstructorDeclaration;
|
|
32
|
+
ConstructorType: ConstructorTypeNode;
|
|
33
|
+
ConstructSignature: ConstructSignatureDeclaration;
|
|
34
|
+
ContinueStatement: ContinueStatement;
|
|
35
|
+
DebuggerStatement: DebuggerStatement;
|
|
36
|
+
Decorator: Decorator;
|
|
37
|
+
DefaultClause: DefaultClause;
|
|
38
|
+
DeleteExpression: DeleteExpression;
|
|
39
|
+
DoStatement: DoStatement;
|
|
40
|
+
ElementAccessExpression: ElementAccessExpression;
|
|
41
|
+
EmptyStatement: EmptyStatement;
|
|
42
|
+
EnumDeclaration: EnumDeclaration;
|
|
43
|
+
EnumMember: EnumMember;
|
|
44
|
+
ExportAssignment: ExportAssignment;
|
|
45
|
+
ExportDeclaration: ExportDeclaration;
|
|
46
|
+
ExportSpecifier: ExportSpecifier;
|
|
47
|
+
ExpressionStatement: ExpressionStatement;
|
|
48
|
+
ExpressionWithTypeArguments: ExpressionWithTypeArguments;
|
|
49
|
+
ExternalModuleReference: ExternalModuleReference;
|
|
50
|
+
FalseKeyword: FalseLiteral;
|
|
51
|
+
ForInStatement: ForInStatement;
|
|
52
|
+
ForOfStatement: ForOfStatement;
|
|
53
|
+
ForStatement: ForStatement;
|
|
54
|
+
FunctionDeclaration: FunctionDeclaration;
|
|
55
|
+
FunctionExpression: FunctionExpression;
|
|
56
|
+
FunctionType: FunctionTypeNode;
|
|
57
|
+
GetAccessor: GetAccessorDeclaration;
|
|
58
|
+
HeritageClause: HeritageClause;
|
|
59
|
+
Identifier: Identifier;
|
|
60
|
+
IfStatement: IfStatement;
|
|
61
|
+
ImportAttribute: ImportAttribute;
|
|
62
|
+
ImportAttributes: ImportAttributes;
|
|
63
|
+
ImportClause: ImportClause;
|
|
64
|
+
ImportDeclaration: ImportDeclaration;
|
|
65
|
+
ImportEqualsDeclaration: ImportEqualsDeclaration;
|
|
66
|
+
ImportKeyword: ImportExpression;
|
|
67
|
+
ImportSpecifier: ImportSpecifier;
|
|
68
|
+
ImportType: ImportTypeNode;
|
|
69
|
+
IndexedAccessType: IndexedAccessTypeNode;
|
|
70
|
+
IndexSignature: IndexSignatureDeclaration;
|
|
71
|
+
InferType: InferTypeNode;
|
|
72
|
+
InterfaceDeclaration: InterfaceDeclaration;
|
|
73
|
+
IntersectionType: IntersectionTypeNode;
|
|
74
|
+
IntrinsicKeyword: IntrinsicKeyword;
|
|
75
|
+
JSDocAllType: JSDocAllType;
|
|
76
|
+
JSDocFunctionType: JSDocFunctionType;
|
|
77
|
+
JSDocLink: JSDocLink;
|
|
78
|
+
JSDocLinkCode: JSDocLinkCode;
|
|
79
|
+
JSDocLinkPlain: JSDocLinkPlain;
|
|
80
|
+
JSDocMemberName: JSDocMemberName;
|
|
81
|
+
JSDocNamepathType: JSDocNamepathType;
|
|
82
|
+
JSDocNonNullableType: JSDocNonNullableType;
|
|
83
|
+
JSDocNullableType: JSDocNullableType;
|
|
84
|
+
JSDocOptionalType: JSDocOptionalType;
|
|
85
|
+
JSDocParameterTag: JSDocParameterTag;
|
|
86
|
+
JSDocPropertyTag: JSDocPropertyTag;
|
|
87
|
+
JSDocReturnTag: JSDocReturnTag;
|
|
88
|
+
JSDocSignature: JSDocSignature;
|
|
89
|
+
JSDocTemplateTag: JSDocTemplateTag;
|
|
90
|
+
JSDocText: JSDocText;
|
|
91
|
+
JSDocTypeExpression: JSDocTypeExpression;
|
|
92
|
+
JSDocTypeLiteral: JSDocTypeLiteral;
|
|
93
|
+
JSDocUnknownType: JSDocUnknownType;
|
|
94
|
+
JSDocVariadicType: JSDocVariadicType;
|
|
95
|
+
JsxAttribute: JsxAttribute;
|
|
96
|
+
JsxAttributes: JsxAttributes;
|
|
97
|
+
JsxClosingElement: JsxClosingElement;
|
|
98
|
+
JsxClosingFragment: JsxClosingFragment;
|
|
99
|
+
JsxElement: JsxElement;
|
|
100
|
+
JsxExpression: JsxExpression;
|
|
101
|
+
JsxFragment: JsxFragment;
|
|
102
|
+
JsxNamespacedName: JsxNamespacedName;
|
|
103
|
+
JsxOpeningElement: JsxOpeningElement;
|
|
104
|
+
JsxOpeningFragment: JsxOpeningFragment;
|
|
105
|
+
JsxSelfClosingElement: JsxSelfClosingElement;
|
|
106
|
+
JsxSpreadAttribute: JsxSpreadAttribute;
|
|
107
|
+
JsxText: JsxText;
|
|
108
|
+
LabeledStatement: LabeledStatement;
|
|
109
|
+
LiteralType: LiteralTypeNode;
|
|
110
|
+
MappedType: MappedTypeNode;
|
|
111
|
+
MetaProperty: MetaProperty;
|
|
112
|
+
MethodDeclaration: MethodDeclaration;
|
|
113
|
+
MethodSignature: MethodSignature;
|
|
114
|
+
MissingDeclaration: MissingDeclaration;
|
|
115
|
+
ModuleBlock: ModuleBlock;
|
|
116
|
+
ModuleDeclaration: ModuleDeclaration;
|
|
117
|
+
NamedExports: NamedExports;
|
|
118
|
+
NamedImports: NamedImports;
|
|
119
|
+
NamedTupleMember: NamedTupleMember;
|
|
120
|
+
NamespaceExport: NamespaceExport;
|
|
121
|
+
NamespaceExportDeclaration: NamespaceExportDeclaration;
|
|
122
|
+
NamespaceImport: NamespaceImport;
|
|
123
|
+
NeverKeyword: NeverKeyword;
|
|
124
|
+
NewExpression: NewExpression;
|
|
125
|
+
NonNullExpression: NonNullExpression;
|
|
126
|
+
NoSubstitutionTemplateLiteral: NoSubstitutionTemplateLiteral;
|
|
127
|
+
NotEmittedStatement: NotEmittedStatement;
|
|
128
|
+
NotEmittedTypeElement: NotEmittedTypeElement;
|
|
129
|
+
NullKeyword: NullLiteral;
|
|
130
|
+
NumberKeyword: NumberKeyword;
|
|
131
|
+
NumericLiteral: NumericLiteral;
|
|
132
|
+
ObjectBindingPattern: ObjectBindingPattern;
|
|
133
|
+
ObjectKeyword: ObjectKeyword;
|
|
134
|
+
ObjectLiteralExpression: ObjectLiteralExpression;
|
|
135
|
+
OmittedExpression: OmittedExpression;
|
|
136
|
+
OptionalType: OptionalTypeNode;
|
|
137
|
+
Parameter: ParameterDeclaration;
|
|
138
|
+
ParenthesizedExpression: ParenthesizedExpression;
|
|
139
|
+
ParenthesizedType: ParenthesizedTypeNode;
|
|
140
|
+
PartiallyEmittedExpression: PartiallyEmittedExpression;
|
|
141
|
+
PostfixUnaryExpression: PostfixUnaryExpression;
|
|
142
|
+
PrefixUnaryExpression: PrefixUnaryExpression;
|
|
143
|
+
PrivateIdentifier: PrivateIdentifier;
|
|
144
|
+
PropertyAccessExpression: PropertyAccessExpression;
|
|
145
|
+
PropertyAssignment: PropertyAssignment;
|
|
146
|
+
PropertyDeclaration: PropertyDeclaration;
|
|
147
|
+
PropertySignature: PropertySignature;
|
|
148
|
+
QualifiedName: QualifiedName;
|
|
149
|
+
RegularExpressionLiteral: RegularExpressionLiteral;
|
|
150
|
+
RestType: RestTypeNode;
|
|
151
|
+
ReturnStatement: ReturnStatement;
|
|
152
|
+
SatisfiesExpression: SatisfiesExpression;
|
|
153
|
+
SemicolonClassElement: SemicolonClassElement;
|
|
154
|
+
SetAccessor: SetAccessorDeclaration;
|
|
155
|
+
ShorthandPropertyAssignment: ShorthandPropertyAssignment;
|
|
156
|
+
SourceFile: SourceFile;
|
|
157
|
+
SpreadAssignment: SpreadAssignment;
|
|
158
|
+
SpreadElement: SpreadElement;
|
|
159
|
+
StringKeyword: StringKeyword;
|
|
160
|
+
StringLiteral: StringLiteral;
|
|
161
|
+
SuperKeyword: SuperExpression;
|
|
162
|
+
SwitchStatement: SwitchStatement;
|
|
163
|
+
SymbolKeyword: SymbolKeyword;
|
|
164
|
+
SyntheticExpression: SyntheticExpression;
|
|
165
|
+
TaggedTemplateExpression: TaggedTemplateExpression;
|
|
166
|
+
TemplateExpression: TemplateExpression;
|
|
167
|
+
TemplateHead: TemplateHead;
|
|
168
|
+
TemplateLiteralType: TemplateLiteralTypeNode;
|
|
169
|
+
TemplateLiteralTypeSpan: TemplateLiteralTypeSpan;
|
|
170
|
+
TemplateMiddle: TemplateMiddle;
|
|
171
|
+
TemplateSpan: TemplateSpan;
|
|
172
|
+
TemplateTail: TemplateTail;
|
|
173
|
+
ThisKeyword: ThisExpression;
|
|
174
|
+
ThisType: ThisTypeNode;
|
|
175
|
+
ThrowStatement: ThrowStatement;
|
|
176
|
+
TrueKeyword: TrueLiteral;
|
|
177
|
+
TryStatement: TryStatement;
|
|
178
|
+
TupleType: TupleTypeNode;
|
|
179
|
+
TypeAliasDeclaration: TypeAliasDeclaration;
|
|
180
|
+
TypeAssertionExpression: TypeAssertion;
|
|
181
|
+
TypeLiteral: TypeLiteralNode;
|
|
182
|
+
TypeOfExpression: TypeOfExpression;
|
|
183
|
+
TypeOperator: TypeOperatorNode;
|
|
184
|
+
TypeParameter: TypeParameterDeclaration;
|
|
185
|
+
TypePredicate: TypePredicateNode;
|
|
186
|
+
TypeQuery: TypeQueryNode;
|
|
187
|
+
TypeReference: TypeReferenceNode;
|
|
188
|
+
UndefinedKeyword: UndefinedKeyword;
|
|
189
|
+
UnionType: UnionTypeNode;
|
|
190
|
+
UnknownKeyword: UnknownKeyword;
|
|
191
|
+
VariableDeclaration: VariableDeclaration;
|
|
192
|
+
VariableDeclarationList: VariableDeclarationList;
|
|
193
|
+
VariableStatement: VariableStatement;
|
|
194
|
+
VoidExpression: VoidExpression;
|
|
195
|
+
VoidKeyword: VoidKeyword;
|
|
196
|
+
WhileStatement: WhileStatement;
|
|
197
|
+
WithStatement: WithStatement;
|
|
198
|
+
YieldExpression: YieldExpression;
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
export { TypeScriptNodesByName };
|
|
202
|
+
//# sourceMappingURL=nodes.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type CharacterReportRange, type NormalizedReportRangeObject } from "@flint.fyi/core";
|
|
2
|
+
import type * as AST from "./types/ast.ts";
|
|
3
|
+
export declare function normalizeRange(original: CharacterReportRange, sourceFile: AST.SourceFile): NormalizedReportRangeObject;
|
|
4
|
+
//# sourceMappingURL=normalizeRange.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getColumnAndLineOfPosition } from "@flint.fyi/core";
|
|
2
|
+
|
|
3
|
+
//#region src/normalizeRange.ts
|
|
4
|
+
function normalizeRange(original, sourceFile) {
|
|
5
|
+
const onCharacters = isNode(original) ? {
|
|
6
|
+
begin: original.getStart(sourceFile),
|
|
7
|
+
end: original.getEnd()
|
|
8
|
+
} : original;
|
|
9
|
+
return {
|
|
10
|
+
begin: getColumnAndLineOfPosition(sourceFile, onCharacters.begin),
|
|
11
|
+
end: getColumnAndLineOfPosition(sourceFile, onCharacters.end)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function isNode(value) {
|
|
15
|
+
return typeof value === "object" && value !== null && "kind" in value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { normalizeRange };
|
|
20
|
+
//# sourceMappingURL=normalizeRange.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SourceFile } from "./types/ast.js";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
|
|
4
|
+
//#region src/prepareTypeScriptBasedLanguage.d.ts
|
|
5
|
+
interface TypeScriptBasedLanguageFile extends Partial<Disposable> {
|
|
6
|
+
program: ts.Program;
|
|
7
|
+
sourceFile: SourceFile;
|
|
8
|
+
}
|
|
9
|
+
interface TypeScriptBasedLanguageFileFactoryDefinition {
|
|
10
|
+
createFromDisk(filePathAbsolute: string): TypeScriptBasedLanguageFile;
|
|
11
|
+
createFromVirtual(filePathAbsolute: string, sourceText: string): TypeScriptBasedLanguageFile;
|
|
12
|
+
}
|
|
13
|
+
declare function prepareTypeScriptBasedLanguage(): TypeScriptBasedLanguageFileFactoryDefinition;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { TypeScriptBasedLanguageFile, TypeScriptBasedLanguageFileFactoryDefinition, prepareTypeScriptBasedLanguage };
|
|
16
|
+
//# sourceMappingURL=prepareTypeScriptBasedLanguage.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createTypeScriptFileFromProjectService } from "./createTypeScriptFileFromProjectService.js";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { createFSBackedSystem, createVirtualTypeScriptEnvironment } from "@typescript/vfs";
|
|
5
|
+
import { createProjectService } from "@typescript-eslint/project-service";
|
|
6
|
+
import { CachedFactory } from "cached-factory";
|
|
7
|
+
import { debugForFile } from "debug-for-file";
|
|
8
|
+
|
|
9
|
+
//#region src/prepareTypeScriptBasedLanguage.ts
|
|
10
|
+
const projectRoot = path.join(import.meta.dirname, "../..");
|
|
11
|
+
const log = debugForFile(import.meta.filename);
|
|
12
|
+
function prepareTypeScriptBasedLanguage() {
|
|
13
|
+
const { service } = createProjectService();
|
|
14
|
+
const seenPrograms = /* @__PURE__ */ new Set();
|
|
15
|
+
const environments = new CachedFactory((filePathAbsolute) => {
|
|
16
|
+
return createVirtualTypeScriptEnvironment(createFSBackedSystem(new Map([[filePathAbsolute, "// ..."]]), projectRoot, ts), [filePathAbsolute], ts, {
|
|
17
|
+
skipLibCheck: true,
|
|
18
|
+
target: ts.ScriptTarget.ESNext
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
const servicePrograms = new CachedFactory((filePathAbsolute) => {
|
|
22
|
+
log("Opening client file:", filePathAbsolute);
|
|
23
|
+
service.openClientFile(filePathAbsolute);
|
|
24
|
+
log("Retrieving client services:", filePathAbsolute);
|
|
25
|
+
const scriptInfo = service.getScriptInfo(filePathAbsolute);
|
|
26
|
+
if (!scriptInfo) throw new Error(`Could not find script info for file: ${filePathAbsolute}`);
|
|
27
|
+
const defaultProject = service.getDefaultProjectForFile(scriptInfo.fileName, true);
|
|
28
|
+
if (!defaultProject) throw new Error(`Could not find default project for file: ${filePathAbsolute}`);
|
|
29
|
+
const program = defaultProject.getLanguageService(true).getProgram();
|
|
30
|
+
if (!program) throw new Error(`Could not retrieve program for file: ${filePathAbsolute}`);
|
|
31
|
+
return program;
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
createFromDisk: (filePathAbsolute) => {
|
|
35
|
+
const program = servicePrograms.get(filePathAbsolute);
|
|
36
|
+
seenPrograms.add(program);
|
|
37
|
+
return createTypeScriptFileFromProjectService(filePathAbsolute, program, service);
|
|
38
|
+
},
|
|
39
|
+
createFromVirtual: (filePathAbsolute, sourceText) => {
|
|
40
|
+
const environment = environments.get(filePathAbsolute);
|
|
41
|
+
environment.updateFile(filePathAbsolute, sourceText);
|
|
42
|
+
const sourceFile = environment.getSourceFile(filePathAbsolute);
|
|
43
|
+
const program = environment.languageService.getProgram();
|
|
44
|
+
seenPrograms.add(program);
|
|
45
|
+
return {
|
|
46
|
+
program,
|
|
47
|
+
sourceFile
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
export { prepareTypeScriptBasedLanguage };
|
|
55
|
+
//# sourceMappingURL=prepareTypeScriptBasedLanguage.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FileAboutData } from "@flint.fyi/core";
|
|
2
|
+
import type { TypeScriptBasedLanguageFile } from "./prepareTypeScriptBasedLanguage.ts";
|
|
3
|
+
export declare function prepareTypeScriptFile(data: FileAboutData, file: TypeScriptBasedLanguageFile): {
|
|
4
|
+
file: {
|
|
5
|
+
about: import("@flint.fyi/core").FileDiskData;
|
|
6
|
+
cache?: import("@flint.fyi/core").LanguageFileCacheImpacts;
|
|
7
|
+
getDiagnostics?(): import("@flint.fyi/core").LanguageDiagnostics;
|
|
8
|
+
runVisitors<OptionsSchema extends import("@flint.fyi/core").AnyOptionalSchema | undefined = import("@flint.fyi/core").AnyOptionalSchema | undefined>(options: import("@flint.fyi/core").InferredOutputObject<OptionsSchema>, runtime: import("@flint.fyi/core").RuleRuntime<import("./nodes.ts").TypeScriptNodesByName, import("./language.ts").TypeScriptFileServices>): void;
|
|
9
|
+
[Symbol.dispose]?: () => void;
|
|
10
|
+
};
|
|
11
|
+
directives: import("@flint.fyi/core").CommentDirective[];
|
|
12
|
+
reports: import("@flint.fyi/core").FileReport[];
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=prepareTypeScriptFile.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createTypeScriptFileFromProgram } from "./createTypeScriptFileFromProgram.js";
|
|
2
|
+
import { parseDirectivesFromTypeScriptFile } from "./directives/parseDirectivesFromTypeScriptFile.js";
|
|
3
|
+
|
|
4
|
+
//#region src/prepareTypeScriptFile.ts
|
|
5
|
+
function prepareTypeScriptFile(data, file) {
|
|
6
|
+
const { program, sourceFile, [Symbol.dispose]: onDispose } = file;
|
|
7
|
+
return {
|
|
8
|
+
...parseDirectivesFromTypeScriptFile(sourceFile),
|
|
9
|
+
file: {
|
|
10
|
+
...onDispose != null && { [Symbol.dispose]: onDispose },
|
|
11
|
+
...createTypeScriptFileFromProgram(data, program, sourceFile)
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { prepareTypeScriptFile };
|
|
18
|
+
//# sourceMappingURL=prepareTypeScriptFile.js.map
|