closure-library.ts

1.0.0 • Public • Published

closure-library.ts NPM version build status Dependency Status

Closure Library for TypeScript

This is all-in-one package to use Closure Library with TypeScript including:

Install

$ npm install closure-library.ts

Usage

// Import index.ts to load type information of Closure Library.
import closure = require('./node_modules/closure-library.ts/index');
// Call register() to enable `goog.requrie()`.
closure.register();
// Then `googl.require` returns the namespace!
var Queue = goog.require('goog.structs.Queue');
// Type information of Closure Library is available in TypeScript.
var q = new Queue<number>();
q.enqueue(10);
q.enqueue(20);
q.enqueue(30);
var n: number = q.dequeue(); // n = 10, ok!
var s: string = q.dequeue(); // Error! "Type 'number' is not assignable to type 'string'."

Once closure-library.ts is registered in the top of your bootstrap file, you don't have to register() in each dependent file.

License

MIT License: Teppei Sato <teppeis@gmail.com>

Package Sidebar

Install

npm i closure-library.ts

Weekly Downloads

10

Version

1.0.0

License

MIT

Last publish

Collaborators

  • teppeis