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

Accurate argument and return types on all functions (issue #512) #513

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

qpwo
Copy link

@qpwo qpwo commented Oct 31, 2021

No description provided.

@qpwo qpwo force-pushed the more-detailed-types branch from ffd1c9d to c993cef Compare October 31, 2021 21:47
@qpwo qpwo marked this pull request as ready for review November 2, 2021 01:51
@qpwo
Copy link
Author

qpwo commented Nov 2, 2021

I think this is ready for review. There's some gaps but most of it is covered. I couldn't figure out a better way to get the exports right than making an index.js and index.d.ts, but there likely is a better way. There's some gaps still with monkey business and event listeners.

Also not sure about immutability – does anything happen if the function passed to apply() mutates data? Or if you mutate the result of .get() ?

@qpwo
Copy link
Author

qpwo commented Nov 2, 2021

Done making changes for the time being lmk what you think

@jrust
Copy link
Contributor

jrust commented Feb 1, 2022

I'm available to try this in our project if it would be helpful in moving it along. I did try bringing in the sbaobab.d.ts file, but typescript (v3.8.3) complained on a number of lines. For example:

[] | [number, ...FullPathsOf<Item>] # TS2574: A rest element type must be an array type.

and

export type FullDeepIndex<T, KS extends FullKeys> = # TS2456: Type alias 'FullDeepIndex' circularly references itself.

@qpwo
Copy link
Author

qpwo commented Feb 1, 2022

@jrust easiest thing is probably npm un baobab && npm i github:qpwo/baobab#more-detailed-types then import { SBaobab } from 'baobab'; const tree = new SBaobab<MyTreeType>(myData).

Option 2 is to @ts-ignore the errors in the .d.ts file since those errors are unfortunately unavoidable it seems. The resulting types from using that file I think are all good but the errors within the file itself annoying so just ignore them.

Option 3 is to try https://github.com/qpwo/dentata (npm install dentata) which I just published today actually - it's basically a limited subset of baobab meant to improve the typescript inferencability and be a bit faster potentially.

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

Successfully merging this pull request may close these issues.

2 participants