Argument of type 'X' is not assignable to parameter of type 'X' with 'exactOp...
Production Risk
Build will fail; resolve before shipping.
A type-checking error (TS2379): Argument of type 'X' is not assignable to parameter of type 'X' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.. This diagnostic is emitted by the TypeScript compiler when argument of type 'X' is not assignable to parameter of type 'X' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties..
- 1The value type does not match the declared or expected type
- 2A type narrowing or assertion is needed
TypeScript compiler reports TS2379 during type checking.
// Triggers TS2379 // Argument of type 'X' is not assignable to parameter of type 'X' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
expected output
error TS2379: Argument of type 'X' is not assignable to parameter of type 'X' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Fix
Correct the argument type
WHEN When calling a function with a wrong argument type
// Check the function signature and pass the correct type
function fn(x: string) {}
fn(String(value)); // convert if neededWhy this works
The parameter type and the argument type must be compatible.
TypeScript Compiler Diagnostics
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev