rimeto/ts-optchain

Problem with properties of type 'any'

Closed this issue · 4 comments

I have been unable to access children of properties that have type 'any':

Property does not exist on type 'OCType'.
Property does not exist on type 'IDataAccessor'.

Example: https://stackblitz.com/edit/ts-optchain-any

It will be good if it can be fixed. In the meantime, maybe you can use this workaround?:

import { oc } from 'ts-optchain';

const testVar: {a: any} = { a: { b: 'some value', c: 'hi' } };

const a: any = oc(testVar).a;
console.log(a.b());

https://stackblitz.com/edit/ts-optchain-any-aawyvi?file=index.ts

I quickly tried this out (#28), working as expected. Looking forward to a release where this is included!

released!