npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ts-retype

v0.3.0-dev.7

Published

Discover duplicate TypeScript types in your codebase.

Downloads

61

Readme

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