TypeScript typings give me "index.d.ts is not a module" -
i getting file node_modules/@types/webrtc/index.d.ts not module code:
import * webrtc "webrtc"; const peerconnection1 = new rtcpeerconnection();
i have installed typings using npm @types/webrtc --save-dev
. hovering on rtcpeerconnection
in const peerconnection1 = new rtcpeerconnection();
display type annotations in visual studio code @ least code editor sees types. running tsc
(or webpack
ts-loader
) fails error.
i have tried npm webrtc --save
in misguided attempt solving this, did not change , want typings anyway, webrtc right there in browser, don't need package that. (support aside.)
the index.d.ts
file indeed not module, references 2 other files interfaces in them. thought remove import * webrtc "webrtc";
hoping typings still visible tsc
somehow. (but that's impossible since exclude node_modules
in typescript config file.) when rtcpeerconnection
no longer recognized.
adding /// <reference src="node_modules/@types/webrtc/" />
did not help, tsc
says invalid reference directive syntax.
you can view repository minimal repro here on gitlab. not versed in typescript typings acquisition please forgive ignorance if i'm going wrong.
webrtc part of browser; you're trying import module. import (typings) library:
import "webrtc";
you may need use "moduleresolution": "node"
in compiler options.
alternatively use "types": ["webrtc"]
compiler option , compiler automatically load types you.
Comments
Post a Comment