content-collections icon indicating copy to clipboard operation
content-collections copied to clipboard

Types for join collections not taking `transform` into account

Open iduuck opened this issue 1 year ago • 4 comments

When I am trying to include a join in the transform function, everything (when in proper order) will be pulled into the joined collection, but the types are not correctly generated.

The types that are acruing from the transform function are not being pulled into the join collections types.

Here is a CodeSandbox: https://codesandbox.io/p/devbox/xhnr2g

And here is a screenshot of the tsc: CleanShot 2024-11-10 at 17 05 09@2x

iduuck avatar Nov 10 '24 16:11 iduuck

This is a constraint for joining collections, as described here:

https://www.content-collections.dev/docs/transform#access-other-collections

sdorra avatar Nov 10 '24 19:11 sdorra

So this is nothing in the pipeline/fixable right now?

FWIW, the data is actually there (as long as I am placing the joined collection (Post) before the joining collection (Category). I suppose this has something to do with the cache.

I am only speaking of the types, that are being generated.

iduuck avatar Nov 10 '24 21:11 iduuck

The problem are the types. I was not able to infer the types from a transformed collection. This is really difficult, because the types are the result of the transform function and parts of the resulting types are from the transform function. Can you understand my problem? IIf you have a solution to the problem, I'm more than happy to accept a PR.

sdorra avatar Nov 11 '24 14:11 sdorra

Jup, I get it.

The actual problem is, that the joined collections are only transformed, when coming before the joining collection.

I think this is a problem, that needs to be tackled before because otherwise this would result in possibly wrong types.

iduuck avatar Nov 14 '24 11:11 iduuck