microsoft / microsoft/TypeScript

Function implementation name must be ... (2389) when abstract method is declared again later

Open
#61,783 3 comments 0 reactions 0 assignees View on GitHub
Domain: Error Messages Help Wanted Possible Improvement
Dominant language
Go
Stars
111k
Forks
14.3k
PR merge metrics
PR metrics pending

Description

### 🔎 Search Terms

duplicate abstract function declaration, abstract method, missing implementation, abstract method overload

### 🕗 Version & Regression Information

- This is the behavior in every version I tried, and I reviewed the FAQ for entries about abstract class

### ⏯ Playground Link

https://www.typescriptlang.org/play/?#code/IYIwzgLgTsDGEAJYBthjAgYge2wg3gFAIkKiQzwIBmArgHawAiApigIwAUAlAFwIA3bAEsAJgG5CxUnUasUAJh78Kw+gHMC00qSgsItKPQQByABbCT2hAF9r18tDiJZzNsi59BIiYTtA

### 💻 Code

```ts
abstract class Foo {
abstract func1(): void;

func2(): string {
// ^? Function implementation name must be 'func1'.(2389)
return 'hi'
}

abstract func1(): void;
}
```

### 🙁 Actual behavior

TS error reported for `func2`, which is valid.

### 🙂 Expected behavior

TS error reported for `func1`, which has duplicated abstract declaration.

### Additional information about the issue

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the diagnostic using the TypeScript Playground link and the abstract class example in the issue. Trace how the compiler assigns implementation-name errors for repeated abstract declarations; done means the error points to the duplicated func1 declaration rather than the valid func2 implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.