mobx-tanstack-query-api 0.0.83 → 0.0.84
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-unused-types.d.ts","sourceRoot":"","sources":["../../../src/codegen/utils/remove-unused-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"remove-unused-types.d.ts","sourceRoot":"","sources":["../../../src/codegen/utils/remove-unused-types.ts"],"names":[],"mappings":"AAqIA,eAAO,MAAM,iBAAiB,GAAU,SAAS;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,kBAK/D,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-constant-condition */
|
|
2
|
-
import { Project, SyntaxKind } from 'ts-morph';
|
|
2
|
+
import { Project, SyntaxKind, Node } from 'ts-morph';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
const removeUnusedTypesItteration = async ({ dir }) => {
|
|
5
5
|
const project = new Project();
|
|
@@ -14,7 +14,8 @@ const removeUnusedTypesItteration = async ({ dir }) => {
|
|
|
14
14
|
const candidateTypes = new Map();
|
|
15
15
|
for (const [name, declarations] of exportedDeclarations) {
|
|
16
16
|
const validDeclarations = declarations.filter((decl) => decl.getKind() === SyntaxKind.InterfaceDeclaration ||
|
|
17
|
-
decl.getKind() === SyntaxKind.TypeAliasDeclaration
|
|
17
|
+
decl.getKind() === SyntaxKind.TypeAliasDeclaration ||
|
|
18
|
+
decl.getKind() === SyntaxKind.EnumDeclaration);
|
|
18
19
|
if (validDeclarations.length > 0) {
|
|
19
20
|
candidateTypes.set(name, validDeclarations);
|
|
20
21
|
}
|
|
@@ -33,16 +34,35 @@ const removeUnusedTypesItteration = async ({ dir }) => {
|
|
|
33
34
|
usedTypes.add(name);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
37
|
+
const memberAccessExpressions = file.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression);
|
|
38
|
+
for (const expr of memberAccessExpressions) {
|
|
39
|
+
const expression = expr.getExpression();
|
|
40
|
+
if (Node.isIdentifier(expression)) {
|
|
41
|
+
const name = expression.getText();
|
|
42
|
+
if (candidateTypes.has(name)) {
|
|
43
|
+
usedTypes.add(name);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
36
47
|
}
|
|
37
48
|
const dependencyGraph = new Map();
|
|
38
49
|
for (const [name, declarations] of candidateTypes) {
|
|
39
50
|
const dependencies = new Set();
|
|
40
51
|
for (const decl of declarations) {
|
|
41
|
-
const
|
|
42
|
-
for (const
|
|
43
|
-
const
|
|
44
|
-
if (candidateTypes.has(
|
|
45
|
-
dependencies.add(
|
|
52
|
+
const typeReferences = decl.getDescendantsOfKind(SyntaxKind.TypeReference);
|
|
53
|
+
for (const ref of typeReferences) {
|
|
54
|
+
const typeName = ref.getTypeName().getText();
|
|
55
|
+
if (candidateTypes.has(typeName)) {
|
|
56
|
+
dependencies.add(typeName);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (decl.getKind() === SyntaxKind.EnumDeclaration) {
|
|
60
|
+
const initializers = decl.getDescendantsOfKind(SyntaxKind.Identifier);
|
|
61
|
+
for (const init of initializers) {
|
|
62
|
+
const text = init.getText();
|
|
63
|
+
if (candidateTypes.has(text)) {
|
|
64
|
+
dependencies.add(text);
|
|
65
|
+
}
|
|
46
66
|
}
|
|
47
67
|
}
|
|
48
68
|
}
|