https://github.com/tsmetadata/polyfill
Metadata symbol polyfill for legacy runtimes.
https://github.com/tsmetadata/polyfill
metadata polyfill symbol typescript
Last synced: 5 months ago
JSON representation
Metadata symbol polyfill for legacy runtimes.
- Host: GitHub
- URL: https://github.com/tsmetadata/polyfill
- Owner: tsmetadata
- License: mit
- Created: 2024-11-05T01:20:05.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-15T03:58:18.000Z (over 1 year ago)
- Last Synced: 2025-08-23T12:14:20.354Z (11 months ago)
- Topics: metadata, polyfill, symbol, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@tsmetadata/polyfill
- Size: 18.6 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `Symbol.metadata` Polyfill
`@tsmetadata/polyfill` provides the necessary polyfill for legacy runtimes to properly use decorator metadata in TypeScript 5.2+.
In addition, the library provides the necessary global type declaration for `Symbol.metadata`.
- [🌱 Install](#-install)
- [⚙️ Usage](#️-usage)
- [🙏 Thanks](#-thanks)
## 🌱 Install
```bash
npm install @tsmetadata/polyfill
```
## ⚙️ Usage
As early as possible, import the polyfill.
```typescript
import '@tsmetadata/polyfill';
```
After doing so, `Symbol.metadata` will be defined.
You may also need to configure your `tsconfig.json` to target <= ES2022 and include the `esnext.decorators` library. The easiest way to do this is to extend our included polyfill-ready configuration.
```json
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": ["@tsmetadata/polyfill/lib/tsconfig.polyfill.json"],
}
```
## 🙏 Thanks
Special thanks to Oleksandr Tarasiuk for implementing decorator metadata and to Andrew Branch for releasing an early version of this polyfill.