Skip to content

Commit 312cba1

Browse files
🤖 Merge PR DefinitelyTyped#73295 [@wordpress/blocks] Added the enum field to block attributes by @joshualip-plaudit
1 parent 6a4cc78 commit 312cba1

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

‎types/wordpress__blocks/index.d.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,12 @@ export namespace AttributeSource {
486486
| {
487487
type: "number";
488488
default?: number | undefined;
489+
enum?: number[] | undefined;
489490
}
490491
| {
491492
type: "string";
492493
default?: string | undefined;
494+
enum?: string[] | undefined;
493495
}
494496
);
495497

@@ -552,10 +554,12 @@ export namespace AttributeSource {
552554
| {
553555
type: "number";
554556
default?: number | undefined;
557+
enum?: number[] | undefined;
555558
}
556559
| {
557560
type: "string";
558561
default?: string | undefined;
562+
enum?: string[] | undefined;
559563
}
560564
)
561565
)

‎types/wordpress__blocks/wordpress__blocks-tests.tsx‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,23 @@ blocks.registerBlockType<{ foo: string }>("my/foo", {
359359
category: "common",
360360
});
361361

362+
// $ExpectType Block<{ foo: string; }> | undefined
363+
blocks.registerBlockType<{ foo: string }>("my/foo", {
364+
attributes: {
365+
foo: {
366+
type: "string",
367+
enum: ["bar", "baz"],
368+
},
369+
},
370+
icon: {
371+
src: "carrot",
372+
foreground: "orange",
373+
background: "green",
374+
},
375+
title: "Foo",
376+
category: "common",
377+
});
378+
362379
// $ExpectType Block<{ foo: object; }> | undefined
363380
blocks.registerBlockType<{ foo: object }>("my/foo", {
364381
attributes: {

0 commit comments

Comments
 (0)