Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Accessing an array field doesn't work #41

Open
dko-slapdash opened this issue May 23, 2019 · 3 comments
Open

Accessing an array field doesn't work #41

dko-slapdash opened this issue May 23, 2019 · 3 comments

Comments

@dko-slapdash
Copy link

Even the example in index.d.ts comments doesn't compile:

const x = oc({
  c: [-100, 200, -300],
});
x.c.map(e => e()) === [-100, 200, -300];
// ^ Property 'map' does not exist on type 'TSOCType<number[]>'.

* x.c.map((e) => e()) === [-100, 200, -300]

@yeongjet
Copy link

got the same problem

@fwielstra
Copy link

The correct usage should be x.c().map(e => e()) === [-100, 200, -300];, which will unwrap the value from the ts-optchain proxy.

@dko-slapdash
Copy link
Author

I think in this case e() won’t work, because it’s already unwrapped by c(). So it has to be re-wrap, which is inconvenient.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants