- Error
- Reported by the type checker
TS2749
'{0}' refers to a value, but is being used as a type here. Did you mean 'typeof {0}'?
A variable or function is used in a type position. Use typeof name to get its type, or reference the actual type.
What it means
Values and types live in separate namespaces. A name that is only a value (a variable, a function, a constant) can't be used as a type directly.
Example
const defaults = { port: 80 };
let config: defaults;
export {};
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(2,13): error TS2749: 'defaults' refers to a value, but is being used as a type here. Did you mean 'typeof defaults'?
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
- Use
typeofto get the value's type:let config: typeof defaults;. - Or declare a named type or interface and use that.