You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

closure-ts

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

closure-ts

Generate TypeScript declarations(d.ts) of Closure Library

0.3.1
latest
Source
npm
Version published
Weekly downloads
7
600%
Maintainers
1
Weekly downloads
 
Created
Source

closure-ts Build Status

Generates TypeScript declaration files (.d.ts) from Closure Library JSDoc annotations.

The result is closure-library.d.ts.

Example

From this JavaScript code with annotations,

/**
 * Truncates a string to a certain length.
 * @param {string} str
 * @param {number} chars
 * @param {boolean=} opt_protectEscapedCharacters
 * @return {string}
 */
goog.string.truncate = function(str, chars, opt_protectEscapedCharacters) {
    // ...
};

closure-ts generates this declaration file (.d.ts).

declare module goog.string {
    /**
     * Truncates a string to a certain length.
     * @param {string} str
     * @param {number} chars
     * @param {boolean=} opt_protectEscapedCharacters
     * @return {string}
     */
    function truncate(str: string, chars: number, opt_protectEscapedCharacters?: boolean): string;
}

Usage

$ closurets some-jsdoced-code.js
$ ls
some-jsdoced-code.d.ts
some-jsdoced-code.js

Project status

Just PoC

Implemented

  • Variable with @type
  • Function with @param and @return
  • Namespace to TypeScript module
  • Classes (@constructor and @extends)
  • Enum with @enum to TypeScrip type alias and variables
  • Convert * to any
  • Generic type like Array<number>
  • Generic classes and function with @template
  • Union type
  • Record type
  • Rest parameters in @param and FunctionType
  • Optional parameters
  • Exclude @private definitions
  • @typedef
  • Convert Object.<string, Foo> to {[index: string]: Foo}
  • Ignore features TypeScript doesn't have
    • @this, new of function type
    • Nullable, Non-Nullable

TODO

  • @lends
  • Dependencies of Closure Library files
  • One stop build system with Grunt or Gulp

Keywords

typescript

FAQs

Package last updated on 14 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts