@flint.fyi/typescript-language 0.20.1 → 0.21.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/dist/index.d.mts +79 -53
- package/dist/index.mjs +138 -96
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as ts$1 from "typescript";
|
|
2
2
|
import ts, { CallLikeExpression, Declaration, Node, Program, Signature, SyntaxKind, TupleTypeReference, Type, TypeChecker, TypeReference } from "typescript";
|
|
3
|
-
import {
|
|
3
|
+
import { CharacterReportRange, FileAboutData, FileVisitorSubscription, FileVisitors, Language, LanguageFileDefinition, LanguageReport, LanguageReports, NormalizedReportRangeObject, SourceFileWithLineMapAndFileName, WithExitKeys } from "@flint.fyi/core";
|
|
4
4
|
//#endregion
|
|
5
5
|
//#region src/convertTypeScriptDiagnosticToLanguageReport.d.ts
|
|
6
6
|
interface TSDiagnostic extends TSDiagnosticRelatedInformation {
|
|
@@ -13,7 +13,7 @@ interface TSDiagnosticRelatedInformation {
|
|
|
13
13
|
messageText: string | ts.DiagnosticMessageChain;
|
|
14
14
|
start: number | undefined;
|
|
15
15
|
}
|
|
16
|
-
declare function convertTypeScriptDiagnosticToLanguageReport(diagnostic: TSDiagnostic): LanguageReport;
|
|
16
|
+
export declare function convertTypeScriptDiagnosticToLanguageReport(diagnostic: TSDiagnostic): LanguageReport;
|
|
17
17
|
declare namespace ast_d_exports {
|
|
18
18
|
export { AbstractKeyword, AccessorDeclaration, AccessorKeyword, AdditiveOperator, AdditiveOperatorOrHigher, AnyKeyword, AnyNode, ArrayBindingElement, ArrayBindingPattern, ArrayLiteralExpression, ArrayTypeNode, ArrowFunction, AsExpression, AssertsKeyword, AssignmentOperator, AssignmentOperatorOrHigher, AsteriskToken, AsyncKeyword, AwaitExpression, AwaitKeyword, BigIntKeyword, BigIntLiteral, BinaryExpression, BinaryOperator, BinaryOperatorToken, BindingElement, BindingName, BindingPattern, BitwiseOperator, BitwiseOperatorOrHigher, Block, BooleanKeyword, BooleanLiteral, BreakStatement, CallExpression, CallSignatureDeclaration, CaseBlock, CaseClause, CaseOrDefaultClause, CatchClause, ClassDeclaration, ClassElement, ClassExpression, ClassStaticBlockDeclaration, ColonToken, CommaListExpression, CompoundAssignmentOperator, ComputedPropertyName, ConciseBody, ConditionalExpression, ConditionalTypeNode, ConstKeyword, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ContinueStatement, DebuggerStatement, DeclarationStatement, DeclareKeyword, Decorator, DefaultClause, DefaultKeyword, DeleteExpression, DoStatement, DotDotDotToken, ElementAccessExpression, EmptyStatement, EntityName, EnumDeclaration, EnumMember, EqualityOperator, EqualityOperatorOrHigher, EqualsGreaterThanToken, EqualsToken, ExclamationToken, ExponentiationOperator, ExportAssignment, ExportDeclaration, ExportKeyword, ExportSpecifier, Expression, ExpressionParent, ExpressionStatement, ExpressionWithTypeArguments, ExternalModuleReference, FalseLiteral, ForInStatement, ForInitializer, ForOfStatement, ForStatement, FunctionBody, FunctionDeclaration, FunctionExpression, FunctionOrConstructorTypeNodeBase, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, Identifier, IfStatement, ImportAttribute, ImportAttributeName, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportExpression, ImportPhaseModifierSyntaxKind, ImportSpecifier, ImportTypeNode, InKeyword, IndexSignatureDeclaration, IndexedAccessTypeNode, InferTypeNode, InterfaceDeclaration, IntersectionTypeNode, IntrinsicKeyword, IterationStatement, JSDocAllType, JSDocComment, JSDocFunctionType, JSDocLink, JSDocLinkCode, JSDocLinkPlain, JSDocMemberName, JSDocNamepathType, JSDocNamespaceBody, JSDocNamespaceDeclaration, JSDocNonNullableType, JSDocNullableType, JSDocOptionalType, JSDocParameterTag, JSDocPropertyLikeTag, JSDocPropertyTag, JSDocReturnTag, JSDocSignature, JSDocTemplateTag, JSDocText, JSDocType, JSDocTypeExpression, JSDocTypeLiteral, JSDocUnknownType, JSDocVariadicType, JsxAttribute, JsxAttributeLike, JsxAttributeName, JsxAttributeValue, JsxAttributes, JsxChild, JsxClosingElement, JsxClosingFragment, JsxElement, JsxExpression, JsxFragment, JsxNamespacedName, JsxOpeningElement, JsxOpeningFragment, JsxSelfClosingElement, JsxSpreadAttribute, JsxTagNameExpression, JsxTagNamePropertyAccess, JsxText, LabeledStatement, LeftHandSideExpression, LeftHandSideExpressionParent, LiteralExpression, LiteralTypeNode, LogicalOperator, LogicalOperatorOrHigher, MappedTypeNode, MemberExpression, MemberName, MetaProperty, MethodDeclaration, MethodSignature, MinusToken, MissingDeclaration, Modifier, ModifierLike, ModifierParent, ModuleBlock, ModuleBody, ModuleDeclaration, ModuleExportName, ModuleName, ModuleReference, MultiplicativeOperator, MultiplicativeOperatorOrHigher, NamedExportBindings, NamedExports, NamedImportBindings, NamedImports, NamedTupleMember, NamespaceBody, NamespaceDeclaration, NamespaceExport, NamespaceExportDeclaration, NamespaceImport, NeverKeyword, NewExpression, NoSubstitutionTemplateLiteral, NodeWithTypeArguments, NonNullExpression, NotEmittedStatement, NotEmittedTypeElement, NullLiteral, NumberKeyword, NumericLiteral, ObjectBindingPattern, ObjectKeyword, ObjectLiteralElementLike, ObjectLiteralExpression, ObjectLiteralExpressionBase, OmittedExpression, OptionalTypeNode, OutKeyword, OverrideKeyword, ParameterDeclaration, ParenthesizedExpression, ParenthesizedTypeNode, PartiallyEmittedExpression, PlusToken, PostfixUnaryExpression, PostfixUnaryOperator, PrefixUnaryExpression, PrefixUnaryOperator, PrimaryExpression, PrivateIdentifier, PrivateKeyword, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertyName, PropertySignature, ProtectedKeyword, PublicKeyword, QualifiedName, QuestionDotToken, QuestionToken, ReadonlyKeyword, RegularExpressionLiteral, RelationalOperator, RelationalOperatorOrHigher, RestTypeNode, ReturnStatement, SatisfiesExpression, SemicolonClassElement, SetAccessorDeclaration, ShiftOperator, ShiftOperatorOrHigher, ShorthandPropertyAssignment, SourceFile, SpreadAssignment, SpreadElement, Statement, StatementParent, StaticKeyword, StringKeyword, StringLiteral, SuperExpression, SwitchStatement, SymbolKeyword, SyntheticExpression, TaggedTemplateExpression, TemplateExpression, TemplateHead, TemplateLiteral, TemplateLiteralTypeNode, TemplateLiteralTypeSpan, TemplateMiddle, TemplateSpan, TemplateTail, ThisExpression, ThisTypeNode, ThrowStatement, TrueLiteral, TryStatement, TupleTypeNode, TypeAliasDeclaration, TypeAssertion, TypeElement, TypeLiteralNode, TypeNode, TypeNodeParent, TypeOfExpression, TypeOperatorNode, TypeParameterDeclaration, TypePredicateNode, TypeQueryNode, TypeReferenceNode, UnaryExpression, UndefinedKeyword, UnionTypeNode, UnknownKeyword, UpdateExpression, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, VoidKeyword, WhileStatement, WithStatement, YieldExpression };
|
|
19
19
|
}
|
|
@@ -2080,16 +2080,63 @@ type ModifierParent = AccessorDeclaration | ArrowFunction | ClassDeclaration | C
|
|
|
2080
2080
|
type StatementParent = Block | CaseOrDefaultClause | IfStatement | IterationStatement | LabeledStatement | ModuleBlock | SourceFile | WithStatement;
|
|
2081
2081
|
type TypeNodeParent = AccessorDeclaration | ArrayTypeNode | ArrowFunction | AsExpression | CallExpression | CallSignatureDeclaration | ConditionalTypeNode | ConstructorDeclaration | ConstructSignatureDeclaration | FunctionDeclaration | FunctionExpression | FunctionOrConstructorTypeNodeBase | IndexedAccessTypeNode | IndexSignatureDeclaration | IntersectionTypeNode | JSDocFunctionType | JSDocNamepathType | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocTypeExpression | JSDocVariadicType | JsxOpeningElement | JsxSelfClosingElement | MappedTypeNode | MethodDeclaration | MethodSignature | NamedTupleMember | NewExpression | NodeWithTypeArguments | OptionalTypeNode | ParameterDeclaration | ParenthesizedTypeNode | PropertyDeclaration | PropertySignature | RestTypeNode | SatisfiesExpression | TaggedTemplateExpression | TemplateLiteralTypeSpan | TupleTypeNode | TypeAliasDeclaration | TypeAssertion | TypeOperatorNode | TypeParameterDeclaration | TypePredicateNode | UnionTypeNode | VariableDeclaration;
|
|
2082
2082
|
//#endregion
|
|
2083
|
+
//#region src/types/checker.d.ts
|
|
2084
|
+
type Checker = CheckerOverrides & Omit<TypeChecker, keyof CheckerOverrides>;
|
|
2085
|
+
interface CheckerOverrides {
|
|
2086
|
+
getResolvedSignature(node: CallExpression | Decorator | JsxOpeningElement | JsxSelfClosingElement | NewExpression | TaggedTemplateExpression | CallLikeExpression): Signature | undefined;
|
|
2087
|
+
/** Improve narrowing, borrow from typescript-eslint */
|
|
2088
|
+
isArrayType(type: Type): type is TypeReference;
|
|
2089
|
+
isTupleType(type: Type): type is TupleTypeReference;
|
|
2090
|
+
/**
|
|
2091
|
+
* TS internal api
|
|
2092
|
+
* Return the type of the given property in the given type, or undefined if no such property exists
|
|
2093
|
+
*/
|
|
2094
|
+
getTypeOfPropertyOfType(type: Type, propertyName: string): Type | undefined;
|
|
2095
|
+
/**
|
|
2096
|
+
* TS internal api
|
|
2097
|
+
*/
|
|
2098
|
+
getContextualTypeForArgumentAtIndex(node: Node, argIndex: number): Type;
|
|
2099
|
+
}
|
|
2100
|
+
//#endregion
|
|
2101
|
+
//#region src/types/services.d.ts
|
|
2102
|
+
interface TypeScriptFileServices {
|
|
2103
|
+
program: Program;
|
|
2104
|
+
sourceFile: SourceFile;
|
|
2105
|
+
typeChecker: Checker;
|
|
2106
|
+
}
|
|
2107
|
+
//#endregion
|
|
2108
|
+
//#region src/createNodeVisitorsForFile.d.ts
|
|
2109
|
+
/**
|
|
2110
|
+
* All visitor subscriptions for a file, along with the callback to run on them.
|
|
2111
|
+
*/
|
|
2112
|
+
interface NodeVisitorsForFile {
|
|
2113
|
+
enter: NodeVisitorSubscriptionsByKind | undefined;
|
|
2114
|
+
exit: NodeVisitorSubscriptionsByKind | undefined;
|
|
2115
|
+
visit: (node: Node) => void;
|
|
2116
|
+
}
|
|
2117
|
+
/**
|
|
2118
|
+
* For each node, the visitor subscriptions that will run when that node is visited.
|
|
2119
|
+
*/
|
|
2120
|
+
type NodeVisitorSubscriptions = FileVisitorSubscription<Node, TypeScriptFileServices>[];
|
|
2121
|
+
/**
|
|
2122
|
+
* For each node kind that has visitors registered, its associated subscriptions.
|
|
2123
|
+
*/
|
|
2124
|
+
type NodeVisitorSubscriptionsByKind = Partial<Record<SyntaxKind, NodeVisitorSubscriptions>>;
|
|
2125
|
+
/**
|
|
2126
|
+
* Given all rule visitors for a file, collects them into a single {@link NodeVisitorsForFile}.
|
|
2127
|
+
*/
|
|
2128
|
+
export declare function createNodeVisitorsForFile(fileVisitors: readonly FileVisitors<object, TypeScriptFileServices>[]): NodeVisitorsForFile | undefined;
|
|
2129
|
+
//#endregion
|
|
2083
2130
|
//#region src/directives/parseDirectivesFromTypeScriptFile.d.ts
|
|
2084
2131
|
interface ExtractedDirective {
|
|
2085
2132
|
range: NormalizedReportRangeObject;
|
|
2086
2133
|
selection: string;
|
|
2087
2134
|
type: string;
|
|
2088
2135
|
}
|
|
2089
|
-
declare function extractDirectivesFromTypeScriptFile(sourceFile: SourceFile): ExtractedDirective[];
|
|
2136
|
+
export declare function extractDirectivesFromTypeScriptFile(sourceFile: SourceFile): ExtractedDirective[];
|
|
2090
2137
|
//#endregion
|
|
2091
2138
|
//#region src/getTSNodeRange.d.ts
|
|
2092
|
-
declare function getTSNodeRange(node: ts$1.Node, sourceFile: SourceFile): CharacterReportRange;
|
|
2139
|
+
export declare function getTSNodeRange(node: ts$1.Node, sourceFile: SourceFile): CharacterReportRange;
|
|
2093
2140
|
//#endregion
|
|
2094
2141
|
//#region src/nodes.d.ts
|
|
2095
2142
|
interface TypeScriptNodesByName {
|
|
@@ -2290,41 +2337,20 @@ interface TypeScriptNodesByName {
|
|
|
2290
2337
|
}
|
|
2291
2338
|
type TypeScriptNodeVisitors = WithExitKeys<TypeScriptNodesByName>;
|
|
2292
2339
|
//#endregion
|
|
2293
|
-
//#region src/types/checker.d.ts
|
|
2294
|
-
type Checker = CheckerOverrides & Omit<TypeChecker, keyof CheckerOverrides>;
|
|
2295
|
-
interface CheckerOverrides {
|
|
2296
|
-
getResolvedSignature(node: CallExpression | Decorator | JsxOpeningElement | JsxSelfClosingElement | NewExpression | TaggedTemplateExpression | CallLikeExpression): Signature | undefined;
|
|
2297
|
-
/** Improve narrowing, borrow from typescript-eslint */
|
|
2298
|
-
isArrayType(type: Type): type is TypeReference;
|
|
2299
|
-
isTupleType(type: Type): type is TupleTypeReference;
|
|
2300
|
-
/**
|
|
2301
|
-
* TS internal api
|
|
2302
|
-
* Return the type of the given property in the given type, or undefined if no such property exists
|
|
2303
|
-
*/
|
|
2304
|
-
getTypeOfPropertyOfType(type: Type, propertyName: string): Type | undefined;
|
|
2305
|
-
/**
|
|
2306
|
-
* TS internal api
|
|
2307
|
-
*/
|
|
2308
|
-
getContextualTypeForArgumentAtIndex(node: Node, argIndex: number): Type;
|
|
2309
|
-
}
|
|
2310
|
-
//#endregion
|
|
2311
2340
|
//#region src/language.d.ts
|
|
2312
|
-
interface TypeScriptFileServices {
|
|
2313
|
-
program: Program;
|
|
2314
|
-
sourceFile: SourceFile;
|
|
2315
|
-
typeChecker: Checker;
|
|
2316
|
-
}
|
|
2317
|
-
declare const NodeSyntaxKinds: typeof SyntaxKind;
|
|
2318
2341
|
type VolarCreateFile = (data: FileAboutData, program: Program, sourceFile: SourceFile) => VolarLanguageFileDefinition;
|
|
2319
2342
|
type VolarLanguageFileDefinition = LanguageFileDefinition<TypeScriptFileServices> & {
|
|
2320
2343
|
__volarServices: {
|
|
2321
2344
|
getLanguageReports(): LanguageReports;
|
|
2322
|
-
runVisitors(
|
|
2345
|
+
runVisitors(fileVisitors: readonly FileVisitors<TypeScriptNodeVisitors, TypeScriptFileServices>[]): void;
|
|
2323
2346
|
};
|
|
2324
2347
|
};
|
|
2325
|
-
declare function setVolarCreateFile(create: VolarCreateFile): void;
|
|
2326
|
-
declare const typescriptLanguage: Language<TypeScriptNodeVisitors, TypeScriptFileServices>;
|
|
2327
|
-
declare function throwUnknownLanguageExtension(filename: string): never;
|
|
2348
|
+
export declare function setVolarCreateFile(create: VolarCreateFile): void;
|
|
2349
|
+
export declare const typescriptLanguage: Language<TypeScriptNodeVisitors, TypeScriptFileServices>;
|
|
2350
|
+
export declare function throwUnknownLanguageExtension(filename: string): never;
|
|
2351
|
+
//#endregion
|
|
2352
|
+
//#region src/nodeSyntaxKinds.d.ts
|
|
2353
|
+
export declare const NodeSyntaxKinds: typeof SyntaxKind;
|
|
2328
2354
|
//#endregion
|
|
2329
2355
|
//#region src/scope/types.d.ts
|
|
2330
2356
|
type FunctionWithParameters = ArrowFunction | ConstructorDeclaration | FunctionDeclaration | FunctionExpression | GetAccessorDeclaration | MethodDeclaration | SetAccessorDeclaration;
|
|
@@ -2364,40 +2390,40 @@ interface ScopeVariable {
|
|
|
2364
2390
|
}
|
|
2365
2391
|
//#endregion
|
|
2366
2392
|
//#region src/scope/scopeManager.d.ts
|
|
2367
|
-
declare function getScopeManager(sourceFile: SourceFile): ScopeManager;
|
|
2393
|
+
export declare function getScopeManager(sourceFile: SourceFile): ScopeManager;
|
|
2368
2394
|
//#endregion
|
|
2369
2395
|
//#region src/utils/createRuleTesterTSConfig.d.ts
|
|
2370
|
-
declare function createRuleTesterTSConfig(defaultCompilerOptions?: Record<string, unknown>): {
|
|
2396
|
+
export declare function createRuleTesterTSConfig(defaultCompilerOptions?: Record<string, unknown>): {
|
|
2371
2397
|
"tsconfig.base.json": string;
|
|
2372
2398
|
"tsconfig.json": string;
|
|
2373
2399
|
};
|
|
2374
2400
|
//#endregion
|
|
2375
2401
|
//#region src/utils/declarationIncludesGlobal.d.ts
|
|
2376
|
-
declare function declarationIncludesGlobal(declaration: Declaration, program: Program): boolean;
|
|
2402
|
+
export declare function declarationIncludesGlobal(declaration: Declaration, program: Program): boolean;
|
|
2377
2403
|
//#endregion
|
|
2378
2404
|
//#region src/utils/forEachChild.d.ts
|
|
2379
|
-
declare const forEachChild: <T>(node: AnyNode, cbNode: (node: AnyNode) => T | undefined, cbNodes?: (nodes: ts.NodeArray<AnyNode>) => T | undefined) => T | undefined;
|
|
2405
|
+
export declare const forEachChild: <T>(node: AnyNode, cbNode: (node: AnyNode) => T | undefined, cbNodes?: (nodes: ts.NodeArray<AnyNode>) => T | undefined) => T | undefined;
|
|
2380
2406
|
//#endregion
|
|
2381
2407
|
//#region src/utils/getDeclarationsIfGlobal.d.ts
|
|
2382
|
-
declare function getDeclarationsIfGlobal(node: Expression, typeChecker: Checker, program: Program): Declaration[] | undefined;
|
|
2408
|
+
export declare function getDeclarationsIfGlobal(node: Expression, typeChecker: Checker, program: Program): Declaration[] | undefined;
|
|
2383
2409
|
//#endregion
|
|
2384
2410
|
//#region src/utils/getModifyingReferences.d.ts
|
|
2385
2411
|
/**
|
|
2386
2412
|
* Gets all references to a variable that modify it (assignments, increments, decrements).
|
|
2387
2413
|
* @returns An array of identifier nodes that modify the variable.
|
|
2388
2414
|
*/
|
|
2389
|
-
declare function getModifyingReferences(identifier: Identifier, sourceFile: SourceFile): Identifier[];
|
|
2415
|
+
export declare function getModifyingReferences(identifier: Identifier, sourceFile: SourceFile): Identifier[];
|
|
2390
2416
|
//#endregion
|
|
2391
2417
|
//#region src/utils/getStaticValue.d.ts
|
|
2392
2418
|
interface StaticValue {
|
|
2393
2419
|
value: unknown;
|
|
2394
2420
|
}
|
|
2395
|
-
declare function getStaticNumberValue(node: Expression): number | undefined;
|
|
2396
|
-
declare function getStaticStringValue(node: Expression): string | undefined;
|
|
2397
|
-
declare function getStaticValue(node: Expression): StaticValue | undefined;
|
|
2421
|
+
export declare function getStaticNumberValue(node: Expression): number | undefined;
|
|
2422
|
+
export declare function getStaticStringValue(node: Expression): string | undefined;
|
|
2423
|
+
export declare function getStaticValue(node: Expression): StaticValue | undefined;
|
|
2398
2424
|
//#endregion
|
|
2399
2425
|
//#region src/utils/hasSameTokens.d.ts
|
|
2400
|
-
declare function hasSameTokens(nodeA: AnyNode, nodeB: AnyNode, sourceFile: SourceFile): boolean;
|
|
2426
|
+
export declare function hasSameTokens(nodeA: AnyNode, nodeB: AnyNode, sourceFile: SourceFile): boolean;
|
|
2401
2427
|
//#endregion
|
|
2402
2428
|
//#region src/utils/isBuiltinArrayMethod.d.ts
|
|
2403
2429
|
type BuiltInArrayMethodNode = CallExpression & {
|
|
@@ -2405,19 +2431,19 @@ type BuiltInArrayMethodNode = CallExpression & {
|
|
|
2405
2431
|
expression: ts.Expression;
|
|
2406
2432
|
};
|
|
2407
2433
|
};
|
|
2408
|
-
declare function isBuiltinArrayMethod(name: string, node: CallExpression, typeChecker: Checker): node is BuiltInArrayMethodNode;
|
|
2434
|
+
export declare function isBuiltinArrayMethod(name: string, node: CallExpression, typeChecker: Checker): node is BuiltInArrayMethodNode;
|
|
2409
2435
|
//#endregion
|
|
2410
2436
|
//#region src/utils/isFunction.d.ts
|
|
2411
|
-
declare function isFunction(node: Expression, typeChecker: Checker): boolean;
|
|
2437
|
+
export declare function isFunction(node: Expression, typeChecker: Checker): boolean;
|
|
2412
2438
|
//#endregion
|
|
2413
2439
|
//#region src/utils/isGlobalDeclaration.d.ts
|
|
2414
|
-
declare function isGlobalDeclaration(node: Expression, typeChecker: Checker, program: Program): boolean;
|
|
2440
|
+
export declare function isGlobalDeclaration(node: Expression, typeChecker: Checker, program: Program): boolean;
|
|
2415
2441
|
//#endregion
|
|
2416
2442
|
//#region src/utils/isGlobalDeclarationOfName.d.ts
|
|
2417
2443
|
/**
|
|
2418
2444
|
* TODO: Use a scope analyzer (#400).
|
|
2419
2445
|
*/
|
|
2420
|
-
declare function isGlobalDeclarationOfName(node: Node, name: string, typeChecker: Checker, program: Program): boolean;
|
|
2446
|
+
export declare function isGlobalDeclarationOfName(node: Node, name: string, typeChecker: Checker, program: Program): boolean;
|
|
2421
2447
|
//#endregion
|
|
2422
2448
|
//#region src/utils/isGlobalVariable.d.ts
|
|
2423
2449
|
/**
|
|
@@ -2426,7 +2452,7 @@ declare function isGlobalDeclarationOfName(node: Node, name: string, typeChecker
|
|
|
2426
2452
|
* like undefined which have symbols but no user-defined declarations.
|
|
2427
2453
|
* TODO: Use a scope manager (#400).
|
|
2428
2454
|
*/
|
|
2429
|
-
declare function isGlobalVariable(node: Expression, typeChecker: Checker, program: Program): boolean;
|
|
2455
|
+
export declare function isGlobalVariable(node: Expression, typeChecker: Checker, program: Program): boolean;
|
|
2430
2456
|
//#endregion
|
|
2431
2457
|
//#region src/utils/isInlineArrayCreation.d.ts
|
|
2432
2458
|
/**
|
|
@@ -2434,22 +2460,22 @@ declare function isGlobalVariable(node: Expression, typeChecker: Checker, progra
|
|
|
2434
2460
|
* These are cases where a new array is created immediately before the method call,
|
|
2435
2461
|
* so mutating methods like .sort() or .reverse() are safe to use.
|
|
2436
2462
|
*/
|
|
2437
|
-
declare function isInlineArrayCreation(node:
|
|
2463
|
+
export declare function isInlineArrayCreation(node: Expression): boolean;
|
|
2438
2464
|
//#endregion
|
|
2439
2465
|
//#region src/utils/isStaticString.d.ts
|
|
2440
2466
|
type StaticString = NoSubstitutionTemplateLiteral | StringLiteral;
|
|
2441
|
-
declare function isStaticString(node: Expression): node is StaticString;
|
|
2467
|
+
export declare function isStaticString(node: Expression): node is StaticString;
|
|
2442
2468
|
//#endregion
|
|
2443
2469
|
//#region src/utils/isStringRawNoSubstitution.d.ts
|
|
2444
2470
|
interface StringRawNoSubstitution extends TaggedTemplateExpression {
|
|
2445
2471
|
template: NoSubstitutionTemplateLiteral;
|
|
2446
2472
|
}
|
|
2447
|
-
declare function isStringRawNoSubstitution(node: Expression): node is StringRawNoSubstitution;
|
|
2473
|
+
export declare function isStringRawNoSubstitution(node: Expression): node is StringRawNoSubstitution;
|
|
2448
2474
|
//#endregion
|
|
2449
2475
|
//#region src/utils/unwrapParenthesizedNode.d.ts
|
|
2450
|
-
declare function unwrapParenthesizedNode(node: AnyNode): AnyNode;
|
|
2476
|
+
export declare function unwrapParenthesizedNode(node: AnyNode): AnyNode;
|
|
2451
2477
|
//#endregion
|
|
2452
2478
|
//#region src/utils/unwrapParentParenthesizedExpressions.d.ts
|
|
2453
|
-
declare function unwrapParentParenthesizedExpressions(node: BinaryExpression | ParenthesizedExpression): LeftHandSideExpressionParent;
|
|
2479
|
+
export declare function unwrapParentParenthesizedExpressions(node: BinaryExpression | ParenthesizedExpression): LeftHandSideExpressionParent;
|
|
2454
2480
|
//#endregion
|
|
2455
|
-
export {
|
|
2481
|
+
export type { ast_d_exports as AST, BuiltInArrayMethodNode, Checker, ExtractedDirective, FunctionWithParameters, NodeVisitorSubscriptions, NodeVisitorsForFile, Scope, ScopeDefinition, ScopeDefinitionKind, ScopeManager, ScopeReference, ScopeVariable, StaticString, StaticValue, StringRawNoSubstitution, TSDiagnostic, TypeScriptFileServices, TypeScriptNodeVisitors, TypeScriptNodesByName };
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import ts, { SyntaxKind, getPreEmitDiagnostics
|
|
2
|
-
import { DirectivesCollector, commonlyIgnoredPaths, createLanguage, getColumnAndLineOfPosition, getPositionOfColumnAndLine } from "@flint.fyi/core";
|
|
1
|
+
import ts, { SyntaxKind, getPreEmitDiagnostics } from "typescript";
|
|
2
|
+
import { DirectivesCollector, commonlyIgnoredPaths, createLanguage, getColumnAndLineOfPosition, getPositionOfColumnAndLine, groupFileVisitors, runFileVisitorSubscriptions } from "@flint.fyi/core";
|
|
3
3
|
import * as tsutils from "ts-api-utils";
|
|
4
4
|
import { FlintAssertionError, assert, normalizePath, nullThrows, pathKey } from "@flint.fyi/utils";
|
|
5
|
-
import * as path$1 from "node:path";
|
|
6
|
-
import path from "node:path";
|
|
7
5
|
import { createProjectService } from "@typescript-eslint/project-service";
|
|
8
6
|
import { debugForFile } from "debug-for-file";
|
|
7
|
+
import { dirname, extname, relative, resolve } from "pathe";
|
|
9
8
|
import fs from "node:fs";
|
|
10
9
|
import timers from "node:timers";
|
|
11
|
-
import { dirname, resolve } from "pathe";
|
|
12
10
|
import { WeakCachedFactory } from "cached-factory";
|
|
13
11
|
//#region src/convertTypeScriptDiagnosticToLanguageReport.ts
|
|
14
12
|
function convertTypeScriptDiagnosticToLanguageReport(diagnostic) {
|
|
@@ -119,6 +117,102 @@ function formatLocation(file, start) {
|
|
|
119
117
|
return output;
|
|
120
118
|
}
|
|
121
119
|
//#endregion
|
|
120
|
+
//#region src/getFirstEnumValues.ts
|
|
121
|
+
/**
|
|
122
|
+
* Removes TypeScript enum values that alias earlier values.
|
|
123
|
+
* @param original Any TypeScript enum with numeric values.
|
|
124
|
+
* @returns A version of the enum with only the first occurrence of each value.
|
|
125
|
+
* @example
|
|
126
|
+
* Given the following enum:
|
|
127
|
+
* ```ts
|
|
128
|
+
* enum Example {
|
|
129
|
+
* A = 1,
|
|
130
|
+
* B = 2,
|
|
131
|
+
* C = A
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
* Its original value looks like:
|
|
135
|
+
* ```ts
|
|
136
|
+
* {
|
|
137
|
+
* 1: 'C', // <-- Points to 'C', the alias of 'A'
|
|
138
|
+
* 2: 'B',
|
|
139
|
+
* A: 1,
|
|
140
|
+
* B: 2,
|
|
141
|
+
* C: 1,
|
|
142
|
+
* }
|
|
143
|
+
* ```
|
|
144
|
+
* Calling `getFirstEnumValues(Example)` would return:
|
|
145
|
+
* ```ts
|
|
146
|
+
* {
|
|
147
|
+
* 1: 'A', // <-- Corrected to the original 'A'
|
|
148
|
+
* 2: 'B',
|
|
149
|
+
* A: 1,
|
|
150
|
+
* B: 2,
|
|
151
|
+
* C: 1,
|
|
152
|
+
* }
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
function getFirstEnumValues(original) {
|
|
156
|
+
const result = {};
|
|
157
|
+
for (const key in original) {
|
|
158
|
+
if (typeof original[key] !== "number") continue;
|
|
159
|
+
if (!(key in result)) result[key] = original[key];
|
|
160
|
+
if (!(original[key] in result)) result[original[key]] = key;
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/nodeSyntaxKinds.ts
|
|
166
|
+
const NodeSyntaxKinds = getFirstEnumValues(SyntaxKind);
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/createNodeVisitorsForFile.ts
|
|
169
|
+
/**
|
|
170
|
+
* Given all rule visitors for a file, collects them into a single {@link NodeVisitorsForFile}.
|
|
171
|
+
*/
|
|
172
|
+
function createNodeVisitorsForFile(fileVisitors) {
|
|
173
|
+
const grouped = groupFileVisitors(fileVisitors);
|
|
174
|
+
const enter = grouped.enter && createSubscriptionsByKind(grouped.enter);
|
|
175
|
+
const exit = grouped.exit && createSubscriptionsByKind(grouped.exit);
|
|
176
|
+
if (enter) {
|
|
177
|
+
const visit = exit ? (node) => {
|
|
178
|
+
const entering = enter[node.kind];
|
|
179
|
+
if (entering !== void 0) runFileVisitorSubscriptions(entering, node);
|
|
180
|
+
node.forEachChild(visit);
|
|
181
|
+
const exiting = exit[node.kind];
|
|
182
|
+
if (exiting !== void 0) runFileVisitorSubscriptions(exiting, node);
|
|
183
|
+
} : (node) => {
|
|
184
|
+
const entering = enter[node.kind];
|
|
185
|
+
if (entering !== void 0) runFileVisitorSubscriptions(entering, node);
|
|
186
|
+
node.forEachChild(visit);
|
|
187
|
+
};
|
|
188
|
+
return {
|
|
189
|
+
enter,
|
|
190
|
+
exit,
|
|
191
|
+
visit
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
if (exit) {
|
|
195
|
+
const visit = (node) => {
|
|
196
|
+
node.forEachChild(visit);
|
|
197
|
+
const exiting = exit[node.kind];
|
|
198
|
+
if (exiting !== void 0) runFileVisitorSubscriptions(exiting, node);
|
|
199
|
+
};
|
|
200
|
+
return {
|
|
201
|
+
enter,
|
|
202
|
+
exit,
|
|
203
|
+
visit
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function createSubscriptionsByKind(group) {
|
|
208
|
+
const byKind = Object.create(null);
|
|
209
|
+
for (const [name, subscriptions] of group) {
|
|
210
|
+
const kind = NodeSyntaxKinds[name];
|
|
211
|
+
if (typeof kind === "number" && NodeSyntaxKinds[kind] === name) byKind[kind] = subscriptions;
|
|
212
|
+
}
|
|
213
|
+
return byKind;
|
|
214
|
+
}
|
|
215
|
+
//#endregion
|
|
122
216
|
//#region src/normalizeRange.ts
|
|
123
217
|
function normalizeRange(original, sourceFile) {
|
|
124
218
|
const onCharacters = isNode(original) ? {
|
|
@@ -203,7 +297,7 @@ function getTSNodeRange(node, sourceFile) {
|
|
|
203
297
|
//#endregion
|
|
204
298
|
//#region package.json
|
|
205
299
|
var name = "@flint.fyi/typescript-language";
|
|
206
|
-
var version = "0.
|
|
300
|
+
var version = "0.21.0";
|
|
207
301
|
//#endregion
|
|
208
302
|
//#region src/createTypeScriptServerHost.ts
|
|
209
303
|
function serverHostMethodNotImplemented(methodName) {
|
|
@@ -300,57 +394,15 @@ function createTypeScriptServerHost(host) {
|
|
|
300
394
|
};
|
|
301
395
|
}
|
|
302
396
|
//#endregion
|
|
303
|
-
//#region src/
|
|
304
|
-
|
|
305
|
-
* Removes TypeScript enum values that alias earlier values.
|
|
306
|
-
* @param original Any TypeScript enum with numeric values.
|
|
307
|
-
* @returns A version of the enum with only the first occurrence of each value.
|
|
308
|
-
* @example
|
|
309
|
-
* Given the following enum:
|
|
310
|
-
* ```ts
|
|
311
|
-
* enum Example {
|
|
312
|
-
* A = 1,
|
|
313
|
-
* B = 2,
|
|
314
|
-
* C = A
|
|
315
|
-
* }
|
|
316
|
-
* ```
|
|
317
|
-
* Its original value looks like:
|
|
318
|
-
* ```ts
|
|
319
|
-
* {
|
|
320
|
-
* 1: 'C', // <-- Points to 'C', the alias of 'A'
|
|
321
|
-
* 2: 'B',
|
|
322
|
-
* A: 1,
|
|
323
|
-
* B: 2,
|
|
324
|
-
* C: 1,
|
|
325
|
-
* }
|
|
326
|
-
* ```
|
|
327
|
-
* Calling `getFirstEnumValues(Example)` would return:
|
|
328
|
-
* ```ts
|
|
329
|
-
* {
|
|
330
|
-
* 1: 'A', // <-- Corrected to the original 'A'
|
|
331
|
-
* 2: 'B',
|
|
332
|
-
* A: 1,
|
|
333
|
-
* B: 2,
|
|
334
|
-
* C: 1,
|
|
335
|
-
* }
|
|
336
|
-
* ```
|
|
337
|
-
*/
|
|
338
|
-
function getFirstEnumValues(original) {
|
|
339
|
-
const result = {};
|
|
340
|
-
for (const key in original) {
|
|
341
|
-
if (typeof original[key] !== "number") continue;
|
|
342
|
-
if (!(key in result)) result[key] = original[key];
|
|
343
|
-
if (!(original[key] in result)) result[original[key]] = key;
|
|
344
|
-
}
|
|
345
|
-
return result;
|
|
346
|
-
}
|
|
397
|
+
//#region src/utils/forEachChild.ts
|
|
398
|
+
const forEachChild = ts.forEachChild;
|
|
347
399
|
//#endregion
|
|
348
400
|
//#region src/collectReferencedFilePaths.ts
|
|
349
401
|
function collectReferencedFilePaths(program, sourceFile) {
|
|
350
402
|
const modulePaths = /* @__PURE__ */ new Set();
|
|
351
403
|
function resolveModulePath(moduleSpecifier) {
|
|
352
404
|
const resolved = ts.resolveModuleName(moduleSpecifier, sourceFile.fileName, program.getCompilerOptions(), ts.sys);
|
|
353
|
-
if (resolved.resolvedModule?.isExternalLibraryImport === false) return
|
|
405
|
+
if (resolved.resolvedModule?.isExternalLibraryImport === false) return relative(program.getCurrentDirectory(), resolved.resolvedModule.resolvedFileName);
|
|
354
406
|
}
|
|
355
407
|
function visit(node) {
|
|
356
408
|
let path;
|
|
@@ -361,25 +413,25 @@ function collectReferencedFilePaths(program, sourceFile) {
|
|
|
361
413
|
else if (isImportTypeNode(node)) path = node.argument.literal.text;
|
|
362
414
|
const resolvedPath = path && resolveModulePath(path);
|
|
363
415
|
if (resolvedPath) modulePaths.add(resolvedPath);
|
|
364
|
-
|
|
416
|
+
forEachChild(node, visit);
|
|
365
417
|
}
|
|
366
418
|
visit(sourceFile);
|
|
367
419
|
return Array.from(modulePaths);
|
|
368
420
|
}
|
|
369
421
|
function isAwaitImportCall(node) {
|
|
370
|
-
return
|
|
422
|
+
return node.kind === SyntaxKind.AwaitExpression && isImportCall(node.expression);
|
|
371
423
|
}
|
|
372
424
|
function isExportDeclaration(node) {
|
|
373
|
-
return
|
|
425
|
+
return node.kind === SyntaxKind.ExportDeclaration && node.moduleSpecifier?.kind === SyntaxKind.StringLiteral;
|
|
374
426
|
}
|
|
375
427
|
function isImportCall(node) {
|
|
376
|
-
return
|
|
428
|
+
return node.kind === SyntaxKind.CallExpression && node.expression.kind === SyntaxKind.ImportKeyword && node.arguments[0]?.kind === SyntaxKind.StringLiteral;
|
|
377
429
|
}
|
|
378
430
|
function isImportDeclaration(node) {
|
|
379
|
-
return
|
|
431
|
+
return node.kind === SyntaxKind.ImportDeclaration && node.moduleSpecifier.kind === SyntaxKind.StringLiteral;
|
|
380
432
|
}
|
|
381
433
|
function isImportTypeNode(node) {
|
|
382
|
-
return
|
|
434
|
+
return node.kind === SyntaxKind.ImportType && node.argument.kind === SyntaxKind.LiteralType && node.argument.literal.kind === SyntaxKind.StringLiteral;
|
|
383
435
|
}
|
|
384
436
|
//#endregion
|
|
385
437
|
//#region src/utils/containsGlobalDeclarations.ts
|
|
@@ -390,7 +442,7 @@ function isImportTypeNode(node) {
|
|
|
390
442
|
function containsGlobalDeclarations(sourceFileNode) {
|
|
391
443
|
const isModule = ts.isExternalModule(sourceFileNode);
|
|
392
444
|
return sourceFileNode.statements.some((statement) => {
|
|
393
|
-
if (
|
|
445
|
+
if (statement.kind === SyntaxKind.ModuleDeclaration && statement.name.text === "global") return true;
|
|
394
446
|
if (isModule) return false;
|
|
395
447
|
if (!ts.canHaveModifiers(statement)) return false;
|
|
396
448
|
return ts.getModifiers(statement)?.some((mod) => mod.kind === SyntaxKind.DeclareKeyword);
|
|
@@ -491,8 +543,7 @@ function orderTypeScriptFilePaths(filePaths, host) {
|
|
|
491
543
|
}
|
|
492
544
|
//#endregion
|
|
493
545
|
//#region src/language.ts
|
|
494
|
-
const log = debugForFile(import.meta.
|
|
495
|
-
const NodeSyntaxKinds = getFirstEnumValues(SyntaxKind);
|
|
546
|
+
const log = debugForFile(import.meta.url);
|
|
496
547
|
const stateSymbol = Symbol.for("@flint.fyi/typescript-language/state");
|
|
497
548
|
const globalTyped = globalThis;
|
|
498
549
|
assert(globalTyped[stateSymbol] == null, `Two different versions of ${name} are imported: ${version} and ${globalTyped[stateSymbol]?.packageVersion}`);
|
|
@@ -516,7 +567,7 @@ const typescriptLanguage = createLanguage({
|
|
|
516
567
|
const defaultProject = nullThrows(service.getDefaultProjectForFile(scriptInfo.fileName, true), `Could not find default project for file: ${data.filePathAbsolute}`);
|
|
517
568
|
const program = nullThrows(defaultProject.getLanguageService(true).getProgram(), `Could not retrieve program for file: ${data.filePathAbsolute}`);
|
|
518
569
|
const sourceFile = nullThrows(program.getSourceFile(data.filePathAbsolute), `Could not retrieve source file for: ${data.filePathAbsolute}`);
|
|
519
|
-
const fileExtension =
|
|
570
|
+
const fileExtension = extname(data.filePathAbsolute);
|
|
520
571
|
if (typeScriptCoreSupportedExtensions.has(fileExtension)) return {
|
|
521
572
|
...parseDirectivesFromTypeScriptFile(sourceFile),
|
|
522
573
|
about: data,
|
|
@@ -546,24 +597,12 @@ const typescriptLanguage = createLanguage({
|
|
|
546
597
|
return getPreEmitDiagnostics(file.services.program, file.services.sourceFile).map(convertTypeScriptDiagnosticToLanguageReport);
|
|
547
598
|
},
|
|
548
599
|
orderFilePaths: orderTypeScriptFilePaths,
|
|
549
|
-
runFileVisitors(file,
|
|
550
|
-
if (!runtime.visitors) return;
|
|
600
|
+
runFileVisitors(file, fileVisitors) {
|
|
551
601
|
if ("__volarServices" in file) {
|
|
552
|
-
file.__volarServices.runVisitors(
|
|
602
|
+
file.__volarServices.runVisitors(fileVisitors);
|
|
553
603
|
return;
|
|
554
604
|
}
|
|
555
|
-
|
|
556
|
-
const visitorServices = {
|
|
557
|
-
options,
|
|
558
|
-
...file.services
|
|
559
|
-
};
|
|
560
|
-
const visit = (node) => {
|
|
561
|
-
const key = NodeSyntaxKinds[node.kind];
|
|
562
|
-
visitors[key]?.(node, visitorServices);
|
|
563
|
-
node.forEachChild(visit);
|
|
564
|
-
visitors[`${key}:exit`]?.(node, visitorServices);
|
|
565
|
-
};
|
|
566
|
-
visit(file.services.sourceFile);
|
|
605
|
+
createNodeVisitorsForFile(fileVisitors)?.visit(file.services.sourceFile);
|
|
567
606
|
}
|
|
568
607
|
});
|
|
569
608
|
const typeScriptCoreSupportedExtensions = /* @__PURE__ */ new Set([
|
|
@@ -589,14 +628,11 @@ const fileExtToFlintPlugin = {
|
|
|
589
628
|
".vue": "@flint.fyi/vue"
|
|
590
629
|
};
|
|
591
630
|
function throwUnknownLanguageExtension(filename) {
|
|
592
|
-
const pluginName = fileExtToFlintPlugin[
|
|
631
|
+
const pluginName = fileExtToFlintPlugin[extname(filename)];
|
|
593
632
|
const message = pluginName ? `Did you install & import ${pluginName}?` : "Unknown extension.";
|
|
594
633
|
throw new Error(`Cannot process ${filename}. ${message}`);
|
|
595
634
|
}
|
|
596
635
|
//#endregion
|
|
597
|
-
//#region src/utils/forEachChild.ts
|
|
598
|
-
const forEachChild = ts.forEachChild;
|
|
599
|
-
//#endregion
|
|
600
636
|
//#region src/scope/identifierReferences.ts
|
|
601
637
|
function isNonReferenceIdentifier(identifier) {
|
|
602
638
|
if (isIdentifierDeclaration(identifier) || isTypeReferenceIdentifier(identifier)) return true;
|
|
@@ -997,7 +1033,7 @@ function hasSameTokens(nodeA, nodeB, sourceFile) {
|
|
|
997
1033
|
return queueA.length === queueB.length;
|
|
998
1034
|
}
|
|
999
1035
|
function areSameToken(nodeA, nodeB, sourceFile) {
|
|
1000
|
-
if (
|
|
1036
|
+
if (nodeA.kind === SyntaxKind.Identifier || nodeA.kind === SyntaxKind.PrivateIdentifier || nodeA.kind === SyntaxKind.NumericLiteral || nodeA.kind === SyntaxKind.BigIntLiteral || nodeA.kind === SyntaxKind.StringLiteral || nodeA.kind === SyntaxKind.NoSubstitutionTemplateLiteral) return nodeA.text === nodeB.text;
|
|
1001
1037
|
if (nodeA.kind === SyntaxKind.RegularExpressionLiteral) return sourceFile.text.slice(nodeA.getStart(sourceFile), nodeA.getEnd()) === sourceFile.text.slice(nodeB.getStart(sourceFile), nodeB.getEnd());
|
|
1002
1038
|
return true;
|
|
1003
1039
|
}
|
|
@@ -1024,15 +1060,21 @@ function isGlobalDeclaration(node, typeChecker, program) {
|
|
|
1024
1060
|
function isGlobalDeclarationOfName(node, name, typeChecker, program) {
|
|
1025
1061
|
const declarations = typeChecker.getSymbolAtLocation(node)?.getDeclarations();
|
|
1026
1062
|
if (!declarations) return false;
|
|
1027
|
-
return declarations.every((
|
|
1028
|
-
|
|
1029
|
-
if (
|
|
1030
|
-
|
|
1063
|
+
return declarations.every((tsDeclaration) => {
|
|
1064
|
+
const declaration = tsDeclaration;
|
|
1065
|
+
if (declaration.kind === SyntaxKind.VariableDeclaration && declaration.initializer?.kind === SyntaxKind.Identifier) return isGlobalDeclarationOfName(declaration.initializer, name, typeChecker, program);
|
|
1066
|
+
if (declaration.kind === SyntaxKind.PropertySignature) return isGlobalDeclarationOfName(declaration.parent, name, typeChecker, program);
|
|
1067
|
+
return isDeclarationOfName(declaration, name) && declarationIncludesGlobal(tsDeclaration, program);
|
|
1031
1068
|
});
|
|
1032
1069
|
}
|
|
1033
1070
|
function isDeclarationOfName(node, name) {
|
|
1034
|
-
|
|
1035
|
-
|
|
1071
|
+
switch (node.kind) {
|
|
1072
|
+
case SyntaxKind.ClassDeclaration:
|
|
1073
|
+
case SyntaxKind.FunctionDeclaration:
|
|
1074
|
+
case SyntaxKind.InterfaceDeclaration:
|
|
1075
|
+
case SyntaxKind.VariableDeclaration: return node.name?.kind === SyntaxKind.Identifier && node.name.text === name;
|
|
1076
|
+
default: return false;
|
|
1077
|
+
}
|
|
1036
1078
|
}
|
|
1037
1079
|
//#endregion
|
|
1038
1080
|
//#region src/utils/isGlobalVariable.ts
|
|
@@ -1076,18 +1118,18 @@ const objectStaticMethods = /* @__PURE__ */ new Set([
|
|
|
1076
1118
|
* so mutating methods like .sort() or .reverse() are safe to use.
|
|
1077
1119
|
*/
|
|
1078
1120
|
function isInlineArrayCreation(node) {
|
|
1079
|
-
if (
|
|
1080
|
-
if (
|
|
1081
|
-
if (
|
|
1082
|
-
if (
|
|
1121
|
+
if (node.kind === SyntaxKind.ArrayLiteralExpression) return true;
|
|
1122
|
+
if (node.kind === SyntaxKind.ParenthesizedExpression) return isInlineArrayCreation(node.expression);
|
|
1123
|
+
if (node.kind === SyntaxKind.CallExpression) {
|
|
1124
|
+
if (node.expression.kind === SyntaxKind.PropertyAccessExpression) {
|
|
1083
1125
|
const methodName = node.expression.name.text;
|
|
1084
|
-
if (
|
|
1085
|
-
if (
|
|
1126
|
+
if (node.expression.expression.kind === SyntaxKind.Identifier && node.expression.expression.text === "Object" && objectStaticMethods.has(methodName)) return true;
|
|
1127
|
+
if (node.expression.expression.kind === SyntaxKind.Identifier && node.expression.expression.text === "Array" && (methodName === "from" || methodName === "of")) return true;
|
|
1086
1128
|
if (methodsReturningNewArray.has(methodName)) return true;
|
|
1087
1129
|
}
|
|
1088
|
-
if (
|
|
1130
|
+
if (node.expression.kind === SyntaxKind.Identifier && node.expression.text === "Array" && node.parent.kind === SyntaxKind.NewExpression) return true;
|
|
1089
1131
|
}
|
|
1090
|
-
if (
|
|
1132
|
+
if (node.kind === SyntaxKind.NewExpression && node.expression.kind === SyntaxKind.Identifier && node.expression.text === "Array") return true;
|
|
1091
1133
|
return false;
|
|
1092
1134
|
}
|
|
1093
1135
|
//#endregion
|
|
@@ -1108,4 +1150,4 @@ function unwrapParentParenthesizedExpressions(node) {
|
|
|
1108
1150
|
return node.parent.kind === SyntaxKind.ParenthesizedExpression ? unwrapParentParenthesizedExpressions(node.parent) : node.parent;
|
|
1109
1151
|
}
|
|
1110
1152
|
//#endregion
|
|
1111
|
-
export { NodeSyntaxKinds, convertTypeScriptDiagnosticToLanguageReport, createRuleTesterTSConfig, declarationIncludesGlobal, extractDirectivesFromTypeScriptFile, forEachChild, getDeclarationsIfGlobal, getModifyingReferences, getScopeManager, getStaticNumberValue, getStaticStringValue, getStaticValue, getTSNodeRange, hasSameTokens, isBuiltinArrayMethod, isFunction, isGlobalDeclaration, isGlobalDeclarationOfName, isGlobalVariable, isInlineArrayCreation, isStaticString, isStringRawNoSubstitution, setVolarCreateFile, throwUnknownLanguageExtension, typescriptLanguage, unwrapParentParenthesizedExpressions, unwrapParenthesizedNode };
|
|
1153
|
+
export { NodeSyntaxKinds, convertTypeScriptDiagnosticToLanguageReport, createNodeVisitorsForFile, createRuleTesterTSConfig, declarationIncludesGlobal, extractDirectivesFromTypeScriptFile, forEachChild, getDeclarationsIfGlobal, getModifyingReferences, getScopeManager, getStaticNumberValue, getStaticStringValue, getStaticValue, getTSNodeRange, hasSameTokens, isBuiltinArrayMethod, isFunction, isGlobalDeclaration, isGlobalDeclarationOfName, isGlobalVariable, isInlineArrayCreation, isStaticString, isStringRawNoSubstitution, setVolarCreateFile, throwUnknownLanguageExtension, typescriptLanguage, unwrapParentParenthesizedExpressions, unwrapParenthesizedNode };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flint.fyi/typescript-language",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "[Experimental] TypeScript language for Flint.",
|
|
5
5
|
"homepage": "https://flint.fyi",
|
|
6
6
|
"repository": {
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
"dist/"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@flint.fyi/core": "^0.
|
|
25
|
+
"@flint.fyi/core": "^0.27.0",
|
|
26
26
|
"@flint.fyi/utils": "^0.16.0",
|
|
27
27
|
"@typescript-eslint/project-service": "^8.53.0",
|
|
28
28
|
"cached-factory": "^0.3.0",
|
|
29
29
|
"debug-for-file": "^0.4.0",
|
|
30
30
|
"pathe": "^2.0.3",
|
|
31
31
|
"ts-api-utils": "^2.4.0",
|
|
32
|
-
"typescript": "^
|
|
32
|
+
"typescript": "^6.0.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@flint.fyi/build": "^0.1.0",
|
|
36
|
-
"tsdown": "0.
|
|
37
|
-
"vitest": "
|
|
36
|
+
"tsdown": "0.23.0",
|
|
37
|
+
"vitest": "5.0.1"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=26.1.0"
|