diff --git a/packages/dockview-core/src/dockview/options.ts b/packages/dockview-core/src/dockview/options.ts index f9d2cc1c5..e2aa50306 100644 --- a/packages/dockview-core/src/dockview/options.ts +++ b/packages/dockview-core/src/dockview/options.ts @@ -15,7 +15,10 @@ import { PanelTransfer } from '../dnd/dataTransfer'; import { IDisposable } from '../lifecycle'; import { Position } from '../dnd/droptarget'; import { IDockviewPanel } from './dockviewPanel'; -import { FrameworkFactory } from '../panel/componentFactory'; +import { + ComponentConstructor, + FrameworkFactory, +} from '../panel/componentFactory'; import { DockviewGroupPanelApi } from '../api/dockviewGroupPanelApi'; export interface IHeaderActionsRenderer extends IDisposable { @@ -40,14 +43,10 @@ export interface TabContextMenuEvent { export interface DockviewRenderFunctions { tabComponents?: { - [componentName: string]: { - new (id: string, component: string): ITabRenderer; - }; + [componentName: string]: ComponentConstructor; }; components?: { - [componentName: string]: { - new (id: string, component: string): IContentRenderer; - }; + [componentName: string]: ComponentConstructor; }; frameworkTabComponents?: { [componentName: string]: any; diff --git a/packages/dockview-core/src/gridview/options.ts b/packages/dockview-core/src/gridview/options.ts index 461ab6c66..3325befa4 100644 --- a/packages/dockview-core/src/gridview/options.ts +++ b/packages/dockview-core/src/gridview/options.ts @@ -1,14 +1,15 @@ import { GridviewPanel } from './gridviewPanel'; import { ISplitviewStyles, Orientation } from '../splitview/splitview'; -import { FrameworkFactory } from '../panel/componentFactory'; +import { + ComponentConstructor, + FrameworkFactory, +} from '../panel/componentFactory'; export interface GridviewComponentOptions { proportionalLayout: boolean; orientation: Orientation; components?: { - [componentName: string]: { - new (id: string, componentName: string): GridviewPanel; - }; + [componentName: string]: ComponentConstructor; }; frameworkComponents?: { [componentName: string]: any; diff --git a/packages/dockview-core/src/panel/componentFactory.ts b/packages/dockview-core/src/panel/componentFactory.ts index d88fb64ad..fb77f9944 100644 --- a/packages/dockview-core/src/panel/componentFactory.ts +++ b/packages/dockview-core/src/panel/componentFactory.ts @@ -2,11 +2,15 @@ export interface FrameworkFactory { createComponent: (id: string, componentId: string, component: any) => T; } +export type ComponentConstructor = { + new (id: string, component: string): T; +}; + export function createComponent( id: string, componentName?: string, components: { - [componentName: string]: { new (id: string, component: string): T }; + [componentName: string]: ComponentConstructor; } = {}, frameworkComponents: { [componentName: string]: any; diff --git a/packages/dockview-core/src/paneview/options.ts b/packages/dockview-core/src/paneview/options.ts index 00763e652..e4ff5d055 100644 --- a/packages/dockview-core/src/paneview/options.ts +++ b/packages/dockview-core/src/paneview/options.ts @@ -1,20 +1,19 @@ -import { FrameworkFactory } from '../panel/componentFactory'; +import { + ComponentConstructor, + FrameworkFactory, +} from '../panel/componentFactory'; import { PaneviewDndOverlayEvent } from './paneviewComponent'; import { IPaneBodyPart, IPaneHeaderPart, PaneviewPanel } from './paneviewPanel'; export interface PaneviewComponentOptions { components?: { - [componentName: string]: { - new (id: string, componentName: string): PaneviewPanel; - }; + [componentName: string]: ComponentConstructor; }; frameworkComponents?: { [componentName: string]: any; }; headerComponents?: { - [componentName: string]: { - new (id: string, componentName: string): PaneviewPanel; - }; + [componentName: string]: ComponentConstructor; }; headerframeworkComponents?: { [componentName: string]: any; diff --git a/packages/dockview-core/src/paneview/paneview.ts b/packages/dockview-core/src/paneview/paneview.ts index 65666bdb7..3bebc07f5 100644 --- a/packages/dockview-core/src/paneview/paneview.ts +++ b/packages/dockview-core/src/paneview/paneview.ts @@ -19,7 +19,7 @@ export class Paneview extends CompositeDisposable implements IDisposable { private splitview: Splitview; private paneItems: PaneItem[] = []; private _orientation: Orientation; - private animationTimer: any | undefined; + private animationTimer: any; private skipAnimation = false; private readonly _onDidChange = new Emitter(); diff --git a/packages/dockview-core/src/paneview/paneviewPanel.ts b/packages/dockview-core/src/paneview/paneviewPanel.ts index bfbda79c8..ba0f4a315 100644 --- a/packages/dockview-core/src/paneview/paneviewPanel.ts +++ b/packages/dockview-core/src/paneview/paneviewPanel.ts @@ -87,7 +87,7 @@ export abstract class PaneviewPanel private bodyPart?: IPaneHeaderPart; private headerPart?: IPaneBodyPart; private expandedSize = 0; - private animationTimer: any | undefined; + private animationTimer: any; private _orientation: Orientation; private _headerVisible: boolean; diff --git a/packages/dockview-core/src/splitview/options.ts b/packages/dockview-core/src/splitview/options.ts index 7f180cd0a..caa4ee0a4 100644 --- a/packages/dockview-core/src/splitview/options.ts +++ b/packages/dockview-core/src/splitview/options.ts @@ -2,7 +2,10 @@ import { IPanel, PanelInitParameters } from '../panel/types'; import { IView, SplitViewOptions, LayoutPriority } from './splitview'; import { SplitviewPanel } from './splitviewPanel'; import { SplitviewComponent } from './splitviewComponent'; -import { FrameworkFactory } from '../panel/componentFactory'; +import { + ComponentConstructor, + FrameworkFactory, +} from '../panel/componentFactory'; export interface PanelViewInitParameters extends PanelInitParameters { minimumSize?: number; @@ -18,9 +21,7 @@ export interface ISerializableView extends IView, IPanel { export interface SplitviewComponentOptions extends SplitViewOptions { components?: { - [componentName: string]: { - new (id: string, componentName: string): SplitviewPanel; - }; + [componentName: string]: ComponentConstructor; }; frameworkComponents?: { [componentName: string]: any; diff --git a/packages/dockview-core/src/splitview/splitviewComponent.ts b/packages/dockview-core/src/splitview/splitviewComponent.ts index 824cfa0a4..b38971cb4 100644 --- a/packages/dockview-core/src/splitview/splitviewComponent.ts +++ b/packages/dockview-core/src/splitview/splitviewComponent.ts @@ -274,7 +274,7 @@ export class SplitviewComponent view.orientation = this.splitview.orientation; view.init({ - params: options.params || {}, + params: options.params ?? {}, minimumSize: options.minimumSize, maximumSize: options.maximumSize, snap: options.snap, diff --git a/packages/dockview/src/react.ts b/packages/dockview/src/react.ts index 59299f22e..378112165 100644 --- a/packages/dockview/src/react.ts +++ b/packages/dockview/src/react.ts @@ -194,7 +194,7 @@ export const usePortalsLifecycle: PortalLifecycleHook = () => { // it does the job... export function isReactElement( - element: any | React.ReactElement + element: unknown ): element is React.ReactElement { - return element?.type; + return !!(element as React.ReactElement)?.type; }