有没有办法阻止TypeScript简化声明文件中的'keyof'语句?

有没有办法阻止TypeScript简化声明文件中的'keyof'语句?,typescript,Typescript,我正在努力修复他们的@customElement装饰器上的LitElement类型错误。问题似乎是TypeScript优化了类型定义。源代码如下所示: export const customElement = (tagName: keyof HTMLElementTagNameMap) => (clazz: Constructor<HTMLElement>) => { window.customElements.define(tagName, clazz); //

我正在努力修复他们的
@customElement
装饰器上的LitElement类型错误。问题似乎是TypeScript优化了类型定义。源代码如下所示:

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;
};
有没有办法阻止TypeScript简化声明文件中的
keyof
语句?如果我手动将声明文件更新为
keyof


此项目的所有代码都在此处

这似乎是重新声明,而不是扩展。除非我对
全局
名称空间有误解。
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;
declare global {
  interface HTMLElementTagNameMap {
    'my-button': MyButton
  }
}