{"repo":"intercom/contentful-typescript-codegen","free":true,"listed":false,"github":"https://github.com/intercom/contentful-typescript-codegen","clone":"git clone https://github.com/intercom/contentful-typescript-codegen.git","description":"Generate TypeScript interfaces from a Contentful environment","language":"TypeScript","stars":292,"topics":["typescript","contentful","codegen"],"license":"MIT","category":"dev-tools","readme_excerpt":"contentful-typescript-codegen Generate typings from your Contentful environment. - Content Types become interfaces. - Locales (and your default locale) become string types. - Assets and Rich Text link to Contentful's types. At Intercom, we use this in our [website] to increase developer confidence and productivity, ensure that breaking changes to our Content Types don't cause an outage, and because it's neat. [website]: https://www.intercom.com Usage Then, add the following to your package.json : Feel free to change the output path to whatever you like. Next, the codegen will expect you to have created a file called either getContentfulEnvironment.js or getContentfulEnvironment.ts in the root of your project directory, which should export a promise that resolves with your Contentful environment. The reason for this is that you can do whatever you like to set up your Contentful Management Client. Here's an example of a JavaScript config: And the same example in TypeScript: Note ts-node must be installed to use a TypeScript config Command line options Example output Here's an idea of what the output will look like for a Content Type: You can see that a few things are handled for you: - Documentation comments are automatically generated from Contentful descriptions. - Links, like author , are resolved to other TypeScript interfaces. - Assets are handled properly. - Validations on symbols and text fields are expanded to unions. - Non-required attributes automatically have null ap","default_branch":null,"files":null,"tree":[],"storefront":"/r/intercom","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/intercom/contentful-typescript-codegen/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}