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

Overview

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

You might also like...

An utility library for Encoding and Compressing whatever you give him into a small string.

🟢 ORBIT ENCODER ⚙️ 🗜️ ORBIT-ENCODER is an utility library for Data Compression and Encoding. It can take whatever object you give him as argument an

Nov 16, 2022

Little Javascript / Typescript library for validating format of string like email, url, password...

String-Validators Little Javascript / Typescript library for validating format of string like email, url, password... Signaler un Bug · Proposer une F

Oct 14, 2022

Convert and Calculate by RPN for typescript.

Coaca.ts: Convert and Calculate by RPN for typescript 注意点 まずそもそも、typescriptはサーバサイドで使用されるべき言語です。一応typescript4.5以降の機能を用いていますが、typescriptの本来の使い方を超越してます。ご

Aug 24, 2022

Whatsapp bot with Typescript Convert to js Lmao 🤣

Whatsapp bot with Typescript Convert to js Lmao 🤣

Rain-BotV2 Join Group ONLY RUN RAILWAY railway.app Deploy to Heroku ✍️ Editing the file Edit the required value in config.js Heroku Buildpack BuildPac

Nov 1, 2022

javascript library to convert a list of objects to a nested json output format, depending on the names in the list

formToNestedJson javascript "library" to convert a list of objects to a nested json output format, depending on the names in the list Basic usage Give

Aug 2, 2021

A simple code that creates a string of random characters displayed in an html object, all saving in a json file.

A simple code that creates a string of random characters displayed in an html object, all saving in a json file.

I'm 17 Years Old Developer / Lead Developer. 💻 I'm wroking on AdrenalinaRP, GrandRDM. 🪙 I’m currently learning JavaScript. 🫂 I’m looking to collabo

Nov 17, 2022

JavaScript project for the Leaderboard list app, using Webpack and ES6 features, notably modules. this app consume the Leaderboard API using JavaScript async and await and add some styling.

Leaderboard Project JavaScript project for the Leaderboard list app, using Webpack and ES6 features, notably modules. this app consume the Leaderboard

May 20, 2022

A tiny (108 bytes), secure, URL-friendly, unique string ID generator for JavaScript

A tiny (108 bytes), secure, URL-friendly, unique string ID generator for JavaScript

Nano ID English | Русский | 简体中文 | Bahasa Indonesia A tiny, secure, URL-friendly, unique string ID generator for JavaScript. “An amazing level of sens

Jan 8, 2023

Provides simple and the most useful methods to string operations in JavaScript / Node.js

🔪 Strops (String Operations) Provides simple methods for the most useful operations with substrings: - remove, replace, get from A to B, get from A t

May 20, 2022
Owner
Lily Scott
Former Prettier Core Team member, Former Babel team member. Interested in JavaScript, Rust, Unity, VR, Dev Tooling, Dev Experience, React, and more.
Lily Scott
Transmute one JavaScript string into another by way of mutating its AST. Powered by babel and recast.

equivalent-exchange Transmute one JavaScript string into another by way of mutating its AST. Powered by babel and recast. Features Can parse code usin

Lily Scott 51 Jul 9, 2022
A simple react project that contain a single page application (SPA) And a simple caculator to make some calculation and there is a section you can see some Math quotes. Ⓜ💯

A simple react project that contain a single page application (SPA) And a simple caculator to make some calculation and there is a section you can see some Math quotes. Ⓜ??

Reem janina 7 May 31, 2022
This Repo Contains projects that demonstrate some concepts / algorithms / implemetation in some form of digital visualisation

Hacktoberfest 2022 OPEN FIRST Pull Request - GET STARTED WITH OPENSOURCE AND WIN SOME AWWSOME SWAGS ?? Contributors of Hacktoberfest 2022 This project

null 5 Nov 7, 2022
A command-line tool to convert Project Zomboid map data into Deep Zoom format

pzmap2dzi pzmap2dzi is a command-line tool running on Windows to convert Project Zomboid map data into Deep Zoom format. Features Supports both python

Min Xiang 14 Dec 31, 2022
When pasting screenshots into obsidian notes, convert the images to jpeg and compress them

obsidian-paste-png-to-jpeg This plugin is inspired by obsidian-paste-image-rename, obsidian-paste-image-rename can be used when inserting images renam

null 19 Nov 15, 2022
Convert any webpage into bionified text!

Bionify - Read Faster! LEGAL NOTICE: To the wonderful folks at Bionic Reading®, this is not a pirated version of your Bionic Reading® API, but rather

Vincent 96 Dec 8, 2022
jsonrawtoxlsx is library to convert json raw (array) into xlsx file

Welcome to jsonrawtoxlsx ?? ✨ What is jsonrawtoxlsx? jsonrawtoxlsx is library to convert json raw (array) into xlsx file ⚡️ Installation using npm npm

M Arie Syukron 17 Dec 23, 2022
jquery plugin to convert number inputs into knobs that can be adjusted by dragging with mouse or fingers

jquery-knobby is a jquery plugin to convert number input elements into turnable knobs that can be adjusted by cyclic dragging with mouse or fingers -

null 4 Oct 2, 2020
Convert Tailwind CSS class names into their CSS3-equivalent styles — right from Alfred.

alfred-tailwind2css Tailwind2CSS offers you the ability to convert TailwindCSS classes into their CSS3-equivalent styles -- right from within Alfred.

Stephan Casas 6 Dec 7, 2022