Joel Thoms
Jul 6, 2018 · 1 min read

This is something I have been interested in very recently. Check out my question on SO https://stackoverflow.com/questions/51034557/where-is-this-vscode-intellisense-coming-from. (gotta read the comments)

With some help, I was able to find the code I needed to make these readable in VSCODE.

The missing piece was inspect.

wrapped[inspect] = wrapped.toString = () => 'custom name here'

You may find the sanctuary-def library interesting as it is doing a lot of the same things you are here.

sanctuary-def will show you the type definition…

//    add :: Number -> Number -> Number
const add =
def ('add')
({})
([$.Number, $.Number, $.Number])
(x => y => x + y);

It will also give you useful debug logs…

add (2, 2, 2);
// ! TypeError: ‘add’ applied to the wrong number of arguments
//
// add :: Number -> Number -> Number
// ^^^^^^
// 1
//
// Expected one argument but received three arguments:
//
// - 2
// - 2
// - 2

Cheers!

    Joel Thoms

    Written by

    Computer Scientist and Technology Evangelist with 20+ years of experience with JavaScript!