@esportsplus/typescript 0.25.1 → 0.25.2
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.
|
@@ -11,8 +11,7 @@ type ModifyOptions = {
|
|
|
11
11
|
};
|
|
12
12
|
declare const _default: {
|
|
13
13
|
find: (sourceFile: ts.SourceFile, packageName: string) => ImportInfo[];
|
|
14
|
-
isFromPackage: (node: ts.
|
|
15
|
-
isSymbolFromPackage: (checker: ts.TypeChecker, node: ts.Node, packageName: string, symbolName?: string) => boolean;
|
|
14
|
+
isFromPackage: (checker: ts.TypeChecker, node: ts.Node, packageName: string, symbolName?: string) => boolean;
|
|
16
15
|
modify: (sourceCode: string, sourceFile: ts.SourceFile, packageName: string, options: ModifyOptions) => string;
|
|
17
16
|
trace: (node: ts.Identifier, checker: ts.TypeChecker) => string | null;
|
|
18
17
|
};
|
|
@@ -22,14 +22,7 @@ const find = (sourceFile, packageName) => {
|
|
|
22
22
|
}
|
|
23
23
|
return imports;
|
|
24
24
|
};
|
|
25
|
-
const isFromPackage = (node, packageName,
|
|
26
|
-
if (!checker) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
let origin = trace(node, checker);
|
|
30
|
-
return origin === null || origin.includes(packageName);
|
|
31
|
-
};
|
|
32
|
-
const isSymbolFromPackage = (checker, node, packageName, symbolName) => {
|
|
25
|
+
const isFromPackage = (checker, node, packageName, symbolName) => {
|
|
33
26
|
let symbol = checker.getSymbolAtLocation(node);
|
|
34
27
|
if (!symbol) {
|
|
35
28
|
return false;
|
|
@@ -114,4 +107,4 @@ const trace = (node, checker) => {
|
|
|
114
107
|
}
|
|
115
108
|
return declarations[0].getSourceFile().fileName;
|
|
116
109
|
};
|
|
117
|
-
export default { find, isFromPackage,
|
|
110
|
+
export default { find, isFromPackage, modify, trace };
|
package/package.json
CHANGED
package/src/compiler/imports.ts
CHANGED
|
@@ -52,21 +52,8 @@ const find = (sourceFile: ts.SourceFile, packageName: string): ImportInfo[] => {
|
|
|
52
52
|
return imports;
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
// Check if identifier traces back to a specific package
|
|
56
|
-
const isFromPackage = (node: ts.Identifier, packageName: string, checker?: ts.TypeChecker): boolean => {
|
|
57
|
-
if (!checker) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let origin = trace(node, checker);
|
|
62
|
-
|
|
63
|
-
// If can't resolve symbol (e.g., sourceFile not in program), assume valid
|
|
64
|
-
// False positives cause compile errors; false negatives silently skip transforms
|
|
65
|
-
return origin === null || origin.includes(packageName);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
55
|
// Check if node's symbol originates from a specific package (with optional symbol name validation)
|
|
69
|
-
const
|
|
56
|
+
const isFromPackage = (
|
|
70
57
|
checker: ts.TypeChecker,
|
|
71
58
|
node: ts.Node,
|
|
72
59
|
packageName: string,
|
|
@@ -204,5 +191,5 @@ const trace = (node: ts.Identifier, checker: ts.TypeChecker): string | null => {
|
|
|
204
191
|
};
|
|
205
192
|
|
|
206
193
|
|
|
207
|
-
export default { find, isFromPackage,
|
|
194
|
+
export default { find, isFromPackage, modify, trace };
|
|
208
195
|
export type { ImportInfo, ModifyOptions };
|