Skip to content

Intersection types not merged in 4.9.4Β #52252

@jenovs

Description

@jenovs

Bug Report

πŸ”Ž Search Terms

Intersection types not merged

πŸ•— Version & Regression Information

  • This changed between versions 4.8.2 and 4.9.4

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type Query = {
  listing: {
    features: {
      primary:
      { __typename?: 'Feature' }
      & {
        colors: {
          light: number,
          dark: number,
        },
      }
    },
    categories: Array<{ raw: number, formatted: string }>
  }
  & Fragment
}

type Fragment = {
  features: {
    primary:
    { __typename?: 'Feature' }
    & {
      colors: {
        light: number
      }
    },
  },
  categories: Array<{ formatted: string }>
}

const response: Query = {
  listing: {
    features: {
      primary: {
        colors: {
          light: 1,
          dark: 3,
        },
      },
    },
    categories: [
      {
        raw: 2,
        formatted: 'Used',
      },
    ],
  },
}

πŸ™ Actual behavior

colors.dark and categories.raw are marked as errors as missing in the type definition.

πŸ™‚ Expected behavior

Errored fields are defined in the Query type and should be valid.
If I remove { __typename?: 'Feature' } from Fragment the error goes away.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions