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

generate-knit-types

v1.1.0

Published

Auto-generate Luau type definitions for Knit services and controllers

Readme

generate-knit-types

Auto-generate Luau type definitions for Knit services and controllers. Get full IDE IntelliSense for your Roblox Knit framework! 🚀

Features

  • ✅ Automatic type generation from service/controller files
  • ✅ Supports multi-line return types
  • ✅ Client vs server method detection
  • ✅ Extracts table-literal controller/service properties (e.g. NotificationStyles)
  • ✅ Recursive directory scanning (nested folders supported)
  • ✅ Dedupe for repeated methods
  • ✅ Zero configuration (uses Knit conventions)
  • ✅ Works with all Luau-supporting IDEs

Installation

npm install --save-dev generate-knit-types

Usage

Quick Start

Add to your package.json:

{
  "scripts": {
    "generate-types": "generate-knit-types",
    "build": "npm run generate-types && rojo build -o Code.rbxlx"
  }
}

Then run:

npm run generate-types

This generates src/shared/Components/KnitTypes.luau

Custom Directories

generate-knit-types --services src/server/MyServices --controllers src/client/MyControllers --output src/Types.luau

In Your Code

Controllers (Client-side)

local KnitTypes = require(ReplicatedStorage.Components.KnitTypes)
local BankService = KnitTypes.GetService("BankService") :: KnitTypes.BankService

-- IntelliSense now works! ✨
local maxStorage: number = BankService:GetMaxStorage(player)
local info = BankService:GetBankInfo(player)  -- Returns typed table

Services (Server-side)

local KnitTypes = require(ReplicatedStorage.Components.KnitTypes)
local SkinController = KnitTypes.GetController("SkinController") :: KnitTypes.SkinController

SkinController:CreateSkinViewport(viewport, model)

How It Works

The script scans your:

  • src/server/Services/ - Extracts service types
  • src/shared/Controllers/ - Extracts controller types

Generates:

  • Full service types (all server + client methods)
  • Client-specific types (only .Client: methods)
  • All controller types
  • Utility functions: GetService<T>() and GetController<T>()

Type Detection

  • Parameters: Extracts type annotations from function signatures
  • Return Types: Handles single-line (number, string) and multi-line table types
  • Client Methods: Automatically detects .Client: marker in function definitions
  • Properties: Infers table-literal property shapes assigned on Knit roots

Robustness Notes

  • Unknown or runtime-only expressions in inferred property values are safely emitted as any.
  • Inline one-line methods like function X:KnitStart(): () end are handled correctly.
  • Output ordering is stable (sorted), so generated diffs are predictable.

Example Output

For BankService:

export type BankService = {
    GetMaxStorage: (self: any, player: Player) -> number,
    SaveBank: (self: any, player: Player) -> { ok: boolean, saved: number?, message: string? },
    GetBankInfo: (self: any, player: Player) -> {
        maxStorage: number,
        nextUpgradeCost: number,
        storageLevel: number,
        loadTimerDuration: number,
    },
}

export type BankServiceClient = {
    SaveBank: (self: any, player: Player) -> { ok: boolean, saved: number?, message: string? },
}

Project Structure

Your Roblox project should follow this structure:

project/
├── src/
│   ├── server/
│   │   └── Services/        ← Services here
│   ├── shared/
│   │   ├── Controllers/     ← Controllers here
│   │   └── Components/      ← Generated types go here
│   └── client/
├── package.json
└── default.project.json

CLI Options

generate-knit-types [options]

Options:
  --services DIR      Services directory (default: src/server/Services)
  --controllers DIR   Controllers directory (default: src/shared/Controllers)
  --output FILE       Output file (default: src/shared/Components/KnitTypes.luau)

Requirements

  • Node.js 14+
  • Your project uses Knit framework
  • Services in src/server/Services/
  • Controllers in src/shared/Controllers/

License

MIT