interface X {
key?: {
inner: number;
};
}
const x: X = {};
const xLens: LensSProxy<X, X> = new LensGenerator<X>().byProxy();
xLens
.key
.inner
.set()(x)(5);
last statement will give you error saying <xxx> is undefined. This is because when lens try to set inner, lens try to get a current value of key, which is undefined, and try to set the 5 to its inner property.
This is not a best solution (since this can break types if there is more than one properties to the key which is currently undefined), just a hot fix for lens problem.
Description
When you have something like following,
last statement will give you error saying
<xxx> is undefined
. This is because when lens try to setinner
, lens try to get a current value ofkey
, which isundefined
, and try to set the5
to itsinner
property.This is not a best solution (since this can break types if there is more than one properties to the key which is currently
undefined
), just a hot fix for lens problem.