disable wrong typescript error

前端 未结 1 699

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.         


        
相关标签:
1条回答
  • 2021-01-21 06:15

    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;
    }
    
    0 讨论(0)
提交回复
热议问题