Skip to content Skip to sidebar Skip to footer

Disable Wrong Typescript Error

I have installed 'interact.js' with jspm (and npm for typescript to be happy). The app runs fine but my code shows errors: import { interact } from 'interact.js/interact' // ==>

Solution 1:

The TypeScript compiler/language service doesn't actually resolve module names through the filesystem or your package.json like you might expect - it instead uses the definition (.d.ts) files that define the type information.

While it's not the most intuitive thing in the world, their reasoning for it wasn't entirely unreasonable - without a definition file, it's impossible to know what type the thing being imported is, and they were somewhat cagey about making the compiler default to just setting imports to the any type.

So in short, the solution to this problem is simply to install the definition files if available, or write/stub out your own if not. They'll be making this easier in TypeScript 2.0 by the sounds of it, but even as it stands, it takes very code to create a dummy definition:

declare module "interact.js/interact" {
    export var interact: any;
}

Post a Comment for "Disable Wrong Typescript Error"