reflect-metadata

A polyfill for the Metadata Reflection API that powers decorator metadata in TypeScript and JavaScript.

Library
npm
v0.2.2
3,361 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
55 /100 Fair
Development Activity 36
Maintenance 24
Community 60
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
84 /100 Excellent
Architecture 84
Code Quality 85
Innovation 88
Learning Curve 80

reflect-metadata is a lightweight, zero-dependency polyfill that adds a Metadata Reflection API to the global Reflect object, letting you attach and read arbitrary metadata on classes and their members. It is the runtime that makes TypeScript’s legacy experimentalDecorators and emitDecoratorMetadata options useful, and it underpins dependency-injection and reflection features in frameworks like Angular, NestJS, TypeORM, and InversifyJS.

The library exposes a small, consistent set of imperative methods (defineMetadata, getMetadata, hasMetadata, and friends) alongside a @Reflect.metadata decorator, works across NodeJS, browsers, and bundlers, and ships CommonJS, ESM, lite, and no-conflict builds to fit different runtime constraints.

What You Get

  • A global Reflect polyfill exposing defineMetadata, getMetadata, hasMetadata, getMetadataKeys, deleteMetadata, and their own-property variants.
  • A @Reflect.metadata(key, value) decorator for declaratively attaching metadata to classes and members.
  • Multiple builds — full (with internal Map/Set/WeakMap polyfills), lite, and no-conflict — plus CommonJS, ESM, and browser <script> distributions.
  • First-class TypeScript typings and support for emitDecoratorMetadata, enabling auto-generated design:type, design:paramtypes, and design:returntype metadata.

Common Use Cases

  • Powering dependency-injection containers that resolve constructor parameter types from emitted metadata.
  • Building runtime type assertions, validation, and serialization from decorator-attached annotations.
  • Supporting ORM and framework decorators (entities, routes, DTOs) that need to read type metadata reflectively.

Under The Hood

Architecture - The library is authored as a single TypeScript namespace Reflect in Reflect.ts (~93KB) that installs itself onto the global Reflect object, or creates one on ES5 runtimes. Metadata is stored in a nested WeakMap keyed first by target object, then by property key, then by metadata key, using internal Map/Set/WeakMap polyfills for legacy environments. Parallel ReflectLite.ts and ReflectNoConflict.ts sources produce the lite (no internal polyfills) and no-conflict builds, exposed through package.json exports as ., ./lite, and ./no-conflict.

Tech Stack - Written entirely in TypeScript with zero runtime dependencies, compiled via a gulp build pipeline (gulpfile.js, tsconfig-release.json) that emits CommonJS .js bundles plus .d.ts typings (index.d.ts, standalone.d.ts, no-conflict.d.ts). The ECMAScript specification itself is authored in spec.html with ecmarkup. Tests run on mocha with chai assertions.

Code Quality - The test/ directory holds 28 focused suites, one per public API method (reflect-definemetadata.ts, reflect-getmetadata.ts, reflect-decorate.ts, and so on), giving thorough behavioral coverage of the metadata operations. The source is extensively documented with JSDoc examples on each exported function, and public surfaces are fully typed.

API Design - The public API is small, consistent, and ergonomic: paired hasMetadata/hasOwnMetadata, getMetadata/getOwnMetadata, and prototype-chain vs own-key variants follow a predictable naming scheme. Metadata key and value precede the target argument so the optional propertyKey sits last and the calls curry cleanly with Function#bind. Getting started requires only a single import "reflect-metadata" at the entry point, with rich typings surfacing documentation directly in the editor.

Used by 46 apps in this directory

TypeScript
82%
Other

AFFiNE

Collaboration · Note Taking · Productivity

73,040

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 82%
Rust 11%
Updated 6 days ago
TypeScript
96%
Other

Amplication

AI Code Assistants · Automation · Developer Tools

16,015

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
58
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 96%
Updated 3 months ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,916

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
90
Repo Health
77
Technical
61
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
Rust
67%
MIT

Bun

Developer Tools

96,068

An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.

View details
92
Repo Health
91
Technical
64
Dependency
Built with
Rust 67%
C++ 19%
TypeScript 10%
Updated 6 days ago
TypeScript
96%
Other

Cal.diy

Scheduling

48,697

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
91
Repo Health
86
Technical
65
Dependency
Built with
TypeScript 96%
Updated 1 weeks ago
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

52,202

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
89
Repo Health
84
Technical
70
Dependency
Built with
TypeScript 99%
Updated 5 days ago
TypeScript
95%
AGPL 3.0

Docmost

CMS · Collaboration · Note Taking

21,801

Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.

View details
89
Repo Health
70
Technical
69
Dependency
Built with
TypeScript 95%
Updated 6 days ago
Go
80%
Apache 2.0

Dolt

Data Engineering · Databases · Developer Tools

24,532

The SQL database you can branch, merge, diff, and clone — Git for your data, MySQL-compatible and ready for multi-agent AI workflows.

View details
90
Repo Health
9
Technical
65
Dependency
Built with
Go 80%
Shell 19%
Updated 1 weeks ago
TypeScript
62%
Other

Flowise

AI Development · Automation · Developer Tools

55,490

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
82
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 62%
JavaScript 27%
Updated 1 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers