prismicio / prismic-ts-codegen

A Prismic model-to-TypeScript-type generator.
Apache License 2.0
18 stars 6 forks source link

fix: support fields with hyphenated API IDs #7

Closed seanlail closed 2 years ago

seanlail commented 2 years ago

Closes https://github.com/prismicio/prismic-ts-codegen/issues/6

Types of changes

Description

Codegen was failing if a field name included hyphens. This PR sets the value correctly using a template literal and wrapping in quotes.

Before After
```typescript interface Example { my-field: string; } ``` ```typescript interface Example { "my-field": string; } ```

Checklist:

codecov-commenter commented 2 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (main@0953400). Click here to learn what that means. The diff coverage is n/a.

@@           Coverage Diff           @@
##             main       #7   +/-   ##
=======================================
  Coverage        ?   95.43%           
=======================================
  Files           ?       20           
  Lines           ?      307           
  Branches        ?       63           
=======================================
  Hits            ?      293           
  Misses          ?        2           
  Partials        ?       12           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0953400...31b34b8. Read the comment docs.

angeloashmore commented 2 years ago

Thanks @seanlail, this looks great. I added a few more tests to check types with child fields, such as Group fields and Slices.