- Error
- Reported by the type checker
TS1244
Abstract methods can only appear within an abstract class.
An abstract method is declared in a class that isn't abstract. Mark the class `abstract`, or give the method a body.
What it means
An abstract method has no body, so only an abstract class, which can't be instantiated, may declare one. A plain class with an abstract method is reported here.
Example
export class Shape {
abstract area(): number;
}
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(2,3): error TS1244: Abstract methods can only appear within an abstract class.
Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.
How to fix
- Make the class abstract:
abstract class Shape. - Or implement the method and drop
abstract.