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

Type definitions for Handsontable.GridSettings.renderer and Handsontable.GridSettings.validator are not correct #5004

Closed
IRCraziestTaxi opened this Issue Apr 6, 2018 · 6 comments

Comments

Projects
None yet
5 participants
@IRCraziestTaxi
Copy link

IRCraziestTaxi commented Apr 6, 2018

Description

The type definitions for Handsontable.GridSettings.renderer and Handsontable.GridSettings.validator are not correct. I get typescript errors when trying to pass the appropriate arguments into the methods.

Steps to reproduce

  1. Install handsontable 0.35
  2. Attempt to define a column's renderer as:
renderer: (instance, td, row, col, prop, value, cellProperties) {
}
  1. Attempt to define a column's validator as:
validator: (value, callback: (condition: boolean) => void) => {
}

Type errors are produced. In handsontable.d.ts, within the GridSettings interface, those two functions should contain at least the following types:

renderer?: (
            instance: Core,
            td: HTMLTableCellElement,
            row: number,
            col: number,
            prop: string,
            value: any,
            cellProperties: any
) => void;

validator?: (value: any, callback: (condition: boolean) => void) => void;

But, instead, they are typed as follows:

renderer?: string | (() => void);

validator?: (() => void) | RegExp;

Your environment

  • Handsontable version: 0.35
@NoNameProvided

This comment has been minimized.

Copy link

NoNameProvided commented Apr 16, 2018

I experience the same issue.

@IRCraziestTaxi

This comment has been minimized.

Copy link
Author

IRCraziestTaxi commented May 9, 2018

Additional note: This is still true in handsontable v2.0.

@AMBudnik AMBudnik added the TypeScript label May 10, 2018

@AMBudnik

This comment has been minimized.

Copy link
Contributor

AMBudnik commented May 10, 2018

related #5091

@swistach

This comment has been minimized.

Copy link
Member

swistach commented May 17, 2018

Hi @IRCraziestTaxi,
Thank you for your sharing. I marked this issue as a bug.

@aaronbeall

This comment has been minimized.

Copy link
Contributor

aaronbeall commented Jan 16, 2019

This seems to be fixed, renderer and validator are now defined in GridSettings as:

renderer?: string | renderers.Base;
validator?: (value: any, callback: (valid: boolean) => void) => void | RegExp;

And renderers.Base is:

interface Base {
  (instance: _Handsontable.Core, TD: HTMLElement, row: number, col: number, prop: string | number, value: any, cellProperties: GridSettings): HTMLElement;
}

Does that resolve this issue, @IRCraziestTaxi ?

@aaronbeall aaronbeall referenced this issue Feb 6, 2019

Merged

TypeScript .d.ts type definitions improvement #5767

2 of 6 tasks complete
@AMBudnik

This comment has been minimized.

Copy link
Contributor

AMBudnik commented Mar 6, 2019

Hey @IRCraziestTaxi @NoNameProvided

thanks to @aaronbeall and our dev team we've improved the definition file. Just released it in v 7.0.0 of Handsontable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.