Comparing version 1.14.1 to 1.14.2
{ | ||
"name": "groq-js", | ||
"version": "1.14.1", | ||
"version": "1.14.2", | ||
"keywords": [ | ||
@@ -71,22 +71,22 @@ "sanity", | ||
"devDependencies": { | ||
"@sanity/pkg-utils": "6.10.2", | ||
"@sanity/prettier-config": "^1.0.2", | ||
"@sanity/pkg-utils": "6.11.14", | ||
"@sanity/prettier-config": "^1.0.3", | ||
"@sanity/semantic-release-preset": "^5.0.0", | ||
"@types/debug": "^4.1.12", | ||
"@types/tap": "^15.0.11", | ||
"@typescript-eslint/eslint-plugin": "^7.15.0", | ||
"@typescript-eslint/parser": "^7.15.0", | ||
"eslint": "^8.57.0", | ||
"@types/tap": "^15.0.12", | ||
"@typescript-eslint/eslint-plugin": "^7.18.0", | ||
"@typescript-eslint/parser": "^7.18.0", | ||
"eslint": "^8.57.1", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-config-sanity": "^7.1.2", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"eslint-config-sanity": "^7.1.3", | ||
"eslint-plugin-prettier": "^5.2.1", | ||
"eslint-plugin-simple-import-sort": "^12.1.1", | ||
"ndjson": "^2.0.0", | ||
"prettier": "^3.3.2", | ||
"prettier": "^3.4.2", | ||
"rimraf": "^5.0.0", | ||
"semantic-release": "^24.0.0", | ||
"semantic-release": "^24.2.0", | ||
"semver": "^7.5.4", | ||
"tap": "^16.3.10", | ||
"tsx": "^4.16.2", | ||
"typescript": "5.5.3" | ||
"tsx": "^4.19.2", | ||
"typescript": "5.7.2" | ||
}, | ||
@@ -93,0 +93,0 @@ "engines": { |
/* eslint-disable max-statements */ | ||
import type {FuncCallNode} from '../nodeTypes' | ||
import {optimizeUnions} from './optimizations' | ||
import {Scope} from './scope' | ||
@@ -178,8 +179,28 @@ import {walk} from './typeEvaluate' | ||
for (const arg of node.args) { | ||
const type = walk({node: arg, scope}) | ||
typeNodes.push(unionWithoutNull(type)) | ||
const argNode = optimizeUnions(walk({node: arg, scope})) | ||
// Check if all types are null | ||
const allNull = | ||
argNode.type === 'null' || | ||
(argNode.type === 'union' && argNode.of.every((t) => t.type === 'null')) | ||
// Can the argument be null, if all is null, unknown, or if its a union with at least one null or unknown | ||
canBeNull = | ||
type.type === 'null' || (type.type === 'union' && type.of.some((t) => t.type === 'null')) | ||
allNull || | ||
argNode.type === 'unknown' || | ||
(argNode.type === 'union' && | ||
argNode.of.some((t) => t.type === 'null' || t.type === 'unknown')) | ||
// As long as some type is not null or unknown, we add it to the union, but skip nulls | ||
if (!allNull) { | ||
typeNodes.push(unionWithoutNull(argNode)) | ||
} | ||
// If we have a type that can't be null, we can break. | ||
if (!canBeNull) { | ||
break | ||
} | ||
} | ||
// If the last argument can be null, we add null to the union | ||
if (canBeNull) { | ||
@@ -186,0 +207,0 @@ typeNodes.push({type: 'null'} satisfies NullTypeNode) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13925
1030072