https://github.com/benoitzugmeyer/ts-transformer-meta
Experimental TypeScript transformer to access meta informations for a type
https://github.com/benoitzugmeyer/ts-transformer-meta
Last synced: about 1 year ago
JSON representation
Experimental TypeScript transformer to access meta informations for a type
- Host: GitHub
- URL: https://github.com/benoitzugmeyer/ts-transformer-meta
- Owner: BenoitZugmeyer
- Created: 2019-01-13T00:23:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-13T00:24:05.000Z (over 7 years ago)
- Last Synced: 2025-03-10T05:48:14.427Z (over 1 year ago)
- Language: TypeScript
- Size: 69.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ts-transformer-meta
Experimental TypeScript transformer to access meta informations for a type.
```ts
import { meta } from "ts-transformer-meta"
interface Foo {
bar: number
}
const properties = meta().properties
if (properties) {
console.log(properties.map(property => property.name)) // ["bar"]
}
enum Alpha {
A,
B,
C,
}
const types = meta().types
if (types) {
console.log(types.map(type => type.value)) // [0, 1, 2]
}
```
## Setup
Configure your build process:
- [webpack / ts-loader](https://github.com/TypeStrong/ts-loader#getcustomtransformers--program-program---before-transformerfactory-after-transformerfactory--)
- [webpack / awesome-typescript-loader](https://github.com/s-panferov/awesome-typescript-loader#getcustomtransformers-string--program-tsprogram--tscustomtransformers--undefined-defaultundefined)
- [rollup / rollup-plugin-typescript2](https://github.com/ezolenko/rollup-plugin-typescript2#plugin-options)
Or use [ttypescript](https://github.com/cevek/ttypescript).
Custom transformers object:
```js
{
before: [keysTransformer(program)]
}
```
See the [example](example) for a configuration example.
## Acknowledgement
All credits go to Kimamula with his projects [ts-transformer-keys](https://github.com/kimamula/ts-transformer-keys) and [ts-transformer-enumerate](https://github.com/kimamula/ts-transformer-enumerate).