'Exporting Referenced Types

I'd like to export a subset of globals from my definition file

Example

// webrtc.globals.d.ts

/// <reference types="web" />

// Cannot redeclare block-scoped variable 'RTCIceCandidate'.
declare { RTCIceCandidate }
// wrtc.d.ts

/// <reference types="web" />

// Cannot export 'RTCIceCandidate'. Only local declarations can be exported from a module.
declare module "webrtc" {
  export { RTCIceCandidate }
}

Thought process

  • I want the typescript definitions for [wrtc])(https://www.npmjs.com/package/wrtc)
  • They don't exist, but its just webrtc types anyway.
  • Perhaps I can import the types from another defintion file and export them again in my declaration
  • I can use @types/webrtc
  • It doesn't have RTCIceCandidate
  • It is available in @types/web
  • I don't want to have all the globals though. How do I restrict them?

For now I'm just going to allow all the globals in my applications but, if you are not aware, that is a bad idea since many of those globals simply do not exist.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source