Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lens): fix undefined access of focusTo and fromKey #40

Merged
merged 1 commit into from
Aug 28, 2018

Conversation

Ailrun
Copy link
Owner

@Ailrun Ailrun commented Aug 28, 2018

Description

When you have something like following,

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.

@Ailrun Ailrun added the PR: fix bug 🛠️ PR fixing some bugs label Aug 28, 2018
@Ailrun Ailrun self-assigned this Aug 28, 2018
@Ailrun Ailrun merged commit 4a63355 into master Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: fix bug 🛠️ PR fixing some bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant