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

Typescript definitions #33

Open
nimo-juice opened this issue Nov 18, 2021 · 3 comments
Open

Typescript definitions #33

nimo-juice opened this issue Nov 18, 2021 · 3 comments

Comments

@nimo-juice
Copy link

Expected Behavior

Your type library does not cover most of the type definitions for the library itself. It would be great to add more.

Current Behavior

Typescript definitions are failing in my repository.

Possible Solution

import { IConfig } from '@vgs/collect-js/dist/utils/IConfig';

type stateParam = {
  errorMessages: string[];
  isDirty: boolean;
  isEmpty: boolean;
  isFocused: boolean;
  isTouched: boolean;
  isValid: boolean;
  name: string;
};

type responseData = {
  errors: {
    detail: string;
    source: {
      pointer: string;
    };
    status: string;
    title: string;
  }[];
};

declare module '@vgs/collect-js' {
  export interface VGSForm {
    field: (
      id: string,
      options: {
        type: string;
        name: string;
        placeholder: string;
        validations: string[];
        successColor?: string;
        errorColor?: string;
        maxLength?: number;
        yearLength?: number;
        serializers?: string[];
        css?: Record<string, string>;
      },
    ) => void;
    SERIALIZERS: string;
    submit: (
      path: string,
      options: {
        mapDotToObject: string;
        headers: Record<string, string>;
      },
      onResponse?: (status: number, data: responseData) => void,
    ) => void;
    state: Record<string, stateParam>;
    onUpdateCallback: unknown;
  }

  export interface CollectFN {
    init: (fn?: (state: Record<string, stateParam>) => void) => VGSFormDef;
  }

  export const loadVGSCollect: (config?: IConfig) => Promise<CollectFN>;
}

Context

Your Environment

  • Version used:
  • Browser Name and version:
  • Operating System and version (desktop or mobile):
  • Link to your project:
@AnnaKudriasheva
Copy link
Collaborator

@nimo-juice thank you for pointing this out! We'll work on adding more types.

@nimo-juice
Copy link
Author

@AnnaKudriasheva happy to open a PR if there are recommendations on how : )

@fstodulski
Copy link

What is the status for it @AnnaKudriasheva ?

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

No branches or pull requests

3 participants