R12SAFEfunction

Parameter Type Widened

Flags when a parameter type becomes more permissive. All existing callers remain valid because the broader type accepts everything the narrow type did.


Applies to

TypeScriptPythonGoJavaRust

Why it matters

Widening a parameter type is safe. If a function accepted string and now accepts string | number, all callers passing strings still work.

Example

Before (string only)
// parser.ts
export function parse(input: string): AST { ... }
After (string | Buffer)
// parser.ts (SAFE)
export function parse(input: string | Buffer): AST { ... }

What you see in the terminal

$ npx dg check

  [SAFE] parse (signature_change)
  src/parser.ts:2
  Parameter 'input' type widened from 'string' to 'string | Buffer'. Existing callers are unaffected.

How detection works

The classifier detects when the new parameter type is a superset of the old type (more union members, added null, etc.) and reports it as safe.

Real-world scenario

A parser library adds Buffer support for stream pipelines. Existing callers passing strings are unaffected.

Edge cases

  • Widening from a specific type to 'any' is technically safe but suspicious
  • Adding 'undefined' to a required param's type may change behavior