kristiandupont / kanel

Generate Typescript types from Postgres
https://kristiandupont.github.io/kanel/
MIT License
829 stars 57 forks source link

Specify pg_catalog.* in the docs for customTypeMap #569

Closed ersinakinci closed 3 weeks ago

ersinakinci commented 3 weeks ago

I just spent about an hour trying to figure out how to map numeric to my own custom type. In the end, I realized that I needed to write out "pg_catalog.numeric": "MyType".

The docs and a lot of the GitHub issues make it clear that I need to use the customTypesMap config option, but it wasn't clear that I need to prefix my types with pg_catalog for it to work.

The docs do use pg_catalog.tsvector and pg_catalog.bpchar as examples, but because tsvector and bpchar are somewhat exotic types, and because I didn't know what pg_catalog is, I didn't realize that the pg_catalog prefix was necessary for any type mapping. I thought maybe pg_catalog.tsvector and pg_catalog.bpchar were "special."

Also, some of the older GH issues don't use the pg_catalog table name prefix.

May I suggest putting a little blurb in the docs to clarify when pg_catalog needs to be specified and why?

kristiandupont commented 3 weeks ago

I am sorry you had to struggle with that! You are right, that should be documented -- or preferably, there should be an error message that nudges you to the right answer. I will fix this.

ersinakinci commented 3 weeks ago

All good, and thank you!

kristiandupont commented 3 weeks ago

I made a small edit to the docs, do you think this covers it? Or am I missing something confusing?

https://github.com/kristiandupont/kanel/commit/e82ec52b904655e37ae40b14fcad622afde8f288#diff-93a1945494e5a3cbbcd925b18baacd4573b5fdcfd1a9c8e1dbbfe7d1df700015L71

ersinakinci commented 3 weeks ago

I think that looks great.

If I had to guess, however, I would say that most people are like me and never get to that page in the docs. I went straight from "Getting Started" to "Data Types." I didn't even see that there's a "Configuring" page because it's bunched in there in the sidebar with links to API docs pages, making the entire group of pages look like an API reference, which makes it easy to ignore. Also, lots of people are coming directly to a page from search engines. (I've worked as a technical writer so I'm a little nitpick-y.)

Personally, I would:

ersinakinci commented 3 weeks ago

Another tip:

kristiandupont commented 3 weeks ago

I've updated the example config. I don't think I want to rename the section because in my opinion, "API Reference" implies that it's for programmatic usage, which isn't really the case. Thank you for your inputs!