0.3.0-dev.7 • Published 2 months ago

ts-retype v0.3.0-dev.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

tests CodeQL npm version coverage

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

2 months ago

0.3.0-dev.4

2 months ago

0.3.0-dev.3

2 months ago

0.3.0-dev.6

2 months ago

0.3.0-dev.5

2 months ago

0.3.0-dev.2

2 months ago

0.3.0-dev.1

2 months ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago

0.1.0-rc.4

1 year ago

0.1.0-rc.3

1 year ago

0.1.0-rc.2

1 year ago

0.1.0-rc.1

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago