- Error
- Reported by the type checker
TS7010
'{0}', which lacks return-type annotation, implicitly has an '{1}' return type.
A declaration without a body (overload, interface method, `declare function`) has no return type, so it would return `any`. Add one.
What it means
Under noImplicitAny, a function or method declaration with no body has nothing to infer a return type from. Without an annotation its return type is any. ts-r reports this for body-less declarations such as declare function, overload signatures and methods in interfaces or ambient classes.
Example
declare function load(path: string);
export const data = load("a.json");
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(1,18): error TS7010: 'load', which lacks return-type annotation, implicitly has an 'any' return type.
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
- Write the return type:
declare function load(path: string): unknown;.