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;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 buildThen use something like yarn link or yalc to install it locally.