Open silasdavis opened 4 years ago
I haven't investigated yet but I wouldn't be surprised if this library breaks without strictNullChecks. I'll investigate ASAP and will either find a fix or add a disclaimer in the README.
Thanks for the report!
Let me know if I can help with this. Worth my while if it can be made to work.
I looked into this a bit, and it seems like it will be really tricky to get this working while keeping the library useful. I'm going to leave this open for a few more days in case I have an epiphany, but I don't think we're going to be able to get this working properly without --strictNullChecks.
Thank you for this project - I really like the approach.
I found that I could not get a fairly trivial example to compile in my project:
The use of
v
inv.payload
produces the error:TS2532: Object is possibly 'undefined'.
. If I checkv !== undefined
to narrow the type ofv
thenpayload
is inferred asnever
.After embedding this example in your tests (where it does work). It seems like the important piece of difference is that you have
strictNullChecks
enabled viastrict
intsconfig.json
.I assume that your type magic must rely on inference that needs there to not be implicit void types. I just wanted to check I am not missing something and this is in fact required since I did not see it mentioned anywhere. Is there a way round this? Perhaps I am mistaken to isolate it the issue to
strictNullChecks
(I can do a more careful isolation if needed).As a side-note I would like to enable
strict
mode in all my projects, but I want to use this library in a large system of projects that I am incrementally typing so it's not something I can easily turn on without refactoring large amounts of code.