microsoft / microsoft/ai-chat-protocol

Issue with context typing

Open
#87 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
177
Forks
27
Avg merge
21d 22h
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the definitions of AIChatCompletionOptions, AIChatCompletion, AIChatCompletionDelta, AIChatMessage, and AIChatMessageDelta, then inspect each context property. Update the context typing as described and run the project's TypeScript checks or linter to verify that arbitrary property access and the existing protocol types remain valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.