mtgjson / mtgjson-website

MTGJSON Documentation Front-End Application built with VitePress
https://mtgjson.com
MIT License
36 stars 24 forks source link

Add types for AllPrintings to the "All Types" TypeScript file #606

Closed invalidCards closed 1 year ago

invalidCards commented 1 year ago

Describe the feature request

I'm not sure if this is the right repository for this, but it seemed more appropriate than the mtgjson repo itself, so here goes. It would be nice to add a type for the setup of the AllPrintings file to AllMTGJSONTypes.ts so that the variable can be fully typed after simply parsing the file with JSON.parse.

The solution you would like

Add the following type to the AllMTGJSONTypes.ts file:

export type AllPrintings = {
  meta: Meta,
  data: { [setCode: string]: Set }
}

Any alternatives you have considered

I have added it myself to my own program, but it might be nice to have for those who are less fluent in TypeScript and don't want to use any type after parsing the JSON file.

Additional context

None

staghouse commented 1 year ago

I've added more exported types to the main all types files for the next release, particularly wanting you to check out the file type exports which should be at the bottom of the file.

Let me know if the typings works for you @invalidCards

https://deploy-preview-602--neon-otter-8cd2e8.netlify.app/types/AllMTGJSONTypes.ts

invalidCards commented 1 year ago

@staghouse Seems perfectly reasonable to me!