google / schema-dts

JSON-LD TypeScript types for Schema.org vocabulary
Apache License 2.0
860 stars 32 forks source link

Add Type-safe strings for Number, Integer, Float #163

Closed Eyas closed 2 years ago

Eyas commented 2 years ago

Schema.org Numbers, Integers, and Floats support being assigned to strings with the appropriate fromat (e.g. "4394" for Integer). With TypeScript 4.1.0 and beyond, this can be expressed with the `${number}` type. This pushes the minimum required version for schema-dts from 3.4.0 to 4.1.0, and is thus a breaking change.

Note there's a future situation where we would RESTRICT the Integer type further; so that only valid integral numbers are assignable to it. This will be another breaking change for another time, when TypeScript can finally represent this.

Fixes #130.