0.3.0-dev.7 • Published 10 months ago
ts-retype v0.3.0-dev.7
TS retype
Discover duplicate TypeScript types in your codebase. TS retype finds duplicates of Literal and Interface types.
Install
npm install -g ts-retype
or
yarn global add ts-retype
Usage with CLI
ts-retype /path/to/project
or
npx ts-retype /path/to/project
Usage with Library
import { scan } from 'ts-retype';
const { data, meta } = scan({
exclude: ['**/node_modules/**', '**/dist/**'],
include: ['**/*.{ts,tsx}'],
rootDir: '.',
});
console.log(meta);
for (const dup of data) {
console.log(dup.group, dup.names, dup.files);
}
See Data Format for result format.
Configuration
CLI options
Usage: ts-retype [options] [rootDir]
Discover duplicate TypeScript types in your codebase.
Options:
-V, --version output the version number
-c, --config [file-path] load config - if no path provided, loads
.retyperc from current directory. if not
set, use default config
-e, --exclude [glob...] glob patterns that will be ignored
-g, --init [file-path] initializes with default config. if no
path is provided, creates .retyperc in the
current directory
-i, --include [glob...] glob patterns that will be included in
search
-j, --json <file-path> file path to export JSON report to. if not
set, does not export JSON.
-n, --noHtml if set, does not export HTML
-o, --output <file-path|dir-path> HTML report file path - if provided with
dir, create index.html file inside the dir
-h, --help display help for command
.retyperc
{
"exclude": ["**/node_modules/**","**/dist/**"],
"include": ["**/*.{ts,tsx}"],
"json": "./apps/vis/src/assets/data.json",
"noHtml": false,
"output": "./retype-report.html",
"rootDir": "."
}
Data Format
Defined in TypeDuplicate
export type TypeDuplicate = {
files: {
name: string;
file: string;
lines: [number, number];
pos: [number, number];
offset: number;
type: 'interface' | 'literal' | 'alias' | 'function' | 'enum' | 'union';
src: string;
srcHgl?: TokenRoot;
properties?: { name: string; type: string }[];
}[];
group: 'different' | 'renamed' | 'identical';
names: { count: number; name: string }[];
members?: string[];
parameters?: { name: string; type: string }[];
properties?: { name: string; type: string }[];
returnType?: string;
signature?: {
name?: string;
params: { name: string; type?: string }[];
return?: string;
strMin?: string;
strFull?: string;
};
types?: string[];
};
Development
just clean
just install
just build-all
just test-all
just dev vis
just dev doc
just build-watch uikit
just rebuild uikit
just build uikit
just test search
0.3.0-dev.7
10 months ago
0.3.0-dev.4
10 months ago
0.3.0-dev.3
10 months ago
0.3.0-dev.6
10 months ago
0.3.0-dev.5
10 months ago
0.3.0-dev.2
10 months ago
0.3.0-dev.1
10 months ago
0.2.5
2 years ago
0.2.4
2 years ago
0.2.3
2 years ago
0.2.2
2 years ago
0.2.1
2 years ago
0.2.0
2 years ago
0.1.0
2 years ago
0.1.0-rc.4
2 years ago
0.1.0-rc.3
2 years ago
0.1.0-rc.2
2 years ago
0.1.0-rc.1
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago
0.0.0
2 years ago