-
Notifications
You must be signed in to change notification settings - Fork 20
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
fix(types): emit and publish type definitions to npm #243
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 52b9233:
|
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.
Thanks for your work @etienne-martin !
I made a small change to separate the tsconfig
file in two different configurations (one for type checking and one for declaration file generation) so we keep the original behavior for the yarn type-check
command.
Beside that it seems good to me 🙂
Great, thank you! |
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.
@etienne-martin Thank you for your contribution 🎉
For the record, I've run yarn lint && yarn test && yarn type-check && yarn build
on my computer, since the community PRs are not run by CircleCI.
// shim for node modules in React Native | ||
// see https://github.com/facebook/react-native/issues/5079 | ||
type empty = {}; | ||
export default empty; |
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.
do these not get generated by the tsc, instead, what if we gitignore it?
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.
They don't because index-node.cjs.js
, index-browser.cjs.js
and empty-module.cjs.js
live outside of the ./lib
folder and are plain JavaScript files.
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.
not sure what you mean
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.
The package.json points to these entry files, and TypeScript will look for the equivalent but with the .d.ts
extension.
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.
Ideally I'd get rid of those files sitting at the root of the project and point the package.json to the entry points in the ./dist
folder but I didn't want to change everything.
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.
I mean that tsc generates these files at publish time, why do they need to be committed on git?
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.
and are plain JavaScript files.
I see now, makes sense! in the future they should be moved to ts
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.
Got it. I will work on it next time.
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.
Another thing is, I'd use the ts-expect
package against the build output to test that the types are emitted properly. That would ensure that the chain package.json --> enty-*.js --> entry-*.d.ts
is working properly.
Because right now, there are unit test for the source code, but there's nothing that checks that the build output is in good health.
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.
Wasn't aware of that. Thanks for the information. I will check it out :)
Related to this issue: #9
./dist
folder usingtsc
.npm publish
ornpm pack
.