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(typeEvlauator): handle rest on object splat operations #232
base: main
Are you sure you want to change the base?
Conversation
8ef8b24
to
15ec7ac
Compare
Something looks a bit sketchy. Here we invoke the mapper multiple times: groq-js/src/typeEvaluator/typeEvaluate.ts Lines 124 to 128 in 15ec7ac
But here we assume that it's only being called once per groq-js/src/typeEvaluator/typeEvaluate.ts Lines 165 to 167 in 15ec7ac
I'm not 100% sure what the right approach here is though. Maybe more usage of |
yess, this should probably be a concrete type with mapConcrete, will fix. Didn't think much about fixing other bugs than the one referenced 😅 |
@judofyr did another pass on comparing with mapped concrete type node |
70fcc00
to
8e46302
Compare
1558ef1
to
8992280
Compare
src/typeEvaluator/typeEvaluate.ts
Outdated
const attributes: Record<string, ObjectAttribute> = {} | ||
|
||
const concreteNode = mapConcrete(node, scope, (node) => node) | ||
if (concreteNode.type === 'object') { |
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.
Hmm. Doesn't this mean that if this returns false
we end up returning {type: 'object', attributes: {}}
below? What about we instead wrap all of this in mapConcrete
?
return mapConcrete(node, scope, (node) => {
if (node.type !== 'object') return {type: 'unknown'}
const attributes: Record<string, ObjectAttribute> = {}
// same same…
})
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.
I did another pass, moved the handling of the object splats out in its own methods
8992280
to
96bc3e7
Compare
fa78ba0
to
05e70bc
Compare
When splatting an object we didn't map over the rest property, if it's an object we should append the attributes. If
rest
is unknown we should treat the entire object as unknown.Fixes sanity-io/sanity#6555