Skip to content

Make internal functions public #113

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

Closed
christophercliff opened this issue Aug 25, 2017 · 4 comments
Closed

Make internal functions public #113

christophercliff opened this issue Aug 25, 2017 · 4 comments
Assignees

Comments

@christophercliff
Copy link

Thanks for putting this library together. For my use case, I used your parser and AST and wrote my own formatter. For cases like these it would be useful if these internal functions were made public so they follow semver and have basic documentation and typings.

It might also cut down on API thrashing related to formatting options because users can use whatever formatting they prefer.

@bcherny
Copy link
Owner

bcherny commented Aug 28, 2017

Hi @christophercliff - Can you be more specific? Which functions in particular would be useful to expose?

Out of curiosity what was the different between your formatter's output and the default output?

@bcherny bcherny self-assigned this Aug 28, 2017
@christophercliff
Copy link
Author

My usage looks like:

import { normalize } from 'json-schema-to-typescript/dist/src/normalizer'
import { parse } from 'json-schema-to-typescript/dist/src/parser'

myFormatter(parse(normalize(myJsonSchema)))

myFormatter() outputs a single type with everything inline (no declarations, exports, or interface reuse). This made it easier to inline the type definitions in my existing code generator. I also removed the styling and just run the output through prettier.

@bcherny
Copy link
Owner

bcherny commented Aug 28, 2017

I didn't realize Prettier supports TypeScript - Seems like a great candidate for #45.

@bcherny
Copy link
Owner

bcherny commented Aug 28, 2017

That said, these internal functions can already be consumed (like you did in your example). Exporting them from the index would make it look like they should be consumed directly, when they are not meant to be, at least for most use cases.

I'll close this issue for now. If there's more interest in the future (meaning the use case is not a niche one), we can revisit this.

@bcherny bcherny closed this as completed Aug 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants