Skip to content

[BUG] Jsonify marks properties that are required and may be undefined as optional #689

@fnimick

Description

@fnimick

Describe the bug
Jsonify marks all properties that may be undefined as optional, which breaks when dealing with types that have required, potentially undefined properties.

To Reproduce

Example:

import { type Jsonify } from "inngest/helpers/jsonify";

interface Test {
  prop: string | null | undefined;
  requiredProp: string;
  optionalProp?: string | null;
}

type TestJsonify = Jsonify<Test>;

TestJsonify has the following type:

type TestJsonify = {
    prop?: string | null | undefined;
    requiredProp: string;
    optionalProp?: (string | null) | undefined;
}

This means that values of type Jsonify<Test> can no longer be assigned to values of type Test, as the required, potentially undefined property no longer type checks.

Expected behavior
The type of Jsonify<object> and the object itself should match, for simple interfaces like this.

Code snippets / Logs / Screenshots
If applicable, add screenshots to help explain your problem.

System info (please complete the following information):

  • npm package Version: 3.22.0

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

📦 inngestAffects the `inngest` package

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions