> ## Documentation Index
> Fetch the complete documentation index at: https://docs.commonality.co/llms.txt
> Use this file to discover all available pages before exploring further.

# diff

```ts theme={null}
(source: unknown, target: unknown) => string;
```

The `diff` utility makes it easier to provide a helpful suggestion for check [messages](#message).

We use the `jest-diff` utility to generate a diff that highlights values present in `target` but not `source`.

Values will be stringified and parsed as lines of text. Lines that appear in `target` but not `source` will appear in red with a `+` prefix.

## Parameters

<ParamField path="source" type="unknown" required>
  Any value, representing the source of the diff.
</ParamField>

<ParamField path="target" type="unknown" required>
  Any value, representing the target of the diff.
</ParamField>

## Returns

Returns a string representing the diff between `source` and `target`.

## Example

```ts theme={null}
diff('first', 'second');
//   first
// + second

diff(
  { name: 'my-package', version: '1.0.0' },
  { name: 'my-package', version: '2.0.0' },
);
//   Object {
//     "name": "my-package",
//     "version": "1.0.0",
// +   "version": "2.0.0",
//   }
```
