Interact.js: [Typings] Not compatible with `strict` compilerOptions

Created on 5 Apr 2018  路  10Comments  路  Source: taye/interact.js

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

wontfix

Most helpful comment

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

All 10 comments

:+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.

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

Same issue..

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

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.

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 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 The Interact namespace is exposed globally so you should be able to use Interact.IteractEvent

@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!

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rbozan picture rbozan  路  9Comments

freefalling picture freefalling  路  3Comments

andrewgleave picture andrewgleave  路  6Comments

jf-m picture jf-m  路  6Comments

sualko picture sualko  路  9Comments