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

Defer to rollup TS plugin to build types #1

Conversation

jednano
Copy link

@jednano jednano commented Sep 5, 2019

  1. No sense in having TS build the types when the TS rollup plugin is already doing it.
  2. Renamed index.ts to redux.ts so the types become redux.d.ts; thus, get picked up automatically by editors.

@cellog
Copy link
Owner

cellog commented Sep 5, 2019

The original PR used es/index.d.ts and this was nuked because there are several directories where source is output (es, lib, and then the browser builds). Can you explain why using lib/ is better than using es or putting into types?

@jednano
Copy link
Author

jednano commented Sep 5, 2019

Sure. The Rollup config is already using the TS plugin to dump types into es, lib and dist folders. That means we already have 3 copies of the exact same types. As such, building another types folder just adds a 4th copy, which is even more redundant and unnecessary.

As the types are verbatim the same between es, lib and dist folders, it doesn't entirely matter which redux.d.ts we point to. In fact, you don't technically need to define your types in package.json at all, because it will just look for your main entry for a .d.ts file adjacent to your main filename. If main points to lib/redux.js then it will automatically assume the types are in lib/redux.d.ts. My types entry just reflects that default behavior, which is recommended to do.

Also note that if your main declaration file is named index.d.ts and lives at the root of the package (next to index.js) you do not need to mark the "types" property, though it is advisable to do so.

https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#including-declarations-in-your-npm-package

@jednano
Copy link
Author

jednano commented Sep 5, 2019

Closing in favor of reduxjs#3564

@jednano jednano closed this Sep 5, 2019
@jednano jednano deleted the rollup-ts-types branch September 5, 2019 18:22
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