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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sliderzz/typify

v1.3.2

Published

Convert JavaScript files to TypeScript

Downloads

37

Readme

typify

A command-line tool to convert JavaScript files to TypeScript with automatic type inference.

Features

  • Converts JavaScript files to TypeScript by just running the command.
  • Automatically infers basic types for function parameters
  • Converts var declarations to let or const
  • Transforms CommonJS require() to ES6 import statements
  • Preserves existing code structure and comments
  • Smart type inference for common patterns:
    • Core Patterns:
      • Basic types (string, number, boolean)
      • Array methods → Array<T>
      • Object patterns → Record<string, any>
      • Error handling → Error | null
    • Web Development:
      • Express (Request, Response, NextFunction)
      • Socket.IO (Socket, Server)
      • JWT (JwtPayload)
      • React (FC, ReactNode)
      • Webpack (Configuration)
      • Axios (AxiosInstance, AxiosResponse)
    • Databases:
      • MongoDB (Db, Collection, Document)
      • Mongoose (Model, Schema)
      • SQL (Connection, Pool, Query)
    • Testing:
      • Jest (Mock, SpyInstance)
    • Utilities:
      • Lodash (LoDashStatic)
      • Date handling (Date/string/number)
      • Validation (Joi/Yup schemas)
      • Node.js FS (typeof fs)
    • Cloud/Infra:
      • AWS SDK (S3, DynamoDB)
      • Node.js streams (Readable/Writable)

Installation

npm install @sliderzz/typify

Usage

typify <filename>

This will create a new TypeScript file (filename.ts) in the same directory.

Examples

Basic Function Conversion

Input (example.js):

function greet(name) {
  return 'Hello ' + name;
}
function calculate(value) {
  return value * 2;
}
function processUser(user) {
  return user.name;
}

Output (example.ts):

function greet(name: string) {
  return 'Hello ' + name;
}
function calculate(value: number) {
  return value * 2;
}
function processUser(user: Record<string, any>) {
  return user.name;
}

Database Pattern Detection

Input (db-example.js):

async function findUsers(db, query) {
  const collection = db.collection('users');
  return collection.find(query);
}

Output (db-example.ts):

import { Db, Collection } from 'mongodb';

async function findUsers(db: Db, query: Record<string, any>) {
  const collection: Collection = db.collection('users');
  return collection.find(query);
}

Web Pattern Detection

Input (web-example.js):

function handleSocket(socket) {
  socket.on('message', (data) => {
    socket.emit('response', data);
  });
}

async function verifyToken(token) {
  return jwt.verify(token, process.env.SECRET);
}

Output (web-example.ts):

import { Socket } from 'socket.io';
import { JwtPayload } from 'jsonwebtoken';

function handleSocket(socket: Socket) {
  socket.on('message', (data: any) => {
    socket.emit('response', data);
  });
}

async function verifyToken(token: string): Promise<JwtPayload> {
  return jwt.verify(token, process.env.SECRET);
}

React Component Detection

Input (component.js):

function Button(props) {
  return <button>{props.children}</button>;
}

Output (component.tsx):

import { FC } from 'react';

const Button: FC<{ children?: ReactNode }> = (props) => {
  return <button>{props.children}</button>;
};

Jest Test Patterns

Input (test.js):

test('user login', async (mock) => {
  const user = mock.user.create();
  await user.login();
});

Output (test.ts):

import { Mock } from 'jest';

test('user login', async (mock: jest.Mock) => {
  const user = mock.user.create();
  await user.login();
});

Webpack Configuration

Input (webpack.config.js):

module.exports = (env) => ({
  entry: './src/index.js',
  mode: env.production ? 'production' : 'development',
});

Output (webpack.config.ts):

import { Configuration } from 'webpack';

export default (env: Record<string, boolean>): Configuration => ({
  entry: './src/index.js',
  mode: env.production ? 'production' : 'development',
});

Type Inference Improvements

React Components

  • Detects props/state parameters
  • Adds FC type with children prop
  • Infers component return types

Testing Frameworks

  • Recognizes Jest mock functions
  • Types test/mock parameters
  • Adds proper async test typing

Infrastructure Patterns

  • AWS service client detection (S3, DynamoDB)
  • Node.js stream type inference

Error Handling

  • Detects error/err parameters
  • Adds Error | null union type
  • Infers try/catch error types

Database Operations

  • Recognizes MongoDB collection patterns
  • Types Mongoose models and schemas
  • Infers SQL connection pools

HTTP Clients

  • Detects Axios instance usage
  • Types fetch API parameters
  • Infers response data shapes

Limitations

  • Complex generic types may need manual annotation
  • AWS SDK v2 requires separate @types/aws-sdk
  • Custom Express middleware types might need refinement
  • Axios interceptors may require additional typing
  • Date format detection has basic pattern matching

Do try it out! I'm always looking for feedback and suggestions. Or let's collaborate for any cool stuff! Reach out to me on linkedin