Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export namespace BindingGetResponse {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ export namespace ScriptUpdateParams {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export namespace SettingEditResponse {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down Expand Up @@ -1228,7 +1228,7 @@ export namespace SettingGetResponse {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down Expand Up @@ -2077,7 +2077,7 @@ export namespace SettingEditParams {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down
4 changes: 2 additions & 2 deletions src/resources/workers/beta/workers/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ export namespace Version {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down Expand Up @@ -1502,7 +1502,7 @@ export namespace VersionCreateParams {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down
6 changes: 3 additions & 3 deletions src/resources/workers/scripts/script-and-version-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ export namespace ScriptAndVersionSettingEditResponse {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down Expand Up @@ -1224,7 +1224,7 @@ export namespace ScriptAndVersionSettingGetResponse {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down Expand Up @@ -2073,7 +2073,7 @@ export namespace ScriptAndVersionSettingEditParams {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down
2 changes: 1 addition & 1 deletion src/resources/workers/scripts/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,7 @@ export namespace ScriptUpdateParams {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down
6 changes: 3 additions & 3 deletions src/resources/workers/scripts/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export namespace VersionCreateResponse {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down Expand Up @@ -1213,7 +1213,7 @@ export namespace VersionGetResponse {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down Expand Up @@ -2022,7 +2022,7 @@ export namespace VersionCreateParams {
/**
* JSON data to use.
*/
json: string;
json: string | Record<string, unknown> | unknown[] | number | boolean | null;

/**
* A JavaScript variable name for the binding.
Expand Down
24 changes: 24 additions & 0 deletions tests/workers-binding-kind-json.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Regression test for https://github.com/cloudflare/cloudflare-typescript/issues/2682
//
// WorkersBindingKindJson's `json` property should accept any valid JSON value,
// not just strings.

import { type ScriptUpdateParams } from 'cloudflare/resources/workers/scripts/scripts';

type WorkersBindingKindJson = ScriptUpdateParams.Metadata.WorkersBindingKindJson;

const binding = (json: WorkersBindingKindJson['json']): WorkersBindingKindJson => ({
name: 'MY_BINDING',
type: 'json',
json,
});

// Type-level validation: if any of these fail to compile, the test suite won't build.
test('WorkersBindingKindJson json property accepts all JSON value types', () => {
expect(binding({ key: 'value' }).json).toEqual({ key: 'value' });
expect(binding('hello').json).toBe('hello'); // backwards compatible
expect(binding([1, 2, 3]).json).toEqual([1, 2, 3]);
expect(binding(42).json).toBe(42);
expect(binding(true).json).toBe(true);
expect(binding(null).json).toBeNull();
});
Loading