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 a name starting with a number #25

Closed angeloashmore closed 2 years ago

angeloashmore commented 2 years ago

Types of changes

Description

This PR fixes a bug where prismic-ts-codegen would crash if it came across a field API ID starting with a number.

For example, a field with the API ID of 3d_noodle would cause the following error:

ManipulationError: Manipulation error: A syntax error was inserted.

types.d.ts:2910:6 - error TS1351: An identifier or keyword cannot immediately follow a numeric literal.

This PR fixes this issue by wrapping those field name properties with quotation parts (e.g. "3d_noodle").

For more details, see #24. Thanks to @AugusDogus for reporting the issue!

Checklist:

🍝

github-actions[bot] commented 2 years ago

size-limit report 📦

Path Size
dist/index.js 1.07 MB (+0.01% 🔺)
dist/index.cjs 1.08 MB (+0.01% 🔺)
codecov-commenter commented 2 years ago

Codecov Report

Merging #25 (d4b34b5) into main (08c4e2f) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main      #25   +/-   ##
=======================================
  Coverage   90.50%   90.50%           
=======================================
  Files          21       21           
  Lines         337      337           
  Branches       82       82           
=======================================
  Hits          305      305           
  Misses          4        4           
  Partials       28       28           
Impacted Files Coverage Δ
src/lib/addInterfacePropertiesForFields.ts 86.91% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us.