Skip to content

Issue with context typing #87

@sinedied

Description

@sinedied

Hey @rohit-ganguly I bumped into an issue today because of this typing:

interface AIChatCompletionOptions {
    context?: object;
    sessionState?: unknown;
}

Because of the object type, you can't index it on arbitrary property as TypeScript reports an error. Some linters like @typescript-eslint reports an error because of this type too.

The same issue also exists with the other context occurrences in AIChatCompletion, AIChatCompletionDelta, AIChatMessage, AIChatMessageDelta.

I recommend updating the type from object to Record<string, unknown> which solves the issues above. This is a common type used in TS for generic indexable objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions