mohuk / ts-jsonapi

JSON API (De)Serializer in Typescript
MIT License
52 stars 10 forks source link

keyForAttribute declaration appears to be incorrect #6

Closed snortblt closed 5 years ago

snortblt commented 6 years ago

The Serializer.keyForAttribute property type is declared as (attribute: string) => string | caseOptions. Providing a function that returns one of these caseOptions prevents correct serialization of any attributes. If the property is assigned to a caseOptions literal string instead serialization works. Should the type be declared as ((attribute: string) => string) | caseOptions instead (note the parens)?

mohuk commented 6 years ago

Hey @snortblt

Can you add a test case for it ? As in just to demonstrate your use case.

christianengledercadt commented 5 years ago

Please add the brackets, the are necessary for the ts compiler.

christianengledercadt commented 5 years ago

(attribute: string) => string | caseOption => ((attribute: string) => string) | caseOption

mohuk commented 5 years ago

Done 👍

Thanks @snortblt and @christianengledercadt

mohuk commented 5 years ago

Released v2.1.2 on npmjs.

https://www.npmjs.com/package/ts-jsonapi