Rodentman87 / mtgjson-types

This package provides types for the various files provided by MTGJSON

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mtgjson-types

This repository holds TypeScript types for all the data available in the mtgjson 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:

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.

# 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 or yalc to install it locally.

About

This package provides types for the various files provided by MTGJSON


Languages

Language:TypeScript 100.0%