cacjs / cac

Simple yet powerful framework for building command-line apps.
MIT License
2.65k stars 104 forks source link

It's impossible to get type definitions working because of EventEmitter #72

Closed drawveloper closed 4 years ago

drawveloper commented 4 years ago

I have spent the best of the last three hours trying innovative ways to make my VSCode understand the typing definitions in this TypeScript program from my client deno cli app. Alas, I have failed.

My attempt consisted of trying to leverage deno compiler options to add types like this:

// @deno-types="https://raw.githubusercontent.com/firstdoit/cac/master/mod.d.ts"
export { cac } from 'https://raw.githubusercontent.com/firstdoit/cac/master/mod.js'

And then to generate said mod.d.ts from the types/* directory.

It's apparently impossible, because you inline EventEmitter (https://github.com/cacjs/cac/pull/66) but all "dts generation tools" I tried were unable to inline the events library.

Tools I tried to create a single dts: https://github.com/Swatinem/rollup-plugin-dts https://github.com/timocov/dts-bundle-generator

You can take a look at my commits if it helps: https://github.com/firstdoit/cac/commit/44e763c88ab4aa3f627b20f8548ad6305ed9031d https://github.com/firstdoit/cac/commit/4637d6bcfae0cc93fe981f6f7361adf48c11d6a6

I'm giving up on cac for now, since apparently deno is really at a stage when it's best to only import .ts, deno-native libs directly. :(

egoist commented 4 years ago

Fixed in latest version: 

// deno-types="https://unpkg.com/cac/mod.d.ts"
import { cac } from 'https://unpkg.com/cac/mod.js'

const cli = cac('my-program')