Browse Source

improve Representation typing

Alexander Rose 2 years ago
parent
commit
f84b5b633d
1 changed files with 4 additions and 4 deletions
  1. 4 4
      src/mol-repr/representation.ts

+ 4 - 4
src/mol-repr/representation.ts

@@ -140,7 +140,7 @@ export class RepresentationRegistry<D, S extends Representation.State> {
 //
 
 export { Representation };
-interface Representation<D, P extends PD.Params = {}, S extends Representation.State = Representation.State> {
+interface Representation<D, P extends PD.Params = PD.Params, S extends Representation.State = Representation.State> {
     readonly label: string
     readonly updated: Subject<number>
     /** Number of addressable groups in all visuals of the representation */
@@ -236,7 +236,7 @@ namespace Representation {
     }
     export const StateBuilder: StateBuilder<State> = { create: createState, update: updateState };
 
-    export type Any = Representation<any, any, any>
+    export type Any<P extends PD.Params = PD.Params, S extends State = State> = Representation<any, P, S>
     export const Empty: Any = {
         label: '', groupCount: 0, renderObjects: [], geometryVersion: -1, props: {}, params: {}, updated: new Subject(), state: createState(), theme: Theme.createEmpty(),
         createOrUpdate: () => Task.constant('', undefined),
@@ -248,7 +248,7 @@ namespace Representation {
         destroy: () => {}
     };
 
-    export type Def<D, P extends PD.Params = {}, S extends State = State> = { [k: string]: RepresentationFactory<D, P, S> }
+    export type Def<D, P extends PD.Params = PD.Params, S extends State = State> = { [k: string]: RepresentationFactory<D, P, S> }
 
     export class GeometryState {
         private curr = new Set<number>();
@@ -272,7 +272,7 @@ namespace Representation {
         }
     }
 
-    export function createMulti<D, P extends PD.Params = {}, S extends State = State>(label: string, ctx: RepresentationContext, getParams: RepresentationParamsGetter<D, P>, stateBuilder: StateBuilder<S>, reprDefs: Def<D, P>): Representation<D, P, S> {
+    export function createMulti<D, P extends PD.Params = PD.Params, S extends State = State>(label: string, ctx: RepresentationContext, getParams: RepresentationParamsGetter<D, P>, stateBuilder: StateBuilder<S>, reprDefs: Def<D, P>): Representation<D, P, S> {
         let version = 0;
         const updated = new Subject<number>();
         const geometryState = new GeometryState();