File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import type { URLSourceElement } from './block-kit/block-elements' ;
2+ import type { AnyBlock } from './block-kit/blocks' ;
23/**
34 * Base interface for streaming message chunks.
45 * https://docs.slack.dev/messaging/sending-and-scheduling-messages#text-streaming
@@ -39,7 +40,17 @@ export interface TaskUpdateChunk extends Chunk {
3940 sources ?: URLSourceElement [ ] ;
4041}
4142
43+ /**
44+ * Used for passing an array of blocks within a streaming message.
45+ * https://docs.slack.dev/changelog/2026/04/16/block-kit-new-blocks/
46+ */
47+ export interface BlocksChunk extends Chunk {
48+ type : 'blocks' ;
49+ /** @description An array of {@link AnyBlock} objects. Maximum of 50 blocks. */
50+ blocks : AnyBlock [ ] ;
51+ }
52+
4253/**
4354 * Union type of all possible chunk types
4455 */
45- export type AnyChunk = MarkdownTextChunk | PlanUpdateChunk | TaskUpdateChunk ;
56+ export type AnyChunk = MarkdownTextChunk | PlanUpdateChunk | TaskUpdateChunk | BlocksChunk ;
Original file line number Diff line number Diff line change 1+ import { expectAssignable , expectError } from 'tsd' ;
2+ import type { AnyChunk , BlocksChunk } from '../src/index' ;
3+
4+ // BlocksChunk
5+ // -- sad path
6+ expectError < BlocksChunk > ( { } ) ;
7+ expectError < BlocksChunk > ( { type : 'blocks' } ) ;
8+ expectError < BlocksChunk > ( { blocks : [ ] } ) ;
9+
10+ // -- happy path
11+ expectAssignable < BlocksChunk > ( { type : 'blocks' , blocks : [ ] } ) ;
12+ expectAssignable < BlocksChunk > ( {
13+ type : 'blocks' ,
14+ blocks : [
15+ {
16+ type : 'section' ,
17+ text : { type : 'plain_text' , text : "Sandra's plan outline" } ,
18+ } ,
19+ ] ,
20+ } ) ;
21+ expectAssignable < BlocksChunk > ( {
22+ type : 'blocks' ,
23+ blocks : [
24+ { type : 'divider' } ,
25+ { type : 'header' , text : { type : 'plain_text' , text : 'Hello' } } ,
26+ ] ,
27+ } ) ;
28+ // Unknown block types accepted via generic Block interface
29+ expectAssignable < BlocksChunk > ( {
30+ type : 'blocks' ,
31+ blocks : [ { type : 'future_block_type' } ] ,
32+ } ) ;
33+
34+ // BlocksChunk is assignable to AnyChunk
35+ expectAssignable < AnyChunk > ( { type : 'blocks' , blocks : [ ] } ) ;
You can’t perform that action at this time.
0 commit comments