-
Notifications
You must be signed in to change notification settings - Fork 46
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 type/docs for VivView(er) and Consumers. #407
Conversation
7703fcf
to
ae7e001
Compare
ae7e001
to
beb6572
Compare
@andreasg123 Can you give this a whirl? The export default VivViewer;
export type ViewStateChange = (event: Object) => any;
export type Hover = (info: Object, event: Object) => any;
export type HandleValue = (valueArray: Array<number>) => any;
export type HandleCoordinate = (coordnate: Object) => any;
export type HoverHooks = {
handleValue: HandleValue;
handleCoordinate: HandleCoordinate;
};
export type LayerProps = {
/**
* Props for the layers in each view.
*/
layerProps: any[];
/**
* Whether or not to randomize which view goes first (for dynamic rendering of multiple linked views).
*/
randomize?: boolean | undefined;
/**
* Various `VivView`s to render.
*/
views: Array<import('../views').VivView>;
/**
* List of objects like [{ target: [x, y, 0], zoom: -zoom, id: 'left' }, { target: [x, y, 0], zoom: -zoom, id: 'right' }]
*/
viewStates: Array<object>;
/**
* Callback that returns the deck.gl view state (https://deck.gl/docs/api-reference/core/deck#onviewstatechange).
*/
onViewStateChange?: ViewStateChange | undefined;
/**
* Callback that returns the picking info and the event (https://deck.gl/docs/api-reference/core/layer#onhover
* https://deck.gl/docs/developer-guide/interactivity#the-picking-info-object)
*/
onHover?: Hover | undefined;
/**
* Object including utility hooks - an object with key handleValue like { handleValue: (valueArray) => {}, handleCoordinate: (coordinate) => {} } where valueArray
* has the pixel values for the image under the hover location and coordinate is the coordinate in the image from which the values are picked.
*/
hoverHooks?: HoverHooks | undefined;
};
/**
* @callback ViewStateChange
* @param {Object} event
* @ignore
*/
/**
* @callback Hover
* @param {Object} info
* @param {Object} event
* @ignore
*/
/**
* @callback HandleValue
* @param {Array.<number>} valueArray pixel values for the image under the hover location
* @ignore
*/
/**
* @callback HandleCoordinate
* @param {Object} coordnate The coordinate in the image from which the values are picked.
* @ignore
*/
/**
* @typedef HoverHooks
* @type {object}
* @property {HandleValue} handleValue
* @property {HandleCoordinate} handleCoordinate
* @ignore
*/
/**
* @typedef LayerProps
* @type {object}
* @property {Array} layerProps Props for the layers in each view.
* @property {boolean} [randomize] Whether or not to randomize which view goes first (for dynamic rendering of multiple linked views).
* @property {Array.<import('../views').VivView>} views Various `VivView`s to render.
* @property {Array.<object>} viewStates List of objects like [{ target: [x, y, 0], zoom: -zoom, id: 'left' }, { target: [x, y, 0], zoom: -zoom, id: 'right' }]
* @property {ViewStateChange} [onViewStateChange] Callback that returns the deck.gl view state (https://deck.gl/docs/api-reference/core/deck#onviewstatechange).
* @property {Hover} [onHover] Callback that returns the picking info and the event (https://deck.gl/docs/api-reference/core/layer#onhover
* https://deck.gl/docs/developer-guide/interactivity#the-picking-info-object)
* @property {HoverHooks} [hoverHooks] Object including utility hooks - an object with key handleValue like { handleValue: (valueArray) => {}, handleCoordinate: (coordinate) => {} } where valueArray
* has the pixel values for the image under the hover location and coordinate is the coordinate in the image from which the values are picked.
*/
/**
* @type {{ new(props: LayerProps): { props: LayerProps, state: any } }}
*/
declare const VivViewer: new (props: LayerProps) => {
props: LayerProps;
state: any;
}; |
@ilan-gold, I'm now getting this error:
|
Apparently, inheritance can be described like this: microsoft/TypeScript#20077 Definition for |
@andreasg123 I couldn't get the generic or the extension working, but I did try wrapping it in a functional component and then documenting that. Seems to work for me in Avivator. Let me know! |
This mostly works. I have to figure out how to produce the correct
I'm using this definition: type ViewStateChange = ({
viewId,
viewState,
oldViewState,
}: {
viewId: any;
viewState: any;
oldViewState: any;
}) => void; |
I think that I'm good to go. onViewStateChange={(onViewStateChange as unknown) as VivViewer.ViewStateChange} This worked: type ViewStateChange = (event: Object) => void; It shouldn't be difficult to fix this error in my project:
Thank you very much for the quick response. |
Could you please add this to
The following better describes diff --git a/src/views/VivView.js b/src/views/VivView.js
index 1245930..6dda388 100644
--- a/src/views/VivView.js
+++ b/src/views/VivView.js
@@ -40,7 +40,7 @@ export default class VivView {
* @param {object} [args.viewState] incoming ViewState object from deck.gl update.
* @param {object} [args.oldViewState] old ViewState object from deck.gl.
* @param {object} [args.currentViewState] current ViewState object in react state.
- * @returns {object} ViewState for this class (or null by default if the ids do not match).
+ * @returns {?object} ViewState for this class (or null by default if the ids do not match).
*/
filterViewState({ viewState }) {
const { id, height, width } = this;
@@ -50,8 +50,8 @@ export default class VivView {
/**
* Create a layer for this instance.
* @param {Object} args
- * @param {ViewState} args.viewStates ViewStates for all current views.
- * @param {number} args.props Props for this instance.
+ * @param {Object<string,Object>} args.viewStates ViewStates for all current views.
+ * @param {Object} args.props Props for this instance.
* @returns {Layer} Instance of a layer.
*/
// eslint-disable-next-line class-methods-use-this,no-unused-vars Otherwise, your changes work very well for me without any TypeScript errors. Thanks again. |
@andreasg123 Just pushed some changes if you want to give them a whirl. Thanks again! |
@ilan-gold, it works now without problems for me. However, you introduced an inconsistency. For |
* Fix Interleaved RGB Image Handling. (#399) * Fix Interleaved RGB Image Handling. * Prettier. * Defaults for photometricInterpretation * Add test for Interleaved BitmapLayer (#400) * Add test for BitmapLayer * Add more stringent requirement for layer. * Fix slicing bug. * Fix tests better. * Small fixes. * ImageLayer too. * 0.9.4 (#405) * Fix type/docs for VivView(er) and Consumers. (#407) * Fix type/docs for VivViewer and VivView (and upstream users) * Use special jsdoc -> typescript syntax. * Small Fixes * Fix ImageLayer * Try functional component * Small fixes. * Small fixes. * Fix `ImageLayer` `loader` type. (#410) * Improve emitted TS types for layers (#413) * Create `Viv` utility type to refine emitted Layer constructor types. * Do not export VivProps type. * Fix Empty Loader Selection Bug. (#416) * 0.9.5 (#417) * Fix Bugs in `getChannelStats`. (#419) * Fix Bugs in `getChannelStats`. * Use > 0 instead of epsilon value. * Check all properties in onHover to avoid crashes (#426) * Bump url-parse from 1.4.7 to 1.5.1 in /avivator (#427) Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.4.7 to 1.5.1. - [Release notes](https://github.com/unshiftio/url-parse/releases) - [Commits](unshiftio/url-parse@1.4.7...1.5.1) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump hosted-git-info from 2.8.8 to 2.8.9 (#429) Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9. - [Release notes](https://github.com/npm/hosted-git-info/releases) - [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md) - [Commits](npm/hosted-git-info@v2.8.8...v2.8.9) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump lodash from 4.17.20 to 4.17.21 in /avivator (#431) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](lodash/lodash@4.17.20...4.17.21) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump postcss from 8.1.4 to 8.2.15 in /avivator (#432) Bumps [postcss](https://github.com/postcss/postcss) from 8.1.4 to 8.2.15. - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](postcss/postcss@8.1.4...8.2.15) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump lodash from 4.17.20 to 4.17.21 (#428) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](lodash/lodash@4.17.20...4.17.21) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Check for dependabot before running CHANGELOG checks (#433) * New README Screenshots (#435) * Add Screenshots for README * Change width. * Update URLs * Allow for LINEAR/NEAREST Filtering Interpolation Choice (#437) * Allow for LINEAR/NEAREST Filtering Interpolation Choice * Change variable name * Change filtering options. * Bump browserslist from 4.16.1 to 4.16.6 (#441) Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.16.1 to 4.16.6. - [Release notes](https://github.com/browserslist/browserslist/releases) - [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md) - [Commits](browserslist/browserslist@4.16.1...4.16.6) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump browserslist from 4.14.6 to 4.16.6 in /avivator (#442) Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.14.6 to 4.16.6. - [Release notes](https://github.com/browserslist/browserslist/releases) - [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md) - [Commits](browserslist/browserslist@4.14.6...4.16.6) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Trevor Manz <trevor.j.manz@gmail.com> Co-authored-by: Andreas Girgensohn <andreasg123@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Fix Interleaved RGB Image Handling. (#399) * Fix Interleaved RGB Image Handling. * Prettier. * Defaults for photometricInterpretation * Add test for Interleaved BitmapLayer (#400) * Add test for BitmapLayer * Add more stringent requirement for layer. * Fix slicing bug. * Fix tests better. * Small fixes. * ImageLayer too. * 0.9.4 (#405) * Fix type/docs for VivView(er) and Consumers. (#407) * Fix type/docs for VivViewer and VivView (and upstream users) * Use special jsdoc -> typescript syntax. * Small Fixes * Fix ImageLayer * Try functional component * Small fixes. * Small fixes. * Fix `ImageLayer` `loader` type. (#410) * Improve emitted TS types for layers (#413) * Create `Viv` utility type to refine emitted Layer constructor types. * Do not export VivProps type. * Fix Empty Loader Selection Bug. (#416) * 0.9.5 (#417) * Fix Bugs in `getChannelStats`. (#419) * Fix Bugs in `getChannelStats`. * Use > 0 instead of epsilon value. * Check all properties in onHover to avoid crashes (#426) * Bump url-parse from 1.4.7 to 1.5.1 in /avivator (#427) Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.4.7 to 1.5.1. - [Release notes](https://github.com/unshiftio/url-parse/releases) - [Commits](unshiftio/url-parse@1.4.7...1.5.1) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump hosted-git-info from 2.8.8 to 2.8.9 (#429) Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9. - [Release notes](https://github.com/npm/hosted-git-info/releases) - [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md) - [Commits](npm/hosted-git-info@v2.8.8...v2.8.9) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump lodash from 4.17.20 to 4.17.21 in /avivator (#431) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](lodash/lodash@4.17.20...4.17.21) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump postcss from 8.1.4 to 8.2.15 in /avivator (#432) Bumps [postcss](https://github.com/postcss/postcss) from 8.1.4 to 8.2.15. - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](postcss/postcss@8.1.4...8.2.15) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump lodash from 4.17.20 to 4.17.21 (#428) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](lodash/lodash@4.17.20...4.17.21) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Check for dependabot before running CHANGELOG checks (#433) * New README Screenshots (#435) * Add Screenshots for README * Change width. * Update URLs * Allow for LINEAR/NEAREST Filtering Interpolation Choice (#437) * Allow for LINEAR/NEAREST Filtering Interpolation Choice * Change variable name * Change filtering options. * Bump browserslist from 4.16.1 to 4.16.6 (#441) Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.16.1 to 4.16.6. - [Release notes](https://github.com/browserslist/browserslist/releases) - [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md) - [Commits](browserslist/browserslist@4.16.1...4.16.6) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump browserslist from 4.14.6 to 4.16.6 in /avivator (#442) Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.14.6 to 4.16.6. - [Release notes](https://github.com/browserslist/browserslist/releases) - [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md) - [Commits](browserslist/browserslist@4.14.6...4.16.6) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Trevor Manz <trevor.j.manz@gmail.com> Co-authored-by: Andreas Girgensohn <andreasg123@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Fixes #406
Background
In #397 we introduced types via jsdoc but failed to correctly type the VivViewer.
Change List
Checklist