Microsoft/TypeScript

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

Open

#61 783 ouverte le 29 mai 2025

Voir sur GitHub
 (3 commentaires) (0 réactions) (0 assignés)TypeScript (6 726 forks)batch import
Domain: Error MessagesHelp WantedPossible Improvement

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

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

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

Guide contributeur