Comfy-Org / Comfy-Org/ComfyUI_frontend

[DevTask] Explicit null vs undefined

Open
#4,737 0 comments 0 reactions 0 assignees View on GitHub
developer experience
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

### Current

There are enough discussions on this topic, but as it pertains to Litegraph, the vast majority `null` usage in the library appears to be stylistic, rather than functional.

Strict typing in TypeScript becomes extremely verbose when `null` is used simply as a stand-in for idiomatic `undefined`. Worse still, it often requires runtime guards to guarantee type safety.

### Proposed

Wherever `null` is used for indeterminate purposes, and could simply be replaced with `undefined` (or e.g. just not returning a value), it should be.

Prefer shorthand where appropriate, e.g. optional properties. Adding `| undefined` works for props/params that must be specified, but may not have a value.

Any use of explicit null where it is strict-equality checked can be ignored - it's serving some purpose or another. There are only a handful of instances, anyway.

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-4737-DevTask-Explicit-null-vs-undefined-2476d73d36508123b008d0ed0dfccb25) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.