-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Closed
Copy link
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Refactoringse.g. extract to constant or function, rename symbole.g. extract to constant or function, rename symbolHelp WantedYou can do thisYou can do this
Milestone
Description
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.");
}JoshuaKGoldberg, blarfoon, nxpatterns and Beraliv
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Refactoringse.g. extract to constant or function, rename symbole.g. extract to constant or function, rename symbolHelp WantedYou can do thisYou can do this