blast-radius-analyzer 1.2.1

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.
Files changed (49) hide show
  1. package/README.md +108 -0
  2. package/TEST-REPORT.md +379 -0
  3. package/dist/core/AnalysisCache.d.ts +59 -0
  4. package/dist/core/AnalysisCache.js +156 -0
  5. package/dist/core/BlastRadiusAnalyzer.d.ts +99 -0
  6. package/dist/core/BlastRadiusAnalyzer.js +510 -0
  7. package/dist/core/CallStackBuilder.d.ts +63 -0
  8. package/dist/core/CallStackBuilder.js +269 -0
  9. package/dist/core/DataFlowAnalyzer.d.ts +215 -0
  10. package/dist/core/DataFlowAnalyzer.js +1115 -0
  11. package/dist/core/DependencyGraph.d.ts +55 -0
  12. package/dist/core/DependencyGraph.js +541 -0
  13. package/dist/core/ImpactTracer.d.ts +96 -0
  14. package/dist/core/ImpactTracer.js +398 -0
  15. package/dist/core/PropagationTracker.d.ts +73 -0
  16. package/dist/core/PropagationTracker.js +502 -0
  17. package/dist/core/PropertyAccessTracker.d.ts +56 -0
  18. package/dist/core/PropertyAccessTracker.js +281 -0
  19. package/dist/core/SymbolAnalyzer.d.ts +139 -0
  20. package/dist/core/SymbolAnalyzer.js +608 -0
  21. package/dist/core/TypeFlowAnalyzer.d.ts +120 -0
  22. package/dist/core/TypeFlowAnalyzer.js +654 -0
  23. package/dist/core/TypePropagationAnalyzer.d.ts +58 -0
  24. package/dist/core/TypePropagationAnalyzer.js +269 -0
  25. package/dist/index.d.ts +13 -0
  26. package/dist/index.js +952 -0
  27. package/dist/types.d.ts +102 -0
  28. package/dist/types.js +5 -0
  29. package/package.json +39 -0
  30. package/src/core/AnalysisCache.ts +189 -0
  31. package/src/core/CallStackBuilder.ts +345 -0
  32. package/src/core/DataFlowAnalyzer.ts +1403 -0
  33. package/src/core/DependencyGraph.ts +584 -0
  34. package/src/core/ImpactTracer.ts +521 -0
  35. package/src/core/PropagationTracker.ts +630 -0
  36. package/src/core/PropertyAccessTracker.ts +349 -0
  37. package/src/core/SymbolAnalyzer.ts +746 -0
  38. package/src/core/TypeFlowAnalyzer.ts +844 -0
  39. package/src/core/TypePropagationAnalyzer.ts +332 -0
  40. package/src/index.ts +1071 -0
  41. package/src/types.ts +163 -0
  42. package/test-cases/.blast-radius-cache/file-states.json +14 -0
  43. package/test-cases/config.ts +13 -0
  44. package/test-cases/consumer.ts +12 -0
  45. package/test-cases/nested.ts +25 -0
  46. package/test-cases/simple.ts +62 -0
  47. package/test-cases/tsconfig.json +11 -0
  48. package/test-cases/user.ts +32 -0
  49. package/tsconfig.json +16 -0
@@ -0,0 +1,120 @@
1
+ /**
2
+ * TypeFlowAnalyzer - 商用级 TypeScript 类型流分析器
3
+ *
4
+ * 完整支持:
5
+ * - 泛型类型 T<U>
6
+ * - 条件类型 T extends U ? X : Y
7
+ * - 交叉类型 A & B
8
+ * - 映射类型 { [K in keyof T]: ... }
9
+ * - infer 关键字
10
+ * - Promise/Array/Observable 等内置类型
11
+ * - 类型推导和比较
12
+ */
13
+ export interface TypeIncompatibility {
14
+ file: string;
15
+ line: number;
16
+ column: number;
17
+ expression: string;
18
+ assignedTo?: string;
19
+ propertyAccess?: string[];
20
+ expectedType: string;
21
+ actualType: string;
22
+ reason: string;
23
+ severity: 'error' | 'warning';
24
+ code: string;
25
+ }
26
+ export interface TypeFlowResult {
27
+ hasIncompatibilities: boolean;
28
+ incompatibilities: TypeIncompatibility[];
29
+ confidence: 'high' | 'medium' | 'low';
30
+ method: string;
31
+ analyzedTypes: number;
32
+ duration: number;
33
+ statistics: {
34
+ genericTypes: number;
35
+ conditionalTypes: number;
36
+ intersectionTypes: number;
37
+ promiseTypes: number;
38
+ };
39
+ }
40
+ /**
41
+ * 商用级类型分析器
42
+ */
43
+ export declare class TypeFlowAnalyzer {
44
+ private program;
45
+ private checker;
46
+ private typeCache;
47
+ constructor(projectRoot: string, tsConfigPath: string);
48
+ /**
49
+ * 主分析入口
50
+ */
51
+ analyzeTypeFlow(functionName: string, functionFile: string): TypeFlowResult;
52
+ /**
53
+ * 创建结果
54
+ */
55
+ private createResult;
56
+ /**
57
+ * 查找函数定义
58
+ */
59
+ private findFunctionDefinition;
60
+ /**
61
+ * 查找声明
62
+ */
63
+ private findDeclarations;
64
+ /**
65
+ * 提取所有返回类型
66
+ */
67
+ private extractAllReturnTypes;
68
+ /**
69
+ * 展开类型(处理泛型、条件类型等)
70
+ */
71
+ private expandType;
72
+ /**
73
+ * 提取泛型参数
74
+ */
75
+ private extractGenericArgument;
76
+ /**
77
+ * 解析类型字符串
78
+ */
79
+ private parseTypeString;
80
+ /**
81
+ * 查找所有调用
82
+ */
83
+ private findAllCalls;
84
+ /**
85
+ * 分析单个调用
86
+ */
87
+ private analyzeCall;
88
+ /**
89
+ * 分析返回值的使用
90
+ */
91
+ private analyzeReturnUsage;
92
+ /**
93
+ * 分析 Promise 回调
94
+ */
95
+ private analyzePromiseCallback;
96
+ /**
97
+ * 分析 await 使用
98
+ */
99
+ private analyzeAwaitUsage;
100
+ /**
101
+ * 比较两个类型
102
+ */
103
+ private compareTypes;
104
+ /**
105
+ * 获取行号
106
+ */
107
+ private getLine;
108
+ /**
109
+ * 获取列号
110
+ */
111
+ private getColumn;
112
+ /**
113
+ * 格式化文本报告
114
+ */
115
+ formatAsText(result: TypeFlowResult, _functionName: string): string;
116
+ /**
117
+ * 格式化 HTML 报告
118
+ */
119
+ formatAsHtml(result: TypeFlowResult, _functionName: string): string;
120
+ }