interact.js icon indicating copy to clipboard operation
interact.js copied to clipboard

[Typings] Not compatible with `strict` compilerOptions

Open DrSensor opened this issue 8 years ago • 10 comments

Expected behavior

No error when using typescript with configuration complerOptions.strict and tslint:recommended enable.

Actual behavior

ERROR in /home/wildan/Projects/Sensorfied/EDI/edi-ui/node_modules/interactjs/index.d.ts
164:5 'preventDefault', which lacks return-type annotation, implicitly has an 'any' return type.
    162 |     relatedTarget: DOMElement
    163 |     currentTarget: DOMElement
  > 164 |     preventDefault ()
        |     ^
    165 |     pageX: number
    166 |     pageY: number
    167 |     clientX: number
ERROR in /home/wildan/Projects/Sensorfied/EDI/edi-ui/node_modules/interactjs/index.d.ts
276:5 'test', which lacks return-type annotation, implicitly has an 'any' return type.
    274 |     styleCursor ( yesno: boolean ) : Interactable
    275 |     createSnapGrid ( opt: { x: number, y: number, range: number, offset: Position } ) : SnapFunction
  > 276 |     test ( x : SnapFunction )
        |     ^
    277 |   }
    278 |
    279 |   interface InteractOptions {
ERROR in /home/wildan/Projects/Sensorfied/EDI/edi-ui/node_modules/interactjs/index.d.ts
291:13 Parameter 'any' implicitly has an 'any' type.
    289 |     pointerMoveTolerance ( tol?: number ) : number | InteractStatic
    290 |     // TODO
  > 291 |     isSet ( any ) : any
        |             ^
    292 |     off ( any ) : any
    293 |     debug ( any ) : any
    294 |     addDocument ( any ) : any
ERROR in /home/wildan/Projects/Sensorfied/EDI/edi-ui/node_modules/interactjs/index.d.ts
292:11 Parameter 'any' implicitly has an 'any' type.
    290 |     // TODO
    291 |     isSet ( any ) : any
  > 292 |     off ( any ) : any
        |           ^
    293 |     debug ( any ) : any
    294 |     addDocument ( any ) : any
    295 |     removeDocument ( any ) : any
ERROR in /home/wildan/Projects/Sensorfied/EDI/edi-ui/node_modules/interactjs/index.d.ts
293:13 Parameter 'any' implicitly has an 'any' type.
    291 |     isSet ( any ) : any
    292 |     off ( any ) : any
  > 293 |     debug ( any ) : any
        |             ^
    294 |     addDocument ( any ) : any
    295 |     removeDocument ( any ) : any
    296 |   }
ERROR in /home/wildan/Projects/Sensorfied/EDI/edi-ui/node_modules/interactjs/index.d.ts
294:19 Parameter 'any' implicitly has an 'any' type.
    292 |     off ( any ) : any
    293 |     debug ( any ) : any
  > 294 |     addDocument ( any ) : any
        |                   ^
    295 |     removeDocument ( any ) : any
    296 |   }
    297 | }
ERROR in /home/wildan/Projects/Sensorfied/EDI/edi-ui/node_modules/interactjs/index.d.ts
295:22 Parameter 'any' implicitly has an 'any' type.
    293 |     debug ( any ) : any
    294 |     addDocument ( any ) : any
  > 295 |     removeDocument ( any ) : any
        |                      ^
    296 |   }
    297 | }
    298 |

Suggestion

For just temporary, I suggest any PR involving typescript should be accepted by default until there is a smoke test for supporting typescript.

System configuration

interact.js version: 1.3.3 Browser name and version: Google Chrome Version 64.0.3282.186 (Official Build) (64-bit) Operating System: Ubuntu 16.04

DrSensor avatar Apr 05 '18 08:04 DrSensor

:+1: same issue.

We recommend all declaration files be compiled with --strict to ensure they do adhere to the strictest possible settings.

https://github.com/Microsoft/TypeScript/issues/18974

However that also says the skiplibcheck flag can be used as a workaround.

bencoveney avatar Jul 11 '18 15:07 bencoveney

Same issue to. However --skiplibcheck seems like an all or nothing fix. I think its best to try to open a PR to fix the problem. I hope it is merged and released ASAP though

tundebabzy avatar Oct 23 '18 20:10 tundebabzy

Same issue..

InputNeuron avatar Jan 20 '19 02:01 InputNeuron

I'm translating the project to typescript so, with some help, this should be resolved soon.

taye avatar Jan 28 '19 01:01 taye

Nice. For what it's worth I did a huge migration with Polar:

https://getpolarized.io/

... and it was a massive help! I think you'll find a huge productivity win here.

InputNeuron avatar Jan 28 '19 18:01 InputNeuron

The migration is done. Please update to version 1.4.0-alpha.23.

npm install interactjs@next
npm install --save-dev @interactjs/types@next

taye avatar Feb 01 '19 23:02 taye

@taye Thanks for releasing the types for the plugin! However, it seems like doing import interact from 'interactjs'; no longer exposes the internal types for the plugin anymore.

In the root index.d.ts, import '@interactjs/types doesn't import anything, because the types/index.d.ts only contains a reference and doesn't export any types. I might be misunderstanding TypeScript type declarations here, so please correct me if I'm wrong.

In order to get all the typings for the plugin, I will have to import the types manually, i.e.:

import interact from 'interactjs';
import { InteractEvent } from '@interactjs/types/types';

So that I can do something like this:

interact(element).draggable({
  onstart: onPanStart
});

function onPanStart(InteractEvent): void {
  // Do something
}

terrymun avatar Feb 25 '19 06:02 terrymun

@terrymun The Interact namespace is exposed globally so you should be able to use Interact.IteractEvent

taye avatar Mar 02 '19 17:03 taye

@taye Thanks for the quick reply, sorry for getting back to you a bit later. Using Interact.<...> instead of interact.<...> worked for me, since it is the namespace Interact that is being exported :) Thank you!

terrymun avatar Mar 11 '19 13:03 terrymun

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 10 '19 13:05 stale[bot]