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

@kattebak/typespec-openapi-types-emitter

v1.0.0

Published

TypeSpec emitter that generates TypeScript types from OpenAPI specs similar to openapicmd typegen

Readme

@kattebak/typespec-openapi-types-emitter

A TypeSpec emitter that generates TypeScript type definitions from your API specifications. Define your API once in TypeSpec and get fully typed client interfaces with complete code completion support.

Features

  • Generates TypeScript types directly from TypeSpec API definitions
  • Outputs Components.Schemas namespace with all models, enums, and scalars
  • Generates Paths namespace with operation-specific types (parameters, request bodies, responses)
  • Creates OperationMethods interface for typed API method calls
  • Produces PathsDictionary for path-based method access
  • Exports convenient top-level type aliases

Installation

npm install @kattebak/typespec-openapi-types-emitter

Usage

1. Add the emitter to your TypeSpec project

Create or update your tspconfig.yaml:

emit:
  - "@kattebak/typespec-openapi-types-emitter"
options:
  "@kattebak/typespec-openapi-types-emitter":
    output-file: "types.d.ts"
    # Optional: generate a package.json for the types
    package-name: "@myorg/api-types"
    package-version: "1.0.0"

2. Compile your TypeSpec project

npx tsp compile .

This will generate a types.d.ts file in your output directory.

Configuration Options

| Option | Type | Default | Description | | -------------------- | ------ | ---------------- | -------------------------------------------------------------- | | output-file | string | "types.d.ts" | The output filename for the generated types | | emitter-output-dir | string | "{output-dir}" | The directory where the types file will be written | | package-name | string | - | If provided, a package.json will be generated with this name | | package-version | string | "0.0.1" | Version for the generated package.json |

Generated Output Structure

The emitter produces TypeScript declarations with the following structure:

declare namespace Components {
  namespace Schemas {
    // All models, enums, and scalar types
    export interface Book { ... }
    export type BookStatus = "available" | "out_of_stock";
    // ...
  }
}

declare namespace Paths {
  namespace GetBooks {
    export interface QueryParameters { ... }
    namespace Responses {
      export type $200 = Components.Schemas.Book[];
    }
  }
  // ... other operations
}

export interface OperationMethods {
  getBooks(
    parameters?: Paths.GetBooks.QueryParameters | null,
    data?: any,
    config?: RequestConfig
  ): Promise<Paths.GetBooks.Responses.$200>;
  // ... other operations
}

export interface PathsDictionary {
  ['/books']: {
    get(...): Promise<...>;
    post(...): Promise<...>;
  };
  // ... other paths
}

// Convenient top-level exports
export type Book = Components.Schemas.Book;
export type BookStatus = Components.Schemas.BookStatus;
// ...

Using the Generated Types

import type { Book, Author, OperationMethods } from "@myorg/api-types";

// Use the types with your API client
const books: Book[] = await client.getBooks({ limit: 10 });
const author: Author = await client.getAuthorById({ id: 1 });

Example

See the test/main.tsp file for a complete example of a Bookstore API definition.

Development

# Install dependencies
npm install

# Build the emitter
npm run build

# Run tests
npm test

# Lint and format
npm run lint
npm run fix

License

MIT