{"id":18987,"library":"babel-dts-generator","title":"babel-dts-generator","description":"A Babel plugin that generates TypeScript declaration (.d.ts) files from JavaScript code with JSDoc type annotations. Version 0.6.3 is the latest stable release; the project appears to be in maintenance mode with no recent activity. It specializes in converting Babel-parsed ASTs into TypeScript declarations, supporting features like object parameters, this-type annotations, typeof-type annotations, and string literal types. Key differentiators include integration with Babel's transformation pipeline and suppression of private exports for clean typings.","status":"maintenance","version":"0.6.3","language":"javascript","source_language":"en","source_url":"https://github.com/YoloDev/babel-dts-generator","tags":["javascript","aurelia","babel","dts"],"install":[{"cmd":"npm install babel-dts-generator","lang":"bash","label":"npm"},{"cmd":"yarn add babel-dts-generator","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-dts-generator","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Works as a Babel plugin; requires a compatible Babel version","package":"babel-core","optional":false}],"imports":[{"note":"Default export is a function; CommonJS users must use require().default","wrong":"const generator = require('babel-dts-generator').default","symbol":"default","correct":"import generator from 'babel-dts-generator'"},{"note":"Named export for programmatic generation, distinct from default","symbol":"generate","correct":"import { generate } from 'babel-dts-generator'"},{"note":"Type import only; do not use at runtime","wrong":"import { BabelDtsGeneratorOptions } from 'babel-dts-generator'","symbol":"BabelDtsGeneratorOptions","correct":"import type { BabelDtsGeneratorOptions } from 'babel-dts-generator'"}],"quickstart":{"code":"import generator from 'babel-dts-generator';\nimport * as babel from 'babel-core';\n\nconst code = `\n/** @param {number} a */\nfunction foo(a) { return a; }\n`;\n\nbabel.transform(code, {\n  plugins: [\n    [generator, {\n      output: 'dist/types',\n      suppressExcess: true,\n      suppressAmbientDeclaration: true\n    }]\n  ]\n}).then(result => {\n  console.log(result.code); // .d.ts content\n}).catch(err => console.error(err));","lang":"javascript","description":"Shows how to use babel-dts-generator as a Babel plugin to generate a .d.ts file from a source file with JSDoc annotations."},"warnings":[{"fix":"Add explicit type annotations to parameters that should be required, or update code to handle optional parameters","message":"Untyped parameters now treated as optional (since v0.5.0)","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Ensure you have babel-core@^6.x installed, not @babel/core","message":"Requires babel-core (not @babel/core) due to legacy Babel 6 plugin API","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Consider alternatives like tsc or @babel/preset-typescript for generating .d.ts files","message":"The project has not been updated since 2017 and may not work with modern Babel versions","severity":"deprecated","affected_versions":">0.6.3"},{"fix":"Verify the 'output' option points to a folder; plugin generates .d.ts for each file but may require additional config","message":"Supports only default exports? Check configuration for named exports","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"If you need _-prefixed exports in .d.ts, adjust the 'suppressPrivate' option (not documented)","message":"Private exports (prefixed with _) are suppressed by default since v0.6.0","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Always await or use .then() when calling babel.transform() with this plugin","message":"Generator yields a Promise, not synchronous result","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.6.3':22 'activ':39 'annot':20,59,63 'appear':30 'ast':47 'aurelia':86 'babel':2,6,45,73,87 'babel-dts-gener':1 'babel-pars':44 'clean':83 'code':16 'convert':43 'd.ts':12 'declar':11,50 'differenti':69 'dts':3,88 'export':81 'featur':52 'file':13 'generat':4,9 'includ':70 'integr':71 'javascript':15,85 'jsdoc':18 'key':68 'latest':25 'like':53 'liter':66 'mainten':34 'mode':35 'object':54 'paramet':55 'pars':46 'pipelin':76 'plugin':7 'privat':80 'project':29 'recent':38 'releas':27 'special':41 'stabl':26 'string':65 'support':51 'suppress':78 'this-typ':56 'transform':75 'type':19,58,62,67,84 'typeof':61 'typeof-typ':60 'typescript':10,49 'version':21","created_at":"2026-04-25T11:15:26.893125+00:00","updated_at":"2026-04-25T11:15:26.893125+00:00","problems":[{"fix":"Install regenerator-runtime and require('regenerator-runtime/runtime') at your entry point","cause":"Async/await usage without regenerator runtime polyfill","error":"ReferenceError: regeneratorRuntime is not defined"},{"fix":"Run npm install babel-core@^6.0.0 --save-dev","cause":"babel-core not installed or wrong version (needs v6)","error":"Cannot find module 'babel-core'"},{"fix":"Use const generator = require('babel-dts-generator').default; in CommonJS","cause":"Using default import incorrectly with CommonJS require","error":"TypeError: generator is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/YoloDev/babel-dts-generator","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/babel-dts-generator","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}