https://github.com/rodentman87/mtgjson-types
This package provides types for the various files provided by MTGJSON
https://github.com/rodentman87/mtgjson-types
Last synced: about 1 year ago
JSON representation
This package provides types for the various files provided by MTGJSON
- Host: GitHub
- URL: https://github.com/rodentman87/mtgjson-types
- Owner: Rodentman87
- Created: 2022-08-27T20:32:21.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-27T20:48:34.000Z (almost 4 years ago)
- Last Synced: 2025-02-01T15:45:02.286Z (over 1 year ago)
- Language: TypeScript
- Size: 29.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mtgjson-types
This repository holds TypeScript types for all the data available in the [mtgjson](https://mtgjson.com) project.
All the types for the available files are exported with the `File` suffix. Simply parse the JSON from the file as cast it with `as <...>File` to get type completions. For example:
```typescript
import { readFile } from "fs/promises";
import { join } from "path";
import { AllPrintingsFile } from "mtgjson-types";
const raw = await readFile(join(__dirname, "./AllPrintings.json"), "utf-8");
const json = JSON.parse(raw) as AllPrintingsFile;
```
## Installing
For now you'll need to clone the repository from GitHub, then build and install it yourself locally.
```bash
# clone the code
git clone https://github.com/Rodentman87/mtgjson-types.git
# move into the directory
cd mtgjson-types
# install dependencies
yarn install
# build the code
yarn run build
```
Then use something like [yarn link](https://classic.yarnpkg.com/en/docs/cli/link) or [yalc](https://github.com/wclr/yalc) to install it locally.