Skip to content

Commit

Permalink
fix: remove GenericObject shim (#2177)
Browse files Browse the repository at this point in the history
This was declared in the local stubs file but not shipped, meaning that
consumers with typescript libchecking enabled would have to also add the
GenericObject definition to their local stubs file.

This commit inlines the definition where necessary, or replaces it with
object where appropriate.
  • Loading branch information
mrginglymus committed Sep 29, 2022
1 parent 168189b commit 127ef26
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 0 additions & 2 deletions custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@ declare var reactHotLoaderGlobal: any;
interface Element {
scrollIntoViewIfNeeded(centerIfNeeded?: boolean): void;
}

type GenericObject = Record<string, any>;
2 changes: 1 addition & 1 deletion src/components/DropdownOrLabel/DropdownOrLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StyledComponent } from 'styled-components';
import { DropdownProps, MimeLabel, SimpleDropdown } from '../../common-elements/Dropdown';

export interface DropdownOrLabelProps extends DropdownProps {
Label?: StyledComponent<any, any, GenericObject, never>;
Label?: StyledComponent<any, any, Record<string, any>, never>;
Dropdown?: StyledComponent<
React.NamedExoticComponent<DropdownProps>,
any,
Expand Down
4 changes: 2 additions & 2 deletions src/services/OpenAPIParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class OpenAPIParser {
}
}

validate(spec: GenericObject): void {
validate(spec: Record<string, any>): void {
if (spec.openapi === undefined) {
throw new Error('Document must be valid OpenAPI 3.0.0 definition');
}
Expand Down Expand Up @@ -153,7 +153,7 @@ export class OpenAPIParser {
} else {
// small optimization
return {
...(resolved as GenericObject),
...(resolved as object),
...rest,
} as T;
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function objectHas(object: GenericObject, path: string | Array<string>): boolean {
export function objectHas(object: object, path: string | Array<string>): boolean {
let _path = <Array<string>>path;

if (typeof path === 'string') {
Expand All @@ -12,7 +12,7 @@ export function objectHas(object: GenericObject, path: string | Array<string>):
});
}

export function objectSet(object: GenericObject, path: string | Array<string>, value: any): void {
export function objectSet(object: object, path: string | Array<string>, value: any): void {
let _path = <Array<string>>path;

if (typeof path === 'string') {
Expand Down

0 comments on commit 127ef26

Please sign in to comment.