enhance globalComponentInstanceContextMap type safety (#13544)
Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
+6
-5
@@ -3,17 +3,18 @@ import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
class ComponentInstanceContextMap {
|
||||
constructor() {
|
||||
if (!isDefined((window as any).componentComponentStateContextMap)) {
|
||||
(window as any).componentComponentStateContextMap = new Map();
|
||||
if (!isDefined(window.componentComponentStateContextMap)) {
|
||||
window.componentComponentStateContextMap = new Map();
|
||||
}
|
||||
}
|
||||
|
||||
public get(key: string): ComponentInstanceStateContext<any> {
|
||||
return (window as any).componentComponentStateContextMap.get(key);
|
||||
public get(key: string): ComponentInstanceStateContext<any> | undefined {
|
||||
const context = window.componentComponentStateContextMap.get(key);
|
||||
return context;
|
||||
}
|
||||
|
||||
public set(key: string, context: ComponentInstanceStateContext<any>) {
|
||||
(window as any).componentComponentStateContextMap.set(key, context);
|
||||
window.componentComponentStateContextMap.set(key, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user