Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONArray: RawRepresentable conflicts with Array: RawRepresentable where Element: Codable #217

Open
hermiteer opened this issue Apr 5, 2024 · 1 comment

Comments

@hermiteer
Copy link

hermiteer commented Apr 5, 2024

There's a popular pattern of folks extending arrays of Codable to allow use with @AppStorage as described here:

https://stackoverflow.com/questions/62562534/swiftui-what-is-appstorage-property-wrapper/62563773#62563773

Unfortunately Turf's JSONArray conflicts with this extension due to:

Conflicting conformance of 'Array<Element>' to protocol 'RawRepresentable'; there cannot be more than one conformance, even with different conditional bounds

If Swift won't allow multiple RawRepresentable extensions, what are our options here? Is it possible to keep JSONArray internal to the Turf package? For that matter, do any of the JSON types need to be public?

So far I've been unable to find another way to express the Array extension that makes the compiler happy, so would love to hear any other ideas.

Note: I'm not using Turf directly, it comes with the Mapbox SDK.

@1ec5
Copy link
Contributor

1ec5 commented Aug 23, 2024

The RawRepresentable usage in this package always seemed a bit too magical to me, but people seemed to like how it led to less typing when writing runtime styling code in the map SDK. #219 would replace this conformance with something more custom, also for JSONObject.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants