Skip to content

Add Missing Function Declaration: Does Not Correctly Declare Generic Function #49693

Closed
@Jutanium

Description

@Jutanium

Bug Report

The "Quick Feature" allows us to generate a missing a function, but doesn't correctly declare that function when its parameters include a type parameter.

See also unexpected behavior when type narrowing in this example.

🔎 Search Terms

  • add missing function declaration
  • generic type parameter

🕗 Version & Regression Information

I am unable to find a version of TypeScript where this was not a problem.

⏯ Playground Link

Playground link with relevant code

💻 Code

function identity<T>(self: T) {
 
  // To reproduce the bug, Quick Fix > Add missing function declaration
  runEvilSideEffect(self)

  return self;
}

🙁 Actual behavior

TypeScript generated this function, which is an invalid function declaration:

function runEvilSideEffect(self: T) {
    throw new Error("Function not implemented.");
}

🙂 Expected behavior

function runEvilSideEffect<T> (self: T) {
    throw new Error("Function not implemented.");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Refactoringse.g. extract to constant or function, rename symbolHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions