Skip to content

New behavior in v6 when interface extends two incompatible interfaces under exactOptionalPropertyTypesΒ #62569

@chriskrycho

Description

@chriskrycho

πŸ”Ž Search Terms

Partial, @types/node, exactOptionalPropertyTypes, interface

πŸ•— Version & Regression Information

  • This changed between versions v5.9.3 and 6.0.0-dev.20251001

⏯ Playground Link

https://www.typescriptlang.org/play/?exactOptionalPropertyTypes=true&ts=6.0.0-dev.20251008#code/HYQwtgpgzgDiDGEAEALALmmSDeBYAUEkhAB4wD2ATmkgJbBoSUBmCyAKvDAMrnwDWENAGFywYBHhoA8jDRQcBIkQrUAXEmABXMACMmAbiVIAvgWOlVNeoxZskAQQDmEBrLS0xC0o2AATBQAFEGpaEAAbAB5OHj5BETEJKXcoAD5FQmVBCBgHcNoANwgAfg1dcnJwiBBgJAAfJC1-CGZ6CD8jTLN8boJQSFh7NHCFPEzLKmsGJlZEJFFxSQ8xd09gUeMVSdLNHX1Kesbm1okO427e-BsZ+2dXGTk17xJfANQMGAA6O7dHrwAaJDDKCfBZJZbAVZeDJEMAgEjCBAodrcaBQJ47bR6JiHJp+FptM49AhAA

πŸ’» Code

namespace http {
  export interface TcpSocketConnectOpts {
    port: number;
  }

  export interface AgentOptions extends Partial<TcpSocketConnectOpts> {
    keepAlive?: boolean | undefined;
  }
}

namespace tls {
  export interface ConnectionOptions {
    port?: number | undefined;
  }
}

interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
  maxCachedSessions?: number | undefined;
}

πŸ™ Actual behavior

This now fails to type checkβ€”I believe correctly, because Partial<{ port: number }> is { port?: number }, not { port?: number | undefined }. It’s surprising that this worked before.

πŸ™‚ Expected behavior

Actually, the new behavior is expected, so probably @types/node needs an update. I wanted to flag this in case/for when other folks hit it!

Additional information about the issue

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