Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Value<D> and export getExportURL function type #1249

Merged
merged 2 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { DataProviderApi } from './providers/api';

export { default as App } from './App';

export { default as MockProvider } from './providers/mock/MockProvider';
Expand All @@ -7,6 +9,7 @@ export { default as H5GroveProvider } from './providers/h5grove/H5GroveProvider'
export { getFeedbackMailto } from './breadcrumbs/utils';
export type { FeedbackContext } from './breadcrumbs/models';
export type { ExportFormat, ExportURL } from './providers/models';
export type GetExportURL = NonNullable<DataProviderApi['getExportURL']>;
axelboc marked this conversation as resolved.
Show resolved Hide resolved

// Context
export { useDataContext } from './providers/DataProvider';
Expand Down
3 changes: 1 addition & 2 deletions packages/app/src/providers/hsds/hsds-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {
ChildEntity,
ProvidedEntity,
ArrayShape,
DType,
Value,
} from '@h5web/shared';
import { assertGroup } from '@h5web/shared';
Expand Down Expand Up @@ -152,7 +151,7 @@ export class HsdsApi extends DataProviderApi {
);
}

public getExportURL<D extends Dataset<ArrayShape, DType>>(
public getExportURL<D extends Dataset<ArrayShape>>(
axelboc marked this conversation as resolved.
Show resolved Hide resolved
format: ExportFormat,
dataset: D,
selection: string | undefined,
Expand Down
3 changes: 1 addition & 2 deletions packages/h5wasm/src/h5wasm-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type {
Attribute,
ChildEntity,
Dataset,
DType,
Entity,
Group,
ProvidedEntity,
Expand Down Expand Up @@ -95,7 +94,7 @@ export class H5WasmApi extends ProviderApi {
);
}

public getExportURL<D extends Dataset<ArrayShape, DType>>(
public getExportURL<D extends Dataset<ArrayShape>>(
format: ExportFormat,
dataset: D,
selection: string | undefined,
Expand Down
10 changes: 6 additions & 4 deletions packages/shared/src/models-hdf5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ export type ArrayValue<T extends DType> =
| Primitive<T>[]
| (T extends NumericType ? TypedArray : never);

export type Value<D extends Dataset> = D['shape'] extends ScalarShape
? Primitive<D['type']>
: D['shape'] extends ArrayShape
? ArrayValue<D['type']>
export type Value<D extends Dataset> = D extends Dataset<infer S, infer T>
? S extends ScalarShape
? Primitive<T>
: S extends ArrayShape
? ArrayValue<T>
: never
: never;

export type AttributeValues = Record<string, unknown>;
Expand Down