diff --git a/src/mol-plugin-state/builder/structure/representation.ts b/src/mol-plugin-state/builder/structure/representation.ts index fc2b05c029131622f3093d7c8de70b87e341cd2e..4bcbb686140f517c5cceda8f53f63ed0d14c5e6f 100644 --- a/src/mol-plugin-state/builder/structure/representation.ts +++ b/src/mol-plugin-state/builder/structure/representation.ts @@ -90,7 +90,7 @@ export class StructureRepresentationBuilder { } applyPreset<K extends keyof PresetStructureRepresentations>(parent: StateObjectRef<PluginStateObject.Molecule.Structure>, preset: K, params?: StructureRepresentationPresetProvider.Params<PresetStructureRepresentations[K]>): Promise<StructureRepresentationPresetProvider.State<PresetStructureRepresentations[K]>> | undefined - applyPreset<P = any, S = {}>(parent: StateObjectRef<PluginStateObject.Molecule.Structure>, provider: StructureRepresentationPresetProvider<P, S>, params?: P): Promise<S> | undefined + applyPreset<P = any, S extends {} = {}>(parent: StateObjectRef<PluginStateObject.Molecule.Structure>, provider: StructureRepresentationPresetProvider<P, S>, params?: P): Promise<S> | undefined applyPreset(parent: StateObjectRef<PluginStateObject.Molecule.Structure>, providerId: string, params?: any): Promise<any> | undefined applyPreset(parent: StateObjectRef, providerRef: string | StructureRepresentationPresetProvider, params?: any): Promise<any> | undefined { const provider = this.resolveProvider(providerRef); diff --git a/src/mol-plugin-state/component.ts b/src/mol-plugin-state/component.ts index 8230b7f222e48a85b0b350bed83cd11db8ebb759..46b7c35077efc787d5bc7a96b507a10d7ffe0a09 100644 --- a/src/mol-plugin-state/component.ts +++ b/src/mol-plugin-state/component.ts @@ -42,7 +42,7 @@ export class PluginComponent { } } -export class StatefulPluginComponent<State> extends PluginComponent { +export class StatefulPluginComponent<State extends {}> extends PluginComponent { private _state: State; protected updateState(...states: Partial<State>[]): boolean { diff --git a/src/mol-plugin-state/formats/trajectory.ts b/src/mol-plugin-state/formats/trajectory.ts index c8eca7e90416533fce2aa6c0605d0016c2521c61..82eef87085d9389dc63800c0427822f8505b1b7a 100644 --- a/src/mol-plugin-state/formats/trajectory.ts +++ b/src/mol-plugin-state/formats/trajectory.ts @@ -75,7 +75,7 @@ export const CifCoreProvider: TrajectoryFormatProvider = { visuals: defaultVisuals }; -function directTrajectory<P>(transformer: StateTransformer<PluginStateObject.Data.String | PluginStateObject.Data.Binary, PluginStateObject.Molecule.Trajectory, P>, transformerParams?: P): TrajectoryFormatProvider['parse'] { +function directTrajectory<P extends {}>(transformer: StateTransformer<PluginStateObject.Data.String | PluginStateObject.Data.Binary, PluginStateObject.Molecule.Trajectory, P>, transformerParams?: P): TrajectoryFormatProvider['parse'] { return async (plugin, data, params) => { const state = plugin.state.data; const trajectory = await state.build().to(data) diff --git a/src/mol-plugin-ui/base.tsx b/src/mol-plugin-ui/base.tsx index 6311d351b19aefa6ff5a5e0ef6dd92a10a71c396..6d724fa66726db3ba8141f1e548e1bd217ec85be 100644 --- a/src/mol-plugin-ui/base.tsx +++ b/src/mol-plugin-ui/base.tsx @@ -13,7 +13,7 @@ import { Icon, ArrowRightSvg, ArrowDropDownSvg } from './controls/icons'; export const PluginReactContext = React.createContext(void 0 as any as PluginUIContext); -export abstract class PluginUIComponent<P = {}, S = {}, SS = {}> extends React.Component<P & { children?: any }, S, SS> { +export abstract class PluginUIComponent<P extends {} = {}, S = {}, SS = {}> extends React.Component<P & { children?: any }, S, SS> { static contextType = PluginReactContext; readonly plugin: PluginUIContext; diff --git a/src/mol-plugin/behavior/behavior.ts b/src/mol-plugin/behavior/behavior.ts index ddbb603c351f26f63978ca998ea3d5a5bab7475b..96ada468ba35d0960ae2481f20545c2884ab229d 100644 --- a/src/mol-plugin/behavior/behavior.ts +++ b/src/mol-plugin/behavior/behavior.ts @@ -40,7 +40,7 @@ namespace PluginBehavior { 'misc': 'Miscellaneous' }; - export interface CreateParams<P> { + export interface CreateParams<P extends {}> { name: string, category: keyof typeof Categories, ctor: Ctor<P>, @@ -73,7 +73,7 @@ namespace PluginBehavior { return categoryMap.get(t.id)!; } - export function create<P>(params: CreateParams<P>) { + export function create<P extends {}>(params: CreateParams<P>) { const t = PluginStateTransform.CreateBuiltIn<Category, Behavior, P>({ name: params.name, display: params.display, @@ -113,7 +113,7 @@ namespace PluginBehavior { }; } - export abstract class Handler<P = { }> implements PluginBehavior<P> { + export abstract class Handler<P extends {} = {}> implements PluginBehavior<P> { private subs: PluginCommand.Subscription[] = []; protected subscribeCommand<T>(cmd: PluginCommand<T>, action: PluginCommand.Action<T>) { this.subs.push(cmd.subscribe(this.ctx, action)); diff --git a/src/mol-state/action.ts b/src/mol-state/action.ts index b6416e63f626fa7fd0ebea77692c99c55cd345cf..864a8cb9535468705a5b03ac099e2aa2c443a629 100644 --- a/src/mol-state/action.ts +++ b/src/mol-state/action.ts @@ -84,7 +84,7 @@ namespace StateAction { } export namespace Builder { - export interface Type<A extends StateObject.Ctor, P extends { }> { + export interface Type<A extends StateObject.Ctor, P extends {}> { from?: A | A[], params?: PD.For<P> | ((a: StateObject.From<A>, globalCtx: any) => PD.For<P>), display?: string | { name: string, description?: string }, @@ -95,7 +95,7 @@ namespace StateAction { <A extends StateObject.Ctor, P extends { }>(info: Type<A, P>): Define<StateObject.From<A>, PD.Normalize<P>> } - export interface Define<A extends StateObject, P> { + export interface Define<A extends StateObject, P extends {}> { <T>(def: DefinitionBase<A, T, P> | DefinitionBase<A, T, P>['run']): StateAction<A, T, P>, } diff --git a/src/mol-state/transformer.ts b/src/mol-state/transformer.ts index 0656babb8f3a526776075368a9ca22d45b6b2b41..94905d9af53e6b852a40a47dbe9e46606eb7fd69 100644 --- a/src/mol-state/transformer.ts +++ b/src/mol-state/transformer.ts @@ -196,7 +196,7 @@ namespace Transformer { } export namespace Builder { - export interface Type<A extends StateObject.Ctor, B extends StateObject.Ctor, P extends { }> { + export interface Type<A extends StateObject.Ctor, B extends StateObject.Ctor, P extends {}> { name: string, from: A | A[], to: B | B[], @@ -210,7 +210,7 @@ namespace Transformer { <A extends StateObject.Ctor, B extends StateObject.Ctor, P extends { }>(info: Type<A, B, P>): Define<StateObject.From<A>, StateObject.From<B>, PD.Normalize<P>> } - export interface Define<A extends StateObject, B extends StateObject, P> { + export interface Define<A extends StateObject, B extends StateObject, P extends {}> { (def: DefinitionBase<A, B, P>): Transformer<A, B, P> } diff --git a/src/mol-util/index.ts b/src/mol-util/index.ts index 4db05201cd2b0631b5534f3be008456b440a42bf..ba4d557c3552354033770c9b3fe0cebe29fc33fa 100644 --- a/src/mol-util/index.ts +++ b/src/mol-util/index.ts @@ -117,7 +117,7 @@ export function defaults<T>(value: T | undefined, defaultValue: T): T { return value !== undefined ? value : defaultValue; } -export function extend<S, T, U>(object: S, source: T, guard?: U): S & T & U { +export function extend<S extends {}, T extends {}, U extends {}>(object: S, source: T, guard?: U): S & T & U { let v: any; const s = <any>source; @@ -139,7 +139,7 @@ export function extend<S, T, U>(object: S, source: T, guard?: U): S & T & U { return <any>object; } -export function shallowClone<T>(o: T): T { +export function shallowClone<T extends {}>(o: T): T { return extend({}, o) as T; } @@ -158,7 +158,7 @@ function _assign<T>(target: T): T { export declare function _assignType<T>(o: T, ...from: any[]): T; export const assign: (<T>(o: T, ...from: any[]) => T) = (Object as any).assign || _assign; -function _shallowMerge1<T>(source: T, update: T) { +function _shallowMerge1<T extends {}>(source: T, update: T) { let changed = false; for (const k of Object.keys(update)) { if (!hasOwnProperty.call(update, k)) continue; diff --git a/src/mol-util/object.ts b/src/mol-util/object.ts index d11c4bb9ef85675352f05aca5cdef5c26579021e..1cdbe8e9ec666d80b93bfb8279d582aeac819e63 100644 --- a/src/mol-util/object.ts +++ b/src/mol-util/object.ts @@ -8,7 +8,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty; /** Assign to the object if a given property in update is undefined */ -export function assignIfUndefined<T>(to: Partial<T>, full: T): T { +export function assignIfUndefined<T extends {}>(to: Partial<T>, full: T): T { for (const k of Object.keys(full)) { if (!hasOwnProperty.call(full, k)) continue; @@ -20,7 +20,7 @@ export function assignIfUndefined<T>(to: Partial<T>, full: T): T { } /** Create new object if any property in "update" changes in "source". */ -export function shallowMerge2<T>(source: T, update: Partial<T>): T { +export function shallowMerge2<T extends {}>(source: T, update: Partial<T>): T { // Adapted from LiteMol (https://github.com/dsehnal/LiteMol) let changed = false; for (const k of Object.keys(update)) { @@ -36,7 +36,7 @@ export function shallowMerge2<T>(source: T, update: Partial<T>): T { return Object.assign({}, source, update); } -export function shallowEqual<T>(a: T, b: T) { +export function shallowEqual<T extends {}>(a: T, b: T) { if (!a) { if (!b) return true; return false; @@ -52,11 +52,11 @@ export function shallowEqual<T>(a: T, b: T) { return true; } -export function shallowMerge<T>(source: T, ...rest: (Partial<T> | undefined)[]): T { +export function shallowMerge<T extends {}>(source: T, ...rest: (Partial<T> | undefined)[]): T { return shallowMergeArray(source, rest); } -export function shallowMergeArray<T>(source: T, rest: (Partial<T> | undefined)[]): T { +export function shallowMergeArray<T extends {}>(source: T, rest: (Partial<T> | undefined)[]): T { // Adapted from LiteMol (https://github.com/dsehnal/LiteMol) let ret: any = source; diff --git a/src/mol-util/param-definition.ts b/src/mol-util/param-definition.ts index 46840b54a6c17dcb13907257c6c9d726bb813594..a9697f5f454d63753f657bba63ff2ab32771eb3c 100644 --- a/src/mol-util/param-definition.ts +++ b/src/mol-util/param-definition.ts @@ -324,7 +324,7 @@ export namespace ParamDefinition { conditionForValue(v: T): keyof C conditionedValue(v: T, condition: keyof C): T, } - export function Conditioned<T, P extends Base<T>, C = { [k: string]: P }>(defaultValue: T, conditionParams: C, conditionForValue: (v: T) => keyof C, conditionedValue: (v: T, condition: keyof C) => T, info?: Info): Conditioned<T, P, C> { + export function Conditioned<T, P extends Base<T>, C extends {} = { [k: string]: P }>(defaultValue: T, conditionParams: C, conditionForValue: (v: T) => keyof C, conditionedValue: (v: T, condition: keyof C) => T, info?: Info): Conditioned<T, P, C> { const options = Object.keys(conditionParams).map(k => [k, k]) as [string, string][]; return setInfo({ type: 'conditioned', select: Select<string>(conditionForValue(defaultValue) as string, options, info), defaultValue, conditionParams, conditionForValue, conditionedValue }, info); }