Skip to content

Commit

Permalink
Merge pull request #1249 from silx-kit/fix-value-type
Browse files Browse the repository at this point in the history
Fix `Value<D>` and export `getExportURL` function type
  • Loading branch information
axelboc authored Nov 2, 2022
2 parents d582960 + 36df934 commit ff35ff7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
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']>;

// 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>>(
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

0 comments on commit ff35ff7

Please sign in to comment.