Skip to content

5.6 regression: Inference with mixed in type intersection no longer compilesΒ #59765

Closed as not planned
@trevorade

Description

@trevorade

πŸ”Ž Search Terms

Inference

πŸ•— Version & Regression Information

  • This changed between versions 5.5.4 and 5.6.0-beta (still happening in 5.6.1-rc)

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.6.1-rc#code/C4TwDgpgBAYgrgOwMbAJYHsEGF0FsyYQLAA8AClALxQCGCIAfFVABRgBO6YAzgFxRkAlFSYBRADYRcRYFAA+UBHHHiA3ACh1qYhHYAzGkmgSpMgILBg7VACM4wCNygBvdVCioAJngDSEEAD8-NxW2gDm8orK4pFKuDa6Gu5IABao4p7sREFQiADWCOgA7ghJUNx5qGA5NujoknQaAL6anhBI4jRZUHqIKBgIUBCS0sTkDCxuUMA0YfzwyGiYOPiEYxQAZFAmo8AWoXYO3AwANFM0ltaHjvyb2yPml7b2jmeC-DsyGuptHV3QvUWA3uADkaNI2JwePxnAhwRAciFrAgwk13vdTMRvsNMcAWBIwdITi40RoAPRkqAAEXQjkU6FkSDwYHS0G0UAArAA6ABsXKgAGUUuhlJ4oEz8KyueogA

πŸ’» Code

type FunctionComponent<P = any> = (props: P) => Element | null;

interface ElementAttributes {
  idomKey?: string | null | number;
  children?: unknown;
  skip?: boolean;
}

declare function element<P>(
  tag: FunctionComponent<P & ElementAttributes>,
  attributes: P & ElementAttributes,
): Element;

declare function ElName(props: {name?: string}): Element;

element(ElName, {});
// Does not compile in 5.6. Should compile.

πŸ™ Actual behavior

Last line errors with:

Argument of type '(props: { name?: string | undefined; }) => Element' is not assignable to parameter of type 'FunctionComponent<ElementAttributes>'.
  Types of parameters 'props' and 'props' are incompatible.
    Type 'ElementAttributes' has no properties in common with type '{ name?: string | undefined; }'.(2345)

πŸ™‚ Expected behavior

Compiles as it did in previous versions

Additional information about the issue

Confirmed that #59709 does not resolve this issue.

(Google note: relevant source location http://shortn/_Ce1E5yV592)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Not a DefectThis behavior is one of several equally-correct options

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions