TypeScript typings give me “index.d.ts is not a module”

后端 未结 5 746
借酒劲吻你
借酒劲吻你 2020-12-16 09:12

I am getting File node_modules/@types/webrtc/index.d.ts is not a module with this code:

import * as webrtc from \"webrtc\";
const peerConnection1 =          


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 09:47

    webrtc is part of the browser; you're trying to import a module. Simply import the (typings) library:

    import "webrtc";
    

    you may need to use "moduleResolution": "node" in the compiler options.

    Alternatively use the "types": ["webrtc"] compiler option and the compiler will automatically load those types up for you.

提交回复
热议问题