-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: allow Link and Array type references as variables #685
base: development
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this PR be marked as a feat
instead? Great work on this one! 🚀
return entryOrAsset; | ||
} | ||
|
||
const arrayValue = get(entryOrAsset, path.split('/').slice(2, -1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the type for arrayValue
is being inferred as any
here. It might be nice to add a type argument so TS can help catch type errors if this code is updated in the future.
const arrayValue = get(entryOrAsset, path.split('/').slice(2, -1)); | |
const arrayValue = get<Array<string | UnresolvedLink<'Entry' | 'Asset'>>>(entryOrAsset, path.split('/').slice(2, -1)); |
const arrayValue = get(entryOrAsset, path.split('/').slice(2, -1)); | ||
|
||
if (!isArray(arrayValue)) { | ||
console.warn(`Expected a value to an array, but got: ${JSON.stringify(arrayValue)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.warn(`Expected a value to an array, but got: ${JSON.stringify(arrayValue)}`); | |
console.warn(`Expected a value to be an array, but got: ${JSON.stringify(arrayValue)}`); |
Purpose
This PR allows a dev to set up variables that can bind to lists (arrays) and entry references as such: