You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a link field with variants with Slice Machine
Check out generated TypeScript
What is expected?
Link variants should be precisely typed when available values are known (always the case for a link field typed after a custom type definition)
This starts by allowing the LinkField type to support another generic to type available variants beyond string but it's not really ideal without reordering generics today (which would be a breaking change).
From here, prismic-ts-codegen could leverage the generic to type variants more precisely the same way it does it for other generic-dependant types (e.g. constrained content relationships)
The field value types should primarily be consumed via the generated types rather than handwritten types. Adding another generic seems okay to me. Re-ordering should be avoided, however, as it would break existing generated types.
Versions
Steps to reproduce
What is expected?
Link variants should be precisely typed when available values are known (always the case for a link field typed after a custom type definition)
This starts by allowing the
LinkField
type to support another generic to type available variants beyondstring
but it's not really ideal without reordering generics today (which would be a breaking change).From here,
prismic-ts-codegen
could leverage the generic to type variants more precisely the same way it does it for other generic-dependant types (e.g. constrained content relationships)What is actually happening?
Generated types
Result
![Image](https://private-user-images.githubusercontent.com/25330882/402967965-3d0316bb-c082-454f-a9f2-126acdd1d96d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1NTIwNzIsIm5iZiI6MTczOTU1MTc3MiwicGF0aCI6Ii8yNTMzMDg4Mi80MDI5Njc5NjUtM2QwMzE2YmItYzA4Mi00NTRmLWE5ZjItMTI2YWNkZDFkOTZkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDE2NDkzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZjOWUyMGRjMTI0MjU1ODBjMDVhOTc0ZTBiZTVkNTU5MzIyYTM4MTYwY2Q3YTcxMGIzOTQwZWNkMDNjYTJlNTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.nddgl08jGVQhk_v8MG8vz-W6AoVbmozOxAbGLZIkQ1I)
Source code
prismic-client/src/types/value/link.ts
Lines 90 to 93 in c45f28d
The text was updated successfully, but these errors were encountered: