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

Add type definition #1116

Merged
merged 15 commits into from
May 28, 2020
Merged

Add type definition #1116

merged 15 commits into from
May 28, 2020

Conversation

heshan0131
Copy link
Contributor

@heshan0131 heshan0131 commented May 14, 2020

Part 1 of the work: Added typedef to

  • reducers
  • actions
  • processers
  • schemas
  • and partially utils

Signed-off-by: Shan He heshan0131@gmail.com

Copy link
Collaborator

@ibgreen ibgreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this built on my internal branch adding types to actions, or is this an independent effort? If not I might want to review that branch and see if it contains something additional.

package.json Outdated
@@ -49,7 +49,8 @@
"docs": "babel-node ./scripts/documentation.js",
"example-version": "babel-node ./scripts/edit-version.js",
"prettier-all": "prettier --write '{src,examples,test}/**/*.js'",
"lint": "eslint src test webpack examples/*.js examples/**/src website/*.js website/src --fix",
"lint": "yarn typescript && eslint src test webpack examples/*.js examples/**/src website/*.js website/src --fix",
"typescript": "tsc",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear we can write tsc --noEmit - though we do have the noEmit setting in the tsconfig, I still think it is worth having it here to emphasize that we are just type checking.

Signed-off-by: Shan He <heshan0131@gmail.com>

add vis-state-updater

Signed-off-by: Shan He <heshan0131@gmail.com>

fix module resolve

Signed-off-by: Shan He <heshan0131@gmail.com>

wip type checking vis-state actions

Signed-off-by: Shan He <heshan0131@gmail.com>

filter-utiles type

Signed-off-by: Shan He <heshan0131@gmail.com>

vis-state-updater tpes

Signed-off-by: Shan He <heshan0131@gmail.com>

add merger schema

Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
Copy link
Collaborator

@akre54 akre54 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Looking forward to this

@@ -28,14 +28,15 @@ export const PROPERTY_GROUPS = keyMirror({
stroke: null,
radius: null,
height: null,

angel: null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: angle

defaultValue: boolean;
};

export type VisConfigSelection = VisConfig<string> & {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is VisConfig a generic? If so, why is there VisConfig<string> but not VisConfig<boolean>? If not, shouldn't this line error?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think VisConfig is a generic, this may be a typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a typo, good catch

Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
@heshan0131 heshan0131 changed the title [WIP] add type definition Add type definition May 25, 2020
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
/**
* Input dataest parsed to addDataToMap
*/
export type ProtoDataset = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why protodataset and not simply Dataset?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the input data that user passed to addDAtaToMap, it then gets converted to dataset

* @param {string} payload.mapboxApiUrl - mapboxApiUrl to be saved to mapStyle reducer.
* @param {Boolean} payload.mapStylesReplaceDefault - mapStylesReplaceDefault to be saved to mapStyle reducer
* @param {object} payload
* @param payload.mapboxApiAccessToken - mapboxApiAccessToken to be saved to mapStyle reducer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove types here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never mind i see the @type


import ActionTypes from 'constants/action-types';

export function registerEntry(entry: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you create a a type for the entry inptu?

type RegistryEntity {
  id:...
  mint:...
...
}


export type AddDataToMaoPayload = {
datasets: ProtoDataset[];
options?: AddDaataToMapOptions;
Copy link
Collaborator

@macrigiuseppe macrigiuseppe May 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type in AddDaataToMapOptions


export function addDataToMap(
data: AddDataToMaoPayload
): {type: ActionTypes.ADD_DATA_TO_MAP; payload: AddDataToMaoPayload};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo AddDataToMaoPayload

/** REQUEST_MAP_STYLES */
export type RequestMapStylesUpdaterAction = {
payload: {
[key: string]: {
Copy link
Collaborator

@macrigiuseppe macrigiuseppe May 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use MapStyles?

export type MapStyles = {
  [key: string]: BaseMapStyle;
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the request payload, BaseMapStyle is the merged result of this request.

provider: Provider;
options?: ExportFileOptions;
onSuccess?: any;
closeModal?: booleam;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in booleam

/** LOAD_MAP_STYLES */
export type LoadMapStylesUpdaterAction = {
payload: {
[id: string]: BaseMapStyle;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

error: any;
provider: Provider;
options?: Options;
onError?: any;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(error: object) => void

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it would be better to create a type ErrorCallback since you are using it in few places

export type LoadCloudMapPayload = {
loadParams: any;
provider: string;
onSuccess?: any;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for this one

loadParams: any;
provider: string;
onSuccess?: any;
onError?: any;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ErrorCallback

response: any;
loadParams: any;
provider: string;
onSuccess?: any;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here

export type LoadCloudMapErrorPayload = {
error: any;
provider: stirng;
onError?: any;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here


export type LayerConfigChangeUpdaterAction = {
oldLayer: Layer;
newConfig: Partiel<LayerConfig>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a typo? should it be Partial? I am not sure

@@ -51,130 +50,120 @@ import {ACTION_PREFIX} from './default-settings';
*
* export default createStore(reducers, {}, applyMiddleware(taskMiddleware))
*/
const ActionTypes = keyMirror({
const ActionTypes = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be achieved by creating a helper that takes the map object and add the prefix to each and every property

Object.keys(types).reduce((acc, key) => ({
  [key]: `${ACTION_PREFIX}${types[key]}`
}), {})

I mean you. already did the work so it is not a big deal but something to consider

export function mergeLayers(state: VisState, layers: ParsedConfig['visState']['layers']): VisState;
export function mergeSplitMaps(state: VisState, splitMaps: ParsedConfig['visState']['splitMaps']): VisState;

export function mergeInteractionTooltipConfig(state: VisState)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty line is missing in this file

} from './schema-manager';

export const KeplerGlSchema: KeplerGLSchema;
export default KeplerGlSchema
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty line

Copy link
Collaborator

@macrigiuseppe macrigiuseppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Work!

just few comments

Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
@heshan0131 heshan0131 merged commit 25c6d2e into master May 28, 2020
@delete-merged-branch delete-merged-branch bot deleted the typescript-def branch May 28, 2020 05:49
manassra pushed a commit that referenced this pull request Jun 18, 2020
Part 1: Added typedef to reducers, actions, processers, schemas, partially utils

Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Wesam Manassra <wesam.manassra@gmail.com>
@epan epan mentioned this pull request Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants