Skip to content

bug: invalid types for sessionIdGenerator in 1.25.2 #1397

@domdomegg

Description

@domdomegg

SDK 1.25.2 introduced types that break projects using sessionIdGenerator: undefined with strict TypeScript configs.

Errors

error TS2379: Argument of type '{ sessionIdGenerator: undefined; enableJsonResponse: true; }'
is not assignable to parameter of type 'WebStandardStreamableHTTPServerTransportOptions' with
'exactOptionalPropertyTypes: true'.
  Types of property 'sessionIdGenerator' are incompatible.
    Type 'undefined' is not assignable to type '() => string'.
error TS2379: Argument of type 'StreamableHTTPServerTransport' is not assignable to parameter
of type 'Transport' with 'exactOptionalPropertyTypes: true'.
  Types of property 'onclose' are incompatible.
    Type '(() => void) | undefined' is not assignable to type '() => void'.
      Type 'undefined' is not assignable to type '() => void'.

Cause

Optional properties like sessionIdGenerator?: () => string need to be typed as sessionIdGenerator?: (() => string) | undefined to allow explicitly passing undefined.

Similarly, the Transport interface's onclose property needs the same treatment.

I beleive this was recently changed in #1326

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions