spectacles-ts icon indicating copy to clipboard operation
spectacles-ts copied to clipboard

JSDoc

Open anthonyjoeseph opened this issue 3 years ago • 3 comments

examples from where?

  • readme
  • blog post
  • tests

anthonyjoeseph avatar Apr 09 '22 14:04 anthonyjoeseph

@anthonyjoeseph this is good one https://codesandbox.io/s/spectacles-ts-experiments-krc1x9?file=/src/experiments.ts

but from tests is better

ivklgn avatar Apr 09 '22 18:04 ivklgn

@anthonyjoeseph im ready to contribute jsdoc. what kind of format?

ivklgn avatar Apr 11 '22 14:04 ivklgn

Oh wow that would be great! I think something modelled after fp-ts

/**
 * Sets a value at a particular path
 * 
 * If a value at the path doesn't exist, return O.none, otherwise wrap the result in O.some
 *
 * @example
 * import { pipe } from 'fp-ts/function'
 * import * as O from 'fp-ts/Option'
 * import { setOption } from 'spectacles-ts/set'
 * 
 * type Data = { a?: { b: number } }
 * 
 * assert.strictEqual(
 *   pipe(
 *     { a: { b: 123 } } as Data,
 *     setOption('a.b', 456)
 *   ),
 *   O.some({ a: { b: 456 } })
 * )
 * assert.strictEqual(
 *   pipe(
 *     {} as Data,
 *     setOption('a?.b', 456)
 *   ),
 *   0.none
 * )
 *
 * @since 1.0.7
 */

We should probably use docs-ts at some point to make sure that the examples actually compile

anthonyjoeseph avatar Apr 11 '22 15:04 anthonyjoeseph