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

Fix TypeScript declaration for sync module #58

Closed
wants to merge 1 commit into from

Conversation

benmccann
Copy link
Contributor

I added sync.d.ts in #54, but missed that we can't have two declaration files because package.json refers explicitly to index.d.ts:

"types": "./index.d.ts"

This also cuts down on code duplication

@lukeed
Copy link
Collaborator

lukeed commented Nov 19, 2020

Unfortunately I don;t think this works either. I've had my fair share of this issue because most of my modules have a secondary "mode"

The only thing I've found to work consistently is:

/sync
  |- index.js
  |- index.mjs (optional)
  |- index.d.ts
index.js (main)
index.mjs (optional)
index.d.ts (main definitions)

@benmccann
Copy link
Contributor Author

What do you do with the types field in package.json in that case? It can only refer to one file, so I'm not sure how you'd have index.d.ts and sync/index.d.ts

@benmccann
Copy link
Contributor Author

I just tested this three different ways:

  • the code in master - works just fine
  • the way you suggested - works just fine
  • this PR - doesn't work

It's very surprising to me that package.json has this types field that doesn't seem necessary and doesn't seem to have an effect. I'll go ahead and close this since things are working as is. Thanks for the extra set of eyes on this

@benmccann benmccann closed this Nov 20, 2020
@lukeed
Copy link
Collaborator

lukeed commented Nov 20, 2020

To answer your question, you just define "types" as the root/main mode. /sync/index.d.ts gets loaded automatically via the /sync import

It's all very weird and loose

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.

None yet

2 participants