Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation in regard to new Babel macro #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zenflow
Copy link
Contributor

@zenflow zenflow commented Oct 23, 2020

This PR:

  1. Adds README documentation for the Babel macro added in PR Add babel macro #24
  2. Reorganizes the README to separate general info vs cli info vs macro info

@dsagal Are you ok with how I handled the 2nd point? I'm happy to change the organization however you like. Also you can feel free to take this PR and quickly change the organization however you like yourself.

Cheers 🍻

@zenflow
Copy link
Contributor Author

zenflow commented Nov 24, 2020

@dsagal Did you get a chance to take a look at this yet? Any thoughts? Don't worry about hurting my feelings or anything if you don't like it lol You can be blunt

Copy link
Member

@dsagal dsagal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reminder! It reads quite well. Including a couple of fairly minor suggestions.

const fooTypeSuite = getTypeSuite('./foo.ts', { /* options */ });
```

The code above would be transpiled into:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd skip this block. It's long, the details are mostly internal. How about something more illustrative. Maybe mention that the runtime description is generated from the interfaces found in './foo.ts', so that this becomes roughly equivalent to:

const fooTypeSuite = {
    Square: t.iface([], {
      "size": "number",
      "color": t.opt("string")
    })
  };

See [ts-interface-checker documentation](https://github.com/gristlabs/ts-interface-checker#readme) for how to use the returned type suite in your code.

The `getCheckers` macro function is also exported, as a convenience, to get a checker suite (with validator functions) directly
instead of first getting a type suite and then creating a checker suite from it (using `ts-interface-checker`s `createCheckers` function).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd insert after "as a convenience" a colon and a code block with an example of how to call it, and a one-liner example how to use it.


The `getCheckers` macro function is also exported, as a convenience, to get a checker suite (with validator functions) directly
instead of first getting a type suite and then creating a checker suite from it (using `ts-interface-checker`s `createCheckers` function).
As with `getTypeSuite`, repeated calls to `getCheckers` using the same arguments will return the same object.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: "For both getTypeSuite and getCheckers, "...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants