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

@macroforge/typescript-plugin

v0.1.72

Published

TypeScript language service plugin that augments classes decorated with @derive to include macro-generated methods.

Readme

@macroforge/typescript-plugin

TypeScript language service plugin that augments classes decorated with @derive to include macro-generated methods.

npm version

Overview

TypeScript Language Service Plugin for Macroforge

This plugin integrates Macroforge's compile-time macro expansion with TypeScript's Language Service to provide seamless IDE support for macro-decorated classes.

Architecture Overview

The plugin operates by intercepting TypeScript's Language Service methods and transforming source code on-the-fly:

  1. Macro Expansion: When TypeScript requests a file's content via getScriptSnapshot, this plugin intercepts the call and returns the macro-expanded version instead.

  2. Position Mapping: Since expanded code has different positions than the original, the plugin maintains a {@link PositionMapper} for each file to translate positions between original and expanded coordinates.

  3. Virtual .d.ts Files: For each macro-containing file, the plugin generates a companion .macroforge.d.ts file containing type declarations for generated methods.

Supported File Types

  • .ts - TypeScript files
  • .tsx - TypeScript JSX files
  • .svelte - Svelte components (with <script lang="ts">)

Hook Categories

The plugin hooks into three categories of Language Service methods:

  • Host-level hooks: Control what TypeScript "sees" (getScriptSnapshot, fileExists, etc.)
  • Diagnostic hooks: Map error positions back to original source (getSemanticDiagnostics)
  • Navigation hooks: Handle go-to-definition, references, completions, etc.

@example

{
"compilerOptions": {
"plugins": [{ "name": "@macroforge/typescript-plugin" }]
}
}

Installation

npm install @macroforge/typescript-plugin

API

Functions

  • parseMacroImportComments - Parses macro import comments to extract macro name to module path mappings.
  • getExternalManifest - Attempts to load the manifest from an external macro package.
  • getExternalMacroInfo - Looks up macro info from an external package manifest.
  • getExternalDecoratorInfo - Looks up decorator info from an external package manifest.
  • findDeriveAtPosition - Finds a macro name within @derive(...) decorators at a given cursor position.
  • findDeriveKeywordAtPosition - Finds the @derive keyword at a given cursor position.
  • findDecoratorAtPosition - Finds a field decorator (like @serde or @debug) at a given cursor position.
  • findEnclosingDeriveContext - const lastCommentEnd = beforeMatch.lastIndexOf("*/
  • getMacroHoverInfo - Generates hover information (QuickInfo) for macros and decorators at a cursor position.
  • shouldProcess - Determines whether a file should be processed for macro expansion.
  • ... and 7 more

Types

  • MacroConfig - Configuration options loaded from macroforge.json.

Examples

{
"compilerOptions": {
"plugins": [{ "name": "@macroforge/typescript-plugin" }]
}
}

Documentation

See the full documentation on the Macroforge website.

License

MIT