cloudflare / cloudflare/agents

Allow proper types for agent props

Open
#1,886 1 comment 0 reactions 1 assignee Claimed by @mattzcarey View on GitHub
Dominant language
TypeScript
Stars
5.6k
Forks
711
Avg merge
1d 20h
Merged PRs (30d)
53

Description

**Describe the bug**
The generic types for `Agent` enforces `Record` as bound for `Props`. This Record type requires subtypes to define an index signature for type `string`, which prevents using interfaces with well-defined properties.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
While the type could still *default* to `Record`, it should allow using proper interfaces that have no index signature.

**Screenshots**

This is the error reported by Typescript on a `getAgentsByName` call passing `{ props: config }` as third argument:

Image

**Version:**
0.17.3

**Additional context**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.