Skip to content

Commit 17e06e9

Browse files
committed
Fix typing errors
1 parent 9ba09d8 commit 17e06e9

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/components/Space.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,22 @@ export class Space extends React.Component<IReactSpaceInnerProps> {
3030
}
3131
}
3232

33+
const PROP_REACT_SPACES_UNIQUEID = "_react_spaces_uniqueid";
34+
type SPACE_INDEXABLE = Record<string, string>;
35+
const getSpaceUniqueId = (space: Space) => ((space as unknown) as SPACE_INDEXABLE)[PROP_REACT_SPACES_UNIQUEID];
36+
const setSpaceUniqueId = (space: Space, uuid: string) => {
37+
((space as unknown) as SPACE_INDEXABLE)[PROP_REACT_SPACES_UNIQUEID] = uuid;
38+
};
39+
3340
const SpaceInner: React.FC<IReactSpaceInnerProps & { wrapperInstance: Space }> = (props) => {
34-
let idToUse = props.id ?? props.wrapperInstance["_react_spaces_uniqueid"];
41+
let idToUse = props.id ?? getSpaceUniqueId(props.wrapperInstance);
3542
const [initialRender, setInitialRender] = React.useState(SSR_SUPPORT_ENABLED ? true : false);
3643

3744
const uniqueId = useUniqueId();
3845

3946
if (!idToUse) {
40-
props.wrapperInstance["_react_spaces_uniqueid"] = uniqueId;
41-
idToUse = props.wrapperInstance["_react_spaces_uniqueid"];
47+
setSpaceUniqueId(props.wrapperInstance, uniqueId);
48+
idToUse = getSpaceUniqueId(props.wrapperInstance);
4249
}
4350

4451
const {

src/core-utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { ISpaceDefinition, SizeUnit, ISize, ResizeHandlePlacement, Type, Orientation } from "./core-types";
22

3+
const asRecord = (obj: any) => (obj as unknown) as Record<string, object>;
4+
35
export function omit<K extends string, T extends Record<K, unknown>>(object: T, ...keys: K[]): Omit<T, K> {
46
const keySet = Object.create(null) as Record<K, true>;
57
keys.forEach((key) => {
@@ -8,8 +10,8 @@ export function omit<K extends string, T extends Record<K, unknown>>(object: T,
810

911
const result = Object.create(null) as Omit<T, K>;
1012
Object.keys(object).forEach((key) => {
11-
if (!keySet[key]) {
12-
result[key] = object[key];
13+
if (!asRecord(keySet)[key]) {
14+
asRecord(result)[key] = asRecord(object)[key];
1315
}
1416
});
1517

0 commit comments

Comments
 (0)