Skip to content

Commit

Permalink
feat(typeEvaluator): validate if arg to sanity::versionOf is string
Browse files Browse the repository at this point in the history
  • Loading branch information
j33ty committed Jul 23, 2024
1 parent db54be4 commit 0f4d047
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/typeEvaluator/functions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-statements */
import type {FuncCallNode} from '../nodeTypes'
import {Scope} from './scope'
import {walk} from './typeEvaluate'
Expand Down Expand Up @@ -297,7 +298,13 @@ export function handleFuncCallNode(node: FuncCallNode, scope: Scope): TypeNode {
})
}
case 'sanity.versionOf': {
return {type: 'array', of: {type: 'string'}}
const typeNode = walk({node: node.args[0], scope})
return mapConcrete(typeNode, scope, (typeNode) => {
if (typeNode.type !== 'string') {
return {type: 'null'}
}
return {type: 'array', of: {type: 'string'}}
})
}
default: {
return {type: 'unknown'}
Expand Down

0 comments on commit 0f4d047

Please sign in to comment.