https://github.com/k-yle/runtime-union
https://github.com/k-yle/runtime-union
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/k-yle/runtime-union
- Owner: k-yle
- Created: 2025-06-02T10:13:15.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-02T10:20:49.000Z (about 1 year ago)
- Last Synced: 2025-07-13T02:05:57.240Z (11 months ago)
- Language: TypeScript
- Homepage: https://npm.im/runtime-union
- Size: 44.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
quick solution to get the value of a TypeScript string union **at runtime** using the TS compiler API.
Don't use this in production obviously! It's designed for build scripts that want to extract a TS union and do something with it.
there's probably a more idiomatic way to do this…
# usage
```js
import { evaluateStringUnion } from 'runtime-union';
const output = evaluateStringUnion('./path/to/file.ts', 'MyUnionType', {
/* tsconfig */
});
```