Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/teppeis/closure-library.ts
A bridge to use Closure Library with TypeScript
https://github.com/teppeis/closure-library.ts
Last synced: 3 months ago
JSON representation
A bridge to use Closure Library with TypeScript
- Host: GitHub
- URL: https://github.com/teppeis/closure-library.ts
- Owner: teppeis
- Created: 2015-03-02T17:26:36.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-06-15T21:04:11.000Z (over 7 years ago)
- Last Synced: 2024-08-09T14:57:09.633Z (5 months ago)
- Language: TypeScript
- Size: 13.7 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
closure-library.ts [![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Dependency Status][deps-image]][deps-url]
====> Closure Library for TypeScript
This is all-in-one package to use Closure Library with TypeScript including:
* Latest Closure Library ([patched for TypeScript](https://github.com/teppeis/closure-library/tree/fix))
* Type declaration files (d.ts) of Closure Library ([closure-library.d.ts](https://github.com/teppeis/closure-library.d.ts))
* Bridge utility for zero config usage## Install
```console
$ npm install closure-library.ts
```## Usage
```typescript
// 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();
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 <[email protected]>
[npm-image]: https://img.shields.io/npm/v/closure-library.ts.svg
[npm-url]: https://npmjs.org/package/closure-library.ts
[travis-image]: https://travis-ci.org/teppeis/closure-library.ts.svg?branch=master
[travis-url]: https://travis-ci.org/teppeis/closure-library.ts
[deps-image]: https://david-dm.org/teppeis/closure-library.ts.svg
[deps-url]: https://david-dm.org/teppeis/closure-library.ts