Browse Source

add NonNullableArray type helper

Alexander Rose 5 years ago
parent
commit
921d23e73f
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/mol-util/type-helpers.ts

+ 4 - 2
src/mol-util/type-helpers.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  * @author David Sehnal <david.sehnal@gmail.com>
@@ -17,4 +17,6 @@ export type UintArray = Uint8Array | Uint16Array | Uint32Array | number[]
 export type ValueOf<T> = T[keyof T]
 export type ArrayCtor<T> = { new(size: number): { [i: number]: T, length: number } }
 /** assignable ArrayLike version */
-export type AssignableArrayLike<T> =  { [i: number]: T, length: number }
+export type AssignableArrayLike<T> =  { [i: number]: T, length: number }
+
+export type NonNullableArray<T extends any[] | ReadonlyArray<any>> = T extends any[] ? NonNullable<T[0]>[] : ReadonlyArray<NonNullable<T[0]>>