DataTables / FixedHeader

Fix the header, footer, left or right columns of a table in place, to always show them when scrolling
http://www.datatables.net/
Other
75 stars 83 forks source link

Fix: Avoid errors with tsconfig#noImplicitAny #109

Closed sakamossan closed 1 year ago

sakamossan commented 1 year ago

I'm encountering a type error in the type definition of types/types.d.ts.

Construct signature, which lacks return-type annotation, implicitly has an 'any' return type

$ npx tsc --noEmit --noImplicitAny
node_modules/datatables.net-fixedheader/types/types.d.ts:43:4 - error TS7013: Construct signature, which lacks return-type annotation, implicitly has an 'any' return type.

43    new (dt: Api<any>, settings: boolean | ConfigFixedHeader);
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error in node_modules/datatables.net-fixedheader/types/types.d.ts:43

This occurs when the noImplicitAny flag is enabled. I believe many projects might be using this setting.

I checked the documentation, and it appears that this process does not expect a return value. I've added explicit type definitions accordingly.

AllanJard commented 1 year ago

It doesn't actually return void, it returns an instance of the FixedHeader "class". I'd kind of expected Typescript to infer that automatically. However, it isn't expected to be used publicly, so I think a void return is probably correct since we are documenting the API with Typescript here.

AllanJard commented 1 year ago

Thanks for the PR and flagging this up!