ts-unused 1.0.1 → 1.0.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.
- package/dist/analyzeFunctionReturnTypes.d.ts +6 -0
- package/dist/analyzeInterfaces.d.ts +3 -0
- package/dist/analyzeProject.d.ts +2 -0
- package/dist/analyzeTypeAliases.d.ts +5 -0
- package/dist/checkExportUsage.d.ts +3 -0
- package/dist/checkGitStatus.d.ts +7 -0
- package/dist/extractTodoComment.d.ts +6 -0
- package/dist/findNeverReturnedTypes.d.ts +3 -0
- package/dist/findStructurallyEquivalentProperties.d.ts +12 -0
- package/dist/findUnusedExports.d.ts +3 -0
- package/dist/findUnusedProperties.d.ts +3 -0
- package/dist/fixProject.d.ts +13 -0
- package/dist/formatResults.d.ts +2 -0
- package/dist/hasNoCheck.d.ts +2 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1251 -0
- package/dist/isPropertyUnused.d.ts +7 -0
- package/dist/isTestFile.d.ts +2 -0
- package/dist/types.d.ts +40 -0
- package/package.json +12 -3
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type FunctionDeclaration, type SourceFile } from "ts-morph";
|
|
2
|
+
import type { NeverReturnedTypeResult } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Analyzes a function to detect union type branches in the return type that are never actually returned
|
|
5
|
+
*/
|
|
6
|
+
export declare function analyzeFunctionReturnTypes(func: FunctionDeclaration, sourceFile: SourceFile, tsConfigDir: string): NeverReturnedTypeResult[];
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Project, SourceFile } from "ts-morph";
|
|
2
|
+
import type { IsTestFileFn, UnusedPropertyResult } from "./types";
|
|
3
|
+
export declare function analyzeInterfaces(sourceFile: SourceFile, tsConfigDir: string, isTestFile: IsTestFileFn, results: UnusedPropertyResult[], project: Project): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Project, type SourceFile, type TypeAliasDeclaration, type TypeElementTypes } from "ts-morph";
|
|
2
|
+
import type { IsTestFileFn, UnusedPropertyResult } from "./types";
|
|
3
|
+
export declare function analyzeTypeLiteralMember(member: TypeElementTypes, typeName: string, sourceFile: SourceFile, tsConfigDir: string, isTestFile: IsTestFileFn, results: UnusedPropertyResult[], project: Project): void;
|
|
4
|
+
export declare function analyzeTypeAlias(typeAlias: TypeAliasDeclaration, sourceFile: SourceFile, tsConfigDir: string, isTestFile: IsTestFileFn, results: UnusedPropertyResult[], project: Project): void;
|
|
5
|
+
export declare function analyzeTypeAliases(sourceFile: SourceFile, tsConfigDir: string, isTestFile: IsTestFileFn, results: UnusedPropertyResult[], project: Project): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Node, type SourceFile } from "ts-morph";
|
|
2
|
+
import type { IsTestFileFn, UnusedExportResult } from "./types";
|
|
3
|
+
export declare function checkExportUsage(exportName: string, declarations: readonly Node[], sourceFile: SourceFile, tsConfigDir: string, isTestFile: IsTestFileFn): UnusedExportResult | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check which files have local git changes (modified, staged, or untracked)
|
|
3
|
+
* Note: Checks the entire git repository, not just the working directory
|
|
4
|
+
* @param workingDir - The directory to check git status in (used to find git root)
|
|
5
|
+
* @returns Set of absolute file paths that have local changes
|
|
6
|
+
*/
|
|
7
|
+
export declare function checkGitStatus(workingDir: string): Set<string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PropertyDeclaration, PropertySignature } from "ts-morph";
|
|
2
|
+
/**
|
|
3
|
+
* Extracts TODO comment text from the leading comments of a property.
|
|
4
|
+
* Returns undefined if no TODO comment is found.
|
|
5
|
+
*/
|
|
6
|
+
export declare function extractTodoComment(prop: PropertySignature | PropertyDeclaration): string | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Project } from "ts-morph";
|
|
2
|
+
import type { IsTestFileFn, NeverReturnedTypeResult } from "./types";
|
|
3
|
+
export declare function findNeverReturnedTypes(project: Project, tsConfigDir: string, isTestFile: IsTestFileFn, onProgress?: (filePath: string) => void, targetFilePath?: string): NeverReturnedTypeResult[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Project, PropertyDeclaration, PropertySignature } from "ts-morph";
|
|
2
|
+
/**
|
|
3
|
+
* Finds properties that are structurally equivalent to the given property.
|
|
4
|
+
* Two properties are structurally equivalent if they have:
|
|
5
|
+
* - Same property name
|
|
6
|
+
* - Same type signature
|
|
7
|
+
*
|
|
8
|
+
* This handles cases where properties are re-declared across interfaces,
|
|
9
|
+
* such as when one interface extends another and re-declares properties,
|
|
10
|
+
* or when spread operations flow values between structurally similar types.
|
|
11
|
+
*/
|
|
12
|
+
export declare function findStructurallyEquivalentProperties(prop: PropertySignature | PropertyDeclaration, project: Project): Array<PropertySignature | PropertyDeclaration>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Project } from "ts-morph";
|
|
2
|
+
import type { IsTestFileFn, UnusedExportResult } from "./types";
|
|
3
|
+
export declare function findUnusedExports(project: Project, tsConfigDir: string, isTestFile: IsTestFileFn, onProgress?: (filePath: string) => void, targetFilePath?: string): UnusedExportResult[];
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Project } from "ts-morph";
|
|
2
|
+
import type { IsTestFileFn, UnusedPropertyResult } from "./types";
|
|
3
|
+
export declare function findUnusedProperties(project: Project, tsConfigDir: string, isTestFile: IsTestFileFn, onProgress?: (filePath: string) => void, targetFilePath?: string): UnusedPropertyResult[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IsTestFileFn } from "./types";
|
|
2
|
+
export interface FixResults {
|
|
3
|
+
fixedExports: number;
|
|
4
|
+
fixedProperties: number;
|
|
5
|
+
fixedNeverReturnedTypes: number;
|
|
6
|
+
deletedFiles: number;
|
|
7
|
+
skippedFiles: string[];
|
|
8
|
+
errors: Array<{
|
|
9
|
+
file: string;
|
|
10
|
+
error: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export declare function fixProject(tsConfigPath: string, onProgress?: (message: string) => void, isTestFile?: IsTestFileFn): FixResults;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { analyzeProject } from "./analyzeProject";
|
|
2
|
+
export { fixProject } from "./fixProject";
|
|
3
|
+
export { formatResults } from "./formatResults";
|
|
4
|
+
export { findUnusedExports } from "./findUnusedExports";
|
|
5
|
+
export { findUnusedProperties } from "./findUnusedProperties";
|
|
6
|
+
export { isTestFile } from "./isTestFile";
|
|
7
|
+
export type { AnalysisResults, ExportKind, IsTestFileFn, NeverReturnedTypeResult, Severity, UnusedExportResult, UnusedPropertyResult, } from "./types";
|
|
8
|
+
export type { FixResults } from "./fixProject";
|
|
9
|
+
export type { PropertyUsageResult } from "./isPropertyUnused";
|