- Error
- Reported by the type checker
TS2391
Function implementation is missing or not immediately following the declaration.
A function overload signature has no implementation, or something else sits between the overloads and the body. Add the body directly after them.
What it means
Outside declaration files and declare blocks, a function or method signature without a body is an overload, and the implementation must come immediately after the last overload. A missing body, or another statement in between, is reported on the signature.
Example
export function parse(text: string): number;
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(1,17): error TS2391: Function implementation is missing or not immediately following the declaration.
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
- Add the body to the function, or add an implementation right after the overloads.
- Move any statement that sits between the overloads and the implementation.
- If the function exists elsewhere at runtime, declare it with
declare function.