Skip to content

Commit 5511325

Browse files
committed
feat: add non-null assertion for reference type validation under strictNullChecks
1 parent c647b9b commit 5511325

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ export function generateFlowSourceCode(
139139
ref.referencePath?.forEach(pathObj => {
140140
refCode += `?.${pathObj.path}`;
141141
});
142-
return `/* @pos ${id} ${index} */ ${refCode}`;
142+
// Non-null assertion: a reference typed `string | null` (or an optional
143+
// chain like `node_X?.text`) must still satisfy a plain `string` parameter
144+
// under strictNullChecks — only the nullish part is waived, base type
145+
// mismatches still fail validation.
146+
return `/* @pos ${id} ${index} */ (${refCode})!`;
143147
}
144148
if (val.__typename === "LiteralValue") {
145149
const jsonString = val?.value !== null && val?.value !== undefined ? stringify(val?.value) : undefined

0 commit comments

Comments
 (0)