Skip to content

Latest commit

 

History

History
57 lines (44 loc) · 2.14 KB

File metadata and controls

57 lines (44 loc) · 2.14 KB

google-api-nodejs-tsd

Typescript definitions for the Google APIs Node.js Client, generated based on the endpoint metadata made available through the Google API Discovery Service.

Importing and using

To use the type definitions for a given Google API, you need to reference both the base definition file (googleapis/googleapis.d.ts) and the API-specific definition file in your project.

'use strict';

import * as google from "googleapis";

// simple
google.discovery('v1').apis.list({
    preferred: true
}, (e, directoryList) => {
    if(e) {
        console.error(e);
    } else {
        console.log(directoryList.items.map(item => item.name + ' ' + item.version).join('\n'));
    }
});

// typed
import Discovery = google.discovery.v1.Discovery;
import DirectoryList = google.discovery.v1.DirectoryList;

let discovery: Discovery = google.discovery('v1');

discovery.apis.list({
    preferred: true
}, (e, directoryList: DirectoryList) => {
    if(e) {
        console.error(e);
    } else {
        console.log(directoryList.items.map(item => item.name + ' ' + item.version).join('\n'));
    }
});

Caveats

  • The definitions, as well as the definition generator are largely untested.
  • Certain call patterns allowed by the Google client are as of yet undefined in the definitions.

TODO

  • Generate typings.json files so that definitions can be installed using typings.
  • Generate documentation to be added to the definition files.
  • Generate tests to go along with the definition files.
  • Add support for various JSON Schema constructs (e.g. patternProperties)
  • Factor out JSON Schema to Typescript definition conversion into a separate project.
  • Complete the definitions for the Google Auth Node.js Library and put them in a separate project.
  • Complete the definitions for Nunjucks and put them in a separate project.
  • Submit definitions to DefinitelyTyped.
  • A whole lotta testing