Generate TypeScript types from Google's Discovery API
$ npm install discovery-tsd
$ dtsd bigquery v2 > bigquery.d.ts
const createTypes = require('discovery-tsd');
const fs = require('fs');
const {promisify} = require('util');
const writeFile = promisify(fs.writeFile);
async function getTypes() {
const types = await createTypes('bigquery', 'v2');
await writeFile('./bigquery.d.ts', types);
}
Fetches the Discovery Document resource.
Refer to the getRest
Documentation for more details.
const {fetch} = require('discovery-tsd');
async function getJSON() {
const json = await fetch('bigquery', 'v2');
}
Creates types for the supplied Discovery Document JSON.
const {fetch, render} = require('discovery-tsd');
async function createTypes() {
const json = await fetch('bigquery', 'v2');
return render(json);
}
ISC