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

后端 未结 5 751
借酒劲吻你
借酒劲吻你 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:35

    You probably want to add

    "types": ["webrtc"]
    

    to your tsconfig.json, or less preferrably, to use

    /// 
    

    in your source files. Here's an example of it in your tsconfig.json:

    {
        "compilerOptions": {
            "target": "es5",
            "sourceMap": true,
            "noImplicitAny": true,
    
            "types": ["webrtc"]
        },
        "exclude": [
            "node_modules"
        ]
    }
    

    This tells TypeScript it should include webrtc declarations in your build

提交回复
热议问题