Skip to content

Commit d3a482d

Browse files
committed
Define IApiNameMap<T> to eliminate a bunch of type literals
1 parent 70b191a commit d3a482d

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

‎libraries/api-extractor/src/api/ApiItem.ts‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ export interface IApiParameter {
7676
type: string;
7777
}
7878

79+
/**
80+
* An ordered map of items, indexed by the symbol name.
81+
* @alpha
82+
*/
83+
export interface IApiNameMap<T> {
84+
/**
85+
* For a given name, returns the object with that name.
86+
*/
87+
[name: string]: T;
88+
}
89+
7990
/**
8091
* Return value of a method or function.
8192
* @alpha
@@ -175,7 +186,7 @@ export interface IApiMethod extends IApiBaseDefinition {
175186
* a mapping of parameter name to IApiParameter
176187
*/
177188

178-
parameters: { [name: string]: IApiParameter};
189+
parameters: IApiNameMap<IApiParameter>;
179190

180191
/**
181192
* describes the return value of the method
@@ -195,7 +206,7 @@ export interface IApiFunction extends IApiBaseDefinition {
195206
/**
196207
* parameters of the function
197208
*/
198-
parameters: { [name: string]: IApiParameter};
209+
parameters: IApiNameMap<IApiParameter>;
199210

200211
/**
201212
* a description of the return value
@@ -215,7 +226,7 @@ export interface IApiConstructor extends IApiBaseDefinition {
215226
/**
216227
* parameters of the function
217228
*/
218-
parameters: { [name: string]: IApiParameter};
229+
parameters: IApiNameMap<IApiParameter>;
219230
}
220231

221232
/**
@@ -230,7 +241,7 @@ export interface IApiClass extends IApiBaseDefinition {
230241
/**
231242
* Can be a combination of methods and/or properties
232243
*/
233-
members: { [name: string]: ApiMember};
244+
members: IApiNameMap<ApiMember>;
234245

235246
/**
236247
* Interfaces implemented by this class
@@ -287,7 +298,7 @@ export interface IApiInterface extends IApiBaseDefinition {
287298
/**
288299
* A mapping from the name of a member API to its ApiMember
289300
*/
290-
members: { [name: string]: ApiMember};
301+
members: IApiNameMap<ApiMember>;
291302

292303
/**
293304
* Interfaces implemented by this interface
@@ -327,7 +338,7 @@ export interface IApiPackage {
327338
/**
328339
* IDocItems of exported API items
329340
*/
330-
exports: { [name: string]: ApiItem};
341+
exports: IApiNameMap<ApiItem>;
331342

332343
/**
333344
* The following are needed so that this interface and can share

0 commit comments

Comments
 (0)