How to declare “any” module in TypeScript?

前端 未结 1 1203
再見小時候
再見小時候 2021-01-17 09:07

I need to migrate step by step some large project from js to typeScript.

I rewrite on of the files in ts and i want to specify that other files at this moment can co

相关标签:
1条回答
  • 2021-01-17 09:28

    For an external module with no exposed types and any values:

    declare module 'Foo' {
      var x: any;
      export = x;
    }
    

    This won't let you write foo.cls, though.

    If you're stubbing out individual classes, you can write:

    declare module 'Foo' {
        // The type side
        export type cls = any;
        // The value side
        export var cls: any;
    }
    
    0 讨论(0)
提交回复
热议问题