From 921d23e73f0c6a86b0abd601128800b304be2379 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alexander.rose@weirdbyte.de> Date: Fri, 24 Jan 2020 18:13:20 -0800 Subject: [PATCH] add NonNullableArray type helper --- src/mol-util/type-helpers.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mol-util/type-helpers.ts b/src/mol-util/type-helpers.ts index 22e9b6ae5..85b68218d 100644 --- a/src/mol-util/type-helpers.ts +++ b/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 } \ No newline at end of file +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]>> -- GitLab