Skip to content

Commit 01e8df2

Browse files
committed
fix(docs): drop the any cast and only follow plain subBlocks spreads in the catalog generator
1 parent 0a51c0d commit 01e8df2

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎scripts/check-explicit-any.baseline.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@
10991099
"scripts/check-fork-dependent-coverage.ts": 2,
11001100
"scripts/check-import-specifiers.ts": 1,
11011101
"scripts/create-single-release.ts": 2,
1102-
"scripts/generate-docs.ts": 41,
1102+
"scripts/generate-docs.ts": 40,
11031103
"scripts/generate-v2-cli-api.ts": 3
11041104
},
11051105
"nonNullAssertion": {

‎scripts/generate-docs.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,14 +2238,16 @@ function extractSpreadBase(blockContent: string): string | null {
22382238
/**
22392239
* Operations a block inherits by spreading a same-file block's fields array
22402240
* (`subBlocks: [...NotionBlock.subBlocks, ...]`) rather than the whole config.
2241+
* Only a plain spread counts: a transformed one (`...XBlock.subBlocks.map(...)`) may rewrite the
2242+
* operations, so it falls through to the block's own `tools.access`.
22412243
*/
22422244
function extractSpreadSubBlocksOperations(
22432245
blockContent: string,
22442246
fileContent: string | undefined
22452247
): { label: string; id: string }[] {
22462248
if (!fileContent) return []
22472249
const declarations = blockDeclarations(fileContent)
2248-
for (const match of blockContent.matchAll(/\.\.\.(\w+Block)\.subBlocks\b/g)) {
2250+
for (const match of blockContent.matchAll(/\.\.\.(\w+Block)\.subBlocks\s*[,\]]/g)) {
22492251
const declaration = declarations.find((candidate) => candidate.name === match[1])
22502252
const operations = declaration ? extractOperationsFromContent(declaration.content) : []
22512253
if (operations.length > 0) return operations
@@ -2354,7 +2356,7 @@ function extractBlockConfigFromContent(
23542356
}
23552357

23562358
const ownOperations = extractOperationsFromContent(blockContent)
2357-
const baseOperations: { label: string; id: string }[] = (baseConfig as any)?.operations ?? []
2359+
const baseOperations = baseConfig?.operations ?? []
23582360
const operations =
23592361
ownOperations.length > 0
23602362
? ownOperations

0 commit comments

Comments
 (0)