TypeScript typings give me "index.d.ts is not a module"
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.
You probably want to add
"types": ["webrtc"]
to your tsconfig.json
, or less preferrably, to use
/// <reference types="webrtc" />
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
Another option is to add a new declaration file *.d.ts
in your module, i.e.:
declare module 'my-module';
No need to import anything, run following:
npm install --save @types/webrtc
-
update tsconfig.json -
"types": [ "@types/webrtc" ]
In vscode
Ctrl + p > Developer: Reload Window