-
Notifications
You must be signed in to change notification settings - Fork 94
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
Export Props interfaces to allow exported declarations #236
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 5ffaab2:
|
Codecov Report
@@ Coverage Diff @@
## next #236 +/- ##
=======================================
Coverage 98.58% 98.58%
=======================================
Files 8 8
Lines 424 424
Branches 148 148
=======================================
Hits 418 418
Misses 6 6
Continue to review full report at Codecov.
|
Otherwise we get: TS4023: Exported variable 'MyAsync' has or is using name 'PendingProps' from external module "<snip>/node_modules/react-async/dist-types/index" but cannot be named.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't hurt exposing those, so we can definitely do that.
But could you please share in which scenario you need those? Are you creating your own library with declarations wrapping react-async? Just for usage, I believe this would not be neccessary.
Thanks for the feedback @phryneas. I've got a monorepo where we're using Typescript project references and incremental builds which therefore generate declaration files. I've decided to separate the Async from the promiseFn, such that components can consume an Async without the implementation of the fetch also being in that library. This allows us to build our components independently of the data source (which could be IndexedDB or a remote system). So we have the following code in AsyncSessionData.tsx:
Which results in the following in AsyncSessionData.d.ts:
Which my previous PR would have solved had it not been that AsyncConstructor uses PendingProps etc. I've now got this behaving as needed with the exports in this PR |
Okay, that seems like a sensible use case. I take it you validated the codesandbox build now checks all your requirements? :) |
Yes. Currently have our build running successfully against the sandbox build for this PR. |
LGTM. It'll mean we have to do a major release when changing any of these, but I suspect that would be the case anyway. |
@all-contributors please add @nealeu for code. |
I've put up a pull request to add @nealeu! 🎉 |
Otherwise we get:
TS4023: Exported variable 'MyAsync' has or is using name 'PendingProps' from external module "/node_modules/react-async/dist-types/index" but cannot be named.