Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

convert-to-dts

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

convert-to-dts

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

latest
Source
npmnpm
Version
3.0.0
Version published
Maintainers
1
Created
Source

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

Keywords

convert

FAQs

Package last updated on 02 Mar 2022

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