Skip to content
This repository has been archived by the owner on Mar 20, 2020. It is now read-only.
/ dts-dom Public archive
forked from RyanCavanaugh/dts-dom

A DOM library for generation TypeScript declaration (.d.ts) files

License

Notifications You must be signed in to change notification settings

hulu/dts-dom

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version

dts-dom is a library for programatically generating TypeScript declaration files. It is based mostly on the same CodeDOM provided for C# and other .NET languages.

dts-dom automatically handles indentation, formatting, and proper placement of declare and export keywords.

As with other CodeDOM libraries, this is overkill for small projects, but is useful in more complex code generation scenarios.

PRs gladly accepted as this is mostly implemented on an as-needed basis for another project.

Usage

npm install --save dts-dom

import * as dom from 'dts-dom';

const intf = dom.create.interface('MyInterface');
intf.jsDocComment = 'This is my nice interface';
intf.members.push(dom.create.method(
    'getThing',
    [dom.create.parameter('x', dom.type.number)],
    dom.type.void,
    dom.DeclarationFlags.Optional));

const ns = dom.create.namespace('SomeNamespace');
ns.members.push(intf);

console.log(dom.emit(ns));

This writes out the block:

declare namespace SomeNamespace {
    /**
     * This is my nice interface
     */
    interface MyInterface {
        getThing?(x: number): void;
    }
}

About

A DOM library for generation TypeScript declaration (.d.ts) files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%