Skip to content

Commit

Permalink
Fix typing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aeagle committed Mar 31, 2024
1 parent 9ba09d8 commit 17e06e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/components/Space.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,22 @@ export class Space extends React.Component<IReactSpaceInnerProps> {
}
}

const PROP_REACT_SPACES_UNIQUEID = "_react_spaces_uniqueid";
type SPACE_INDEXABLE = Record<string, string>;
const getSpaceUniqueId = (space: Space) => ((space as unknown) as SPACE_INDEXABLE)[PROP_REACT_SPACES_UNIQUEID];
const setSpaceUniqueId = (space: Space, uuid: string) => {
((space as unknown) as SPACE_INDEXABLE)[PROP_REACT_SPACES_UNIQUEID] = uuid;
};

const SpaceInner: React.FC<IReactSpaceInnerProps & { wrapperInstance: Space }> = (props) => {
let idToUse = props.id ?? props.wrapperInstance["_react_spaces_uniqueid"];
let idToUse = props.id ?? getSpaceUniqueId(props.wrapperInstance);
const [initialRender, setInitialRender] = React.useState(SSR_SUPPORT_ENABLED ? true : false);

const uniqueId = useUniqueId();

if (!idToUse) {
props.wrapperInstance["_react_spaces_uniqueid"] = uniqueId;
idToUse = props.wrapperInstance["_react_spaces_uniqueid"];
setSpaceUniqueId(props.wrapperInstance, uniqueId);
idToUse = getSpaceUniqueId(props.wrapperInstance);
}

const {
Expand Down
6 changes: 4 additions & 2 deletions src/core-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ISpaceDefinition, SizeUnit, ISize, ResizeHandlePlacement, Type, Orientation } from "./core-types";

const asRecord = (obj: any) => (obj as unknown) as Record<string, object>;

export function omit<K extends string, T extends Record<K, unknown>>(object: T, ...keys: K[]): Omit<T, K> {
const keySet = Object.create(null) as Record<K, true>;
keys.forEach((key) => {
Expand All @@ -8,8 +10,8 @@ export function omit<K extends string, T extends Record<K, unknown>>(object: T,

const result = Object.create(null) as Omit<T, K>;
Object.keys(object).forEach((key) => {
if (!keySet[key]) {
result[key] = object[key];
if (!asRecord(keySet)[key]) {
asRecord(result)[key] = asRecord(object)[key];
}
});

Expand Down

0 comments on commit 17e06e9

Please sign in to comment.