microsoft / microsoft/TypeScript
Function implementation name must be ... (2389) when abstract method is declared again later
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
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
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