chore: remove global Dict<T> and replace it with Record<string, T>

This commit is contained in:
Roman Hotsiy 2020-05-25 16:37:38 +03:00
parent 9dd129d90b
commit c69f6de4c9
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
12 changed files with 24 additions and 24 deletions

View File

@ -26,7 +26,7 @@ export interface ParametersProps {
const PARAM_PLACES = ['path', 'query', 'cookie', 'header'];
export class Parameters extends React.PureComponent<ParametersProps> {
orderParams(params: FieldModel[]): Dict<FieldModel[]> {
orderParams(params: FieldModel[]): Record<string, FieldModel[]> {
const res = {};
params.forEach(param => {
safePush(res, param.in, param);

View File

@ -30,7 +30,7 @@ export type ExtendedOpenAPIOperation = {
pathServers: Array<OpenAPIServer> | undefined;
} & OpenAPIOperation;
export type TagsInfoMap = Dict<TagInfo>;
export type TagsInfoMap = Record<string, TagInfo>;
export interface TagGroup {
name: string;

View File

@ -298,8 +298,8 @@ export class OpenAPIParser {
* returns map of definition pointer to definition name
* @param $refs array of references to find derived from
*/
findDerived($refs: string[]): Dict<string[] | string> {
const res: Dict<string[]> = {};
findDerived($refs: string[]): Record<string, string[] | string> {
const res: Record<string, string[]> = {};
const schemas = (this.spec.components && this.spec.components.schemas) || {};
for (const defName in schemas) {
const def = this.deref(schemas[defName]);

View File

@ -30,7 +30,7 @@ export interface RedocRawOptions {
unstable_ignoreMimeParameters?: boolean;
allowedMdComponents?: Dict<MDXComponentMeta>;
allowedMdComponents?: Record<string, MDXComponentMeta>;
labels?: LabelsConfigRaw;
@ -172,7 +172,7 @@ export class RedocNormalizedOptions {
/* tslint:disable-next-line */
unstable_ignoreMimeParameters: boolean;
allowedMdComponents: Dict<MDXComponentMeta>;
allowedMdComponents: Record<string, MDXComponentMeta>;
expandDefaultServerVariables: boolean;

View File

@ -40,7 +40,7 @@ export class FieldModel {
deprecated: boolean;
in?: OpenAPIParameterLocation;
kind: string;
extensions?: Dict<any>;
extensions?: Record<string, any>;
explode: boolean;
style?: OpenAPIParameterStyle;

View File

@ -22,7 +22,7 @@ export class MediaContentModel {
*/
constructor(
parser: OpenAPIParser,
info: Dict<OpenAPIMediaType>,
info: Record<string, OpenAPIMediaType>,
public isRequestType: boolean,
options: RedocNormalizedOptions,
) {

View File

@ -73,7 +73,7 @@ export class OperationModel implements IMenuItem {
path: string;
servers: OpenAPIServer[];
security: SecurityRequirementModel[];
extensions: Dict<any>;
extensions: Record<string, any>;
isCallback: boolean;
constructor(

View File

@ -59,7 +59,7 @@ export class SchemaModel {
rawSchema: OpenAPISchema;
schema: MergedOpenAPISchema;
extensions?: Dict<any>;
extensions?: Record<string, any>;
/**
* @param isChild if schema discriminator Child

View File

@ -1,8 +1,3 @@
export * from './open-api';
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
declare global {
type Dict<T> = {
[key: string]: T;
};
}

View File

@ -226,22 +226,22 @@ export interface OpenAPISecurityScheme {
flows: {
implicit?: {
refreshUrl?: string;
scopes: Dict<string>;
scopes: Record<string, string>;
authorizationUrl: string;
};
password?: {
refreshUrl?: string;
scopes: Dict<string>;
scopes: Record<string, string>;
tokenUrl: string;
};
clientCredentials?: {
refreshUrl?: string;
scopes: Dict<string>;
scopes: Record<string, string>;
tokenUrl: string;
};
authorizationCode?: {
refreshUrl?: string;
scopes: Dict<string>;
scopes: Record<string, string>;
tokenUrl: string;
};
};

View File

@ -24,9 +24,9 @@ export function mapWithLast<T, P>(array: T[], iteratee: (item: T, isLast: boolea
* @param iteratee the function invoked per iteration.
*/
export function mapValues<T, P>(
object: Dict<T>,
iteratee: (val: T, key: string, obj: Dict<T>) => P,
): Dict<P> {
object: Record<string, T>,
iteratee: (val: T, key: string, obj: Record<string, T>) => P,
): Record<string, P> {
const res: { [key: string]: P } = {};
for (const key in object) {
if (object.hasOwnProperty(key)) {

View File

@ -492,7 +492,9 @@ export function mergeParams(
return pathParams.concat(operationParams);
}
export function mergeSimilarMediaTypes(types: Dict<OpenAPIMediaType>): Dict<OpenAPIMediaType> {
export function mergeSimilarMediaTypes(
types: Record<string, OpenAPIMediaType>,
): Record<string, OpenAPIMediaType> {
const mergedTypes = {};
Object.keys(types).forEach(name => {
const mime = types[name];
@ -586,7 +588,10 @@ export function isRedocExtension(key: string): boolean {
return key in redocExtensions;
}
export function extractExtensions(obj: object, showExtensions: string[] | true): Dict<any> {
export function extractExtensions(
obj: object,
showExtensions: string[] | true,
): Record<string, any> {
return Object.keys(obj)
.filter(key => {
if (showExtensions === true) {