@@ -13,6 +13,7 @@ import {
1313 ensure ,
1414 ensureArray ,
1515 ensureJsonMap ,
16+ ensureObject ,
1617 ensureString ,
1718 isArray ,
1819 JsonMap ,
@@ -38,10 +39,10 @@ function emitNoTopicMetadataWarning(topic: string): void {
3839export class Docs {
3940 public constructor (
4041 private outputDir : string ,
41- private plugins : JsonMap ,
42+ private plugins : Record < string , unknown > ,
4243 private hidden : boolean ,
43- private topicMeta : JsonMap ,
44- private cliMeta : JsonMap
44+ private topicMeta : Record < string , unknown > ,
45+ private cliMeta : Record < string , unknown >
4546 ) { }
4647
4748 public async build ( commands : CommandClass [ ] ) : Promise < void > {
@@ -164,8 +165,8 @@ export class Docs {
164165 const subtopic = commandParts [ 1 ] ;
165166
166167 try {
167- const topicMeta = ensureJsonMap ( this . topicMeta [ topLevelTopic ] ) ;
168- const subTopicsMeta = ensureJsonMap ( topicMeta . subtopics ) ;
168+ const topicMeta = ensureObject < Record < string , unknown > > ( this . topicMeta [ topLevelTopic ] ) ;
169+ const subTopicsMeta = ensureObject < Record < string , unknown > > ( topicMeta . subtopics ) ;
169170 if ( subTopicsMeta . hidden && ! this . hidden ) {
170171 continue ;
171172 }
@@ -210,19 +211,23 @@ export class Docs {
210211 }
211212 }
212213
213- private resolveCommandMeta ( commandId : string , command : CommandClass , commandsInTopic : number ) : JsonMap {
214+ private resolveCommandMeta (
215+ commandId : string ,
216+ command : CommandClass ,
217+ commandsInTopic : number
218+ ) : Record < string , unknown > {
214219 const commandMeta = Object . assign ( { } , this . cliMeta ) ;
215220 // Remove top level topic, since the topic meta is already for that topic
216221 const commandParts = commandId . split ( ':' ) ;
217222 let part ;
218223 try {
219- let currentMeta : JsonMap | undefined ;
224+ let currentMeta : Record < string , unknown > | undefined ;
220225 for ( part of commandParts ) {
221226 if ( currentMeta ) {
222- const subtopics = ensureJsonMap ( currentMeta . subtopics ) ;
223- currentMeta = ensureJsonMap ( subtopics [ part ] ) ;
227+ const subtopics = ensureObject < Record < string , unknown > > ( currentMeta . subtopics ) ;
228+ currentMeta = ensureObject < Record < string , unknown > > ( subtopics [ part ] ) ;
224229 } else {
225- currentMeta = ensureJsonMap ( this . topicMeta [ part ] ) ;
230+ currentMeta = ensureObject < Record < string , unknown > > ( this . topicMeta [ part ] ) ;
226231 }
227232
228233 // Collect all tiers of the meta, so the command will also pick up the topic state (isPilot, etc) if applicable
@@ -249,7 +254,7 @@ export class Docs {
249254 topic : string ,
250255 subtopic : string | null ,
251256 command : CommandClass ,
252- commandMeta : JsonMap
257+ commandMeta : Record < string , unknown >
253258 ) : Promise < string > {
254259 // If it is a hidden command - abort
255260 if ( command . hidden && ! this . hidden ) {
0 commit comments