Skip to content

🫡 Check for existing type aliases given a custom type.

Notifications You must be signed in to change notification settings

thomscoder/TypeSentinel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeSentinel 🫡

Check for existing type aliases given a custom type.

Why?

I was working on a project and while i was going through the code i was seeing a lot of duplicated types declaration so i took this opportunity to learn more about Typescript APIs

What does it do?

Say you have

// file1.ts
type NullableString = string | null
// file2.ts
type AnotherNullableString = string | null

TypeSentinel will tell you that you already have one or multiple type alias(es) with that exact same values, returning:

  • the name of the type alias that you already have
  • the usage count (how many times was that type alias used in your project)

Screenshot 2024-05-07 at 22 22 03

TypeSentinel currently supports

  • Types aliases with the same name

Screenshot 2024-05-07 at 22 23 52

  • Searching types with generics

Screenshot 2024-05-07 at 22 26 45

  • Interfaces declarations

By default it skips the node_modules folder, but you can customize it with a config.json

{
  "skip": ["node_modules", "sentinel.ts", "index.ts"],
  "collectTypes": true
}

in the same path of your process.cwd().

Run it

Fast way

npm link && typesentinel

Development

pnpm tsc
  1. Make it executable
pnpm makex
  1. Add Shebang to ./build/index.js
#!/usr/bin/env node

// rest of the file
  1. Link
npm link
  1. Run it
typesentinel

About

🫡 Check for existing type aliases given a custom type.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published