Skip to content

suchipi/convert-to-dts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

convert-to-dts

Converts the source code for any .js or .ts file into the equivalent .d.ts code TypeScript would generate.

Usage

import { convertToDeclaration } from "convert-to-dts";

const code = `
  import fs from "fs";
  import path from "path";

  /**
   * Comment :D
   */
  export class Something {
    blah!: typeof path;

    constructor() {
      console.log("hi");
    }
  }
`;

const converted = convertToDeclaration(code);
console.log(converted);

// Logs:
//
// import path from "path";
// /**
//  * Comment :D
//  */
// export declare class Something {
//     blah: typeof path;
//     constructor();
// }

API Documentation

Please see api/index.d.ts for API documentation. There are lots of comments.

License

MIT

About

Convert some JavaScript/TypeScript code string into a .d.ts TypeScript Declaration code string

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published