- Error
- Reported by the type checker
TS2559
Type '{0}' has no properties in common with type '{1}'.
A value is assigned to a type whose properties are all optional, but the value has none of them. Check you passed the right object.
What it means
A type whose properties are all optional (a "weak" type) would accept almost anything. To catch mistakes, assigning a value that shares no property with it is reported.
Example
interface Options {
verbose?: boolean;
depth?: number;
}
const opts = { colour: true };
export const o: Options = opts;
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(6,14): error TS2559: Type '{ colour: boolean; }' has no properties in common with type 'Options'.
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
- Pass an object with at least one of the expected properties (often a typo in a property name).
- If the value really is unrelated, don't assign it to that type.