microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.11k stars 12.5k forks source link

Unexpected type listing for `keyof T` on declaration file #17294

Open saschanaz opened 7 years ago

saschanaz commented 7 years ago

TypeScript Version: 2.4.1 Code

var Foo = class Foo {
    method<T extends keyof ElementTagNameMap>() {};
}

class Bar {
    method<T extends keyof ElementTagNameMap>() {};
}

tsc test.ts -t es2017 -d

Expected behavior: Both should use keyof ElementTagNameMap

Actual behavior:

declare var Foo: {
    new (): {
        method<T extends "symbol" | "object" | "track" | "progress" | "a" | "applet" | "area" | "audio" | "base" | "basefont" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "col" | "colgroup" | "data" | "datalist" | "del" | "dir" | "div" | "dl" | "embed" | "fieldset" | "font" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "hr" | "html" | "iframe" | "img" | "input" | "ins" | "isindex" | "label" | "legend" | "li" | "link" | "listing" | "map" | "marquee" | "menu" | "meta" | "meter" | "nextid" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "q" | "script" | "select" | "source" | "span" | "style" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "ul" | "video" | "x-ms-webview" | "xmp" | "circle" | "defs" | "desc" | "ellipse" | "filter" | "g" | "image" | "line" | "marker" | "mask" | "path" | "metadata" | "pattern" | "polygon" | "polyline" | "rect" | "svg" | "stop" | "switch" | "tspan" | "text" | "use" | "view" | "abbr" | "acronym" | "address" | "article" | "aside" | "b" | "bdo" | "big" | "center" | "cite" | "clippath" | "code" | "dd" | "dfn" | "dt" | "em" | "feblend" | "fecolormatrix" | "fecomponenttransfer" | "fecomposite" | "feconvolvematrix" | "fediffuselighting" | "fedisplacementmap" | "fedistantlight" | "feflood" | "fefunca" | "fefuncb" | "fefuncg" | "fefuncr" | "fegaussianblur" | "feimage" | "femerge" | "femergenode" | "femorphology" | "feoffset" | "fepointlight" | "fespecularlighting" | "fespotlight" | "fetile" | "feturbulence" | "figcaption" | "figure" | "footer" | "foreignobject" | "header" | "hgroup" | "i" | "kbd" | "keygen" | "lineargradient" | "mark" | "nav" | "nobr" | "noframes" | "noscript" | "plaintext" | "radialgradient" | "rt" | "ruby" | "s" | "samp" | "section" | "small" | "strike" | "strong" | "sub" | "sup" | "textpath" | "tt" | "u" | "var" | "wbr">(): void;
    };
};
declare class Bar {
    method<T extends keyof ElementTagNameMap>(): void;
}
mhegazy commented 7 years ago

chances are we will not be able to fix this. but getting @weswigham to see if there is a possible solution here.