Skip to content

Commit 78dd7f1

Browse files
committed
fix: only throw if multiple results are different
1 parent 00deae8 commit 78dd7f1

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/parse.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SyntaxError } from './errors';
1+
import { LiqeError, SyntaxError } from './errors';
22
import grammar from './grammar';
33
import { hydrateAst } from './hydrateAst';
44
import { type LiqeQuery, type ParserAst } from './types';
@@ -52,7 +52,14 @@ export const parse = (query: string): LiqeQuery => {
5252
}
5353

5454
if (results.length > 1) {
55-
throw new Error('Ambiguous results.');
55+
const firstResult = JSON.stringify(results[0]);
56+
57+
for (const result of results) {
58+
// Only throw if the results are different.
59+
if (JSON.stringify(result) !== firstResult) {
60+
throw new LiqeError('Ambiguous results.');
61+
}
62+
}
5663
}
5764

5865
const hydratedAst = hydrateAst(results[0]);

tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"declaration": true,
55
"esModuleInterop": true,
66
"forceConsistentCasingInFileNames": true,
7+
"lib": [
8+
"es2021"
9+
],
710
"module": "commonjs",
811
"moduleResolution": "node",
912
"noImplicitAny": false,
@@ -12,9 +15,6 @@
1215
"noUnusedParameters": false,
1316
"outDir": "dist",
1417
"skipLibCheck": true,
15-
"lib": [
16-
"es2021"
17-
],
1818
"strict": true,
1919
"target": "ES2018"
2020
},

0 commit comments

Comments
 (0)