Back to all reviewers

avoid suppressing TypeScript errors

unionlabs/union
Based on 2 comments
Other

Do not use `@ts-expect-error` comments to suppress TypeScript errors, especially those related to null, undefined, or type safety. These errors are designed to catch potential runtime issues and should be properly resolved instead of silenced.

Null Handling Other

Reviewer Prompt

Do not use @ts-expect-error comments to suppress TypeScript errors, especially those related to null, undefined, or type safety. These errors are designed to catch potential runtime issues and should be properly resolved instead of silenced.

TypeScript’s type system helps prevent null reference errors and other type-related bugs. When you encounter type errors, investigate and fix the root cause rather than suppressing them.

Instead of:

// @ts-expect-error
someFunction(potentiallyNullValue)

Fix the underlying issue:

if (potentiallyNullValue !== null) {
  someFunction(potentiallyNullValue)
}

Similarly, prefer type-safe patterns like derived() stores for read-only computed values instead of writable() stores that allow unsafe mutations:

// Prefer this - read-only derived state
let destinationChain = derived(chains, $chains => 
  $chains.find(chain => chain.chain_id === destination)
)

// Over this - writable store for derived data
let destinationChain = writable(chains.find(chain => chain.chain_id === destination))

If you must temporarily suppress an error during development, add a detailed comment explaining why and create a task to fix it properly.

2
Comments Analyzed
Other
Primary Language
Null Handling
Category

Source Discussions