iov-core icon indicating copy to clipboard operation
iov-core copied to clipboard

Self documenting REPL

Open ethanfrey opened this issue 6 years ago • 2 comments

Building on #219

It would be nice for a developer to get some feedback and API insight directly in the REPL. We have this is the IDE, and it doesn't have to be so nice, but at least listing the methods on a class and arguments to a method....

I hacked something like this into the javascript weave-js repl:

  • https://github.com/confio/weave-js/blob/master/bin/cli.js#L36-L64
  • https://github.com/confio/weave-js/blob/master/bin/args.js

We should be able to do something at least as powerful with the typescript info

ethanfrey avatar Aug 03 '18 10:08 ethanfrey

Apparently this is a known and open issue in ts-node: https://github.com/TypeStrong/ts-node/issues/8

There is a fork that produces something very nice (eg :type Buffer scroll to the bottom of the readme), but this seems unmaintained: https://github.com/HerringtonDarkholme/typescript-repl/blob/master/README.md

Other ideas? I would really like something closer to the IDE type hints when writing functions in the repl

ethanfrey avatar Aug 05 '18 20:08 ethanfrey

Just discovered this tidbit in ts-node

> .type profile
const profile: UserProfile
> .type profile.getIdentities
(method) UserProfile.getIdentities(n: number): ReadonlyArray<LocalIdentity>

ethanfrey avatar Aug 06 '18 14:08 ethanfrey