closure-ts
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 * @param * @param * @return */googstring { // ...};
closure-ts generates this declaration file (.d.ts).
declare module googstring /** * Truncates a string to a certain length. * @param * @param * @param * @return */ : string;}
Usage
$ closurets some-jsdoced-code.js$ lssome-jsdoced-code.d.tssome-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
*
toany
- 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