Skip to content

WorkersBindingKindJson json property typed as string #2682

@JuroUhlar

Description

@JuroUhlar

Confirm this is a Typescript library issue and not an underlying Cloudflare API issue

  • This is an issue with the Typescript library

Describe the bug

Hi team!

The types for WorkersBindingKindJson seem to be:

export interface WorkersBindingKindJson {
  /**
   * JSON data to use.
   */
  json: string;

https://github.com/cloudflare/cloudflare-typescript/blob/b13f7bae1ac77ff9962fc08fae6849b0688583d3/src/resources/workers/scripts/scripts.ts#L1066C1-L1081C6

Is this correct? It prompted me to pass json: JSON.stringify({ a: "b"}) to the SDK, but this results in the variable being saved as "{\"a\":\"b\"}" instead of the expected {"a":"b"}.

Ignoring the type error and passing json: {a: "b"} seems to work as expected.

To Reproduce

const binding: ScriptUpdateParams.Metadata.WorkersBindingKindJson = {
  name: 'MY_TEST',
  type: 'json',
  json: {
    name: 'value',
  },
}
Image

Code snippets

OS

macOS

Runtime version

Typescript 4.9.4

Library version

5.2

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