title: How to create a globally available interface/type in TypeScript?
body: <p>I am creating an component library with Preact and TypeScript. I have an icon component which can be used like:</p>
  <pre><code>&lt;SVGIcon name='camera' width={16} height={24} /&gt;
  </code></pre>
  <p>And, it is implemented as:</p>
  <pre><code>export interface SVGIconProps {
    class?: string;
    width?: string;
    height?: string;
    name: string;
  };
  
  export function SVGIcon(props: SVGIconProps) { /* return svg; */ }
  </code></pre>
  <p>In to provide better intellisense for library users, I want to narrow the type of <code>name</code> prop to a limited set of string literals (basically show only allowed names for icons). I can, of course, use string literals that library is providing; however, the user is also allowed to dynamically register his own additional icon sets using a register function like:</p>
  <pre><code>registerIcon('icon-name', jsxFunctionReturningSVGFragment);
  </code></pre>
  <p>The <code>registerIcon</code> function add the icon and its JSX function to an internal cache (instance of ES <code>Map</code>).</p>
  <p>That question is how can I retain the narrow typing and provide auto-complete/intellisense for library users considering the fact that they can add one or more icons when consuming the library?</p>
  <p>Is it possible to declare a dummy interface/type say <code>MyLibIconSet</code> at a library level which the user of the library should then override in his code-base before using the library? Something similar to how we do for declaration merging or using Global augmentation for patching missing types?</p>