Búsqueda de sitios web

¿Hay alguna manera de evitar que TypeScript simplifique la declaración de `keyof` en los archivos de declaración?


Estoy trabajando en intentar arreglar un error de tipado con LitElement en su decorador @customElement. El problema parece ser que TypeScript está optimizando la definición de tipos. El código fuente se ve así:

export const customElement = (tagName: keyof HTMLElementTagNameMap) =>
(clazz: Constructor<HTMLElement>) => {
  window.customElements.define(tagName, clazz);
  // Cast as any because TS doesn't recognize the return type as being a
  // subtype of the decorated class when clazz is typed as
  // `Constructor<HTMLElement>` for some reason. `Constructor<HTMLElement>`
  // is helpful to make sure the decorator is applied to elements however.
  return clazz as any;
};

Pero en el archivo de declaración la salida es esta:

export declare const customElement: (tagName: "object" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr") => (clazz: Constructor<HTMLElement>) => any;

La idea es que al declarar tu elemento personalizado también extiendas el HTMLElementTagNameMap:

declare global {
  interface HTMLElementTagNameMap {
    'my-button': MyButton
  }
}

¿Hay alguna manera de evitar que TypeScript simplifique la declaración keyof en los archivos de declaración? Si actualizo manualmente el archivo de declaración para que sea keyof, todo funciona como se espera.

Todo el código de este proyecto está aquí https://github.com/Polymer/lit-element