镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

bad declaration emit for rebound type parameter name #47561

Closed

Description

Bug Report

An d.ts file containing an undeclared typename is generated when a generic typename bound to a function container is rebound to a nested function definition which is used as part of the outer function's return type.

🔎 Search Terms

declaration emit bound shadow undeclared typename

🕗 Version & Regression Information

4.3.5 does not exhibit, but 4.4.4+ does (as per the playground)
as of $now it is also present in nightly on the playground

  • This changed between versions 4.3.5 and 4.4.4

⏯ Playground Link

Playground link with relevant code

💻 Code

function foo<T>(v:T) {
    function x<T>(v: T) { return v; }
    function y() : T { return v; }
    return {
        x, // decl emit: <T_1>(v:T_1) => T_1
        y  // decl emit: () => T_2 // can't find name 'T_2'
    };
}

🙁 Actual behavior

error in declaration file

🙂 Expected behavior

no error in declaration file
(or error at compile time if you want to not allow shadowing like this.

Metadata

Metadata

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions