Skip to content

Commit 95be04c

Browse files
committed
refactor: update parameter handling in getFlowValidation.ts for improved null support
1 parent 306fe40 commit 95be04c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/validation/getFlowValidation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const getFlowValidation = (
2828
// We ignore this in flow validation too because we might generate code for incomplete flows.
2929

3030
let nodeId: NodeFunction['id'] | undefined;
31-
let parameterIndex: number | undefined;
31+
let parameterIndex: number | null = null;
3232

3333
if (d.start !== undefined) {
3434
const fullText = sourceFile.getFullText();
@@ -40,7 +40,7 @@ export const getFlowValidation = (
4040
const searchText = fullText.substring(searchStart, searchEnd);
4141

4242
// Find all @pos comments in the search range
43-
const posRegex = /\/\* @pos ([^ ]+) (\d+) \*\//g;
43+
const posRegex = /\/\* @pos ([^ ]+) (\d+|null) \*\//g;
4444
let match;
4545
let closestMatch: RegExpExecArray | null = null;
4646
let closestCommentEnd = -1;
@@ -62,8 +62,8 @@ export const getFlowValidation = (
6262
}
6363

6464
if (closestMatch) {
65-
nodeId = closestMatch[1] === "undefined" ? undefined : closestMatch[1] as NodeFunction['id'];
66-
parameterIndex = parseInt(closestMatch[2], 10);
65+
nodeId = closestMatch[1] === "null" ? null : closestMatch[1] as NodeFunction['id'];
66+
parameterIndex = parseInt(closestMatch[2], 10) || null;
6767
}
6868
}
6969

0 commit comments

Comments
 (0)