Skip to content

TypeScript doesn't warn me that a property is missingΒ #50845

Closed
@anas-araid

Description

@anas-araid

Bug Report

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type DataType = {
  value: (Data & Extra) | Data;
};

type Data = {
  type1: string;
};

type Extra = {
  isEditable: boolean;
  onChange: () => void;
};

const data: DataType = {
  // value should throw an error (onChange is not specified)
  value: {
    type1: 'type',
    isEditable: true,
  },
};

πŸ™ Actual behavior

TypeScript ignores this definition ((Data & Extra) | Data)

πŸ™‚ Expected behavior

I expect TypeScript to warn me that a property within value is missing: e.g (onChange is not specified)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions