Browse Source

fix return type of State.tryGetCellData

Alexander Rose 1 year ago
parent
commit
78874c0024
2 changed files with 3 additions and 1 deletions
  1. 2 0
      CHANGELOG.md
  2. 1 1
      src/mol-state/state.ts

+ 2 - 0
CHANGELOG.md

@@ -6,6 +6,8 @@ Note that since we don't clearly distinguish between a public and private interf
 
 ## [Unreleased]
 
+- Fix return type of `State.tryGetCellData`
+
 ## [v3.42.0] - 2023-11-05
 
 - Fix handling of PDB files with insertion codes (#945)

+ 1 - 1
src/mol-state/state.ts

@@ -72,7 +72,7 @@ class State {
     tryGetCellData = <T extends StateObject>(ref: StateTransform.Ref) => {
         const ret = this.cells.get(ref)?.obj?.data;
         if (!ref) throw new Error(`Cell '${ref}' data undefined.`);
-        return ret as T;
+        return ret as T extends StateObject<infer D> ? D : never;
     };
 
     private historyCapacity = 5;