Skip to content

Add a exports/types field to package.json#3975

Merged
ryanking13 merged 1 commit intopyodide:mainfrom
khill-fbmc:patch-1
Jul 5, 2023
Merged

Add a exports/types field to package.json#3975
ryanking13 merged 1 commit intopyodide:mainfrom
khill-fbmc:patch-1

Conversation

@khill-fbmc
Copy link
Copy Markdown
Contributor

Forgive me if this isn't right, but don't we need to export the types as well?

Description

I was having trouble in VSCode with no type hints

Solution

Add "types": "./pyodide.d.ts" to the exports definition.

Forgive me if this isn't right, but don't we need to export the types as well?
@ryanking13
Copy link
Copy Markdown
Member

Thanks, but I think we have top-level types field which works for TypeScript I think. Is there a difference between setting types inside exports and setting it globally?

"types": "./pyodide.d.ts"

@khill-fbmc
Copy link
Copy Markdown
Contributor Author

khill-fbmc commented Jul 5, 2023

Here is a small reproduction of what I encountered:

When hovering, it gives the suggestion to modify the package.json

image

So I gave that a shot, and it cleared the error and gave me proper types:

image

image

Copy link
Copy Markdown
Member

@ryanking13 ryanking13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the repro @khill-fbmc! After reading the typescript docs, it looks like this is the right change.

@ryanking13 ryanking13 changed the title Update package.json Add a exports/types field to package.json Jul 5, 2023
@ryanking13 ryanking13 merged commit 1012a3f into pyodide:main Jul 5, 2023
@khill-fbmc khill-fbmc deleted the patch-1 branch July 5, 2023 13:22
@khill-fbmc
Copy link
Copy Markdown
Contributor Author

Happy to help :) This is a really cool project!

@hoodmane
Copy link
Copy Markdown
Member

hoodmane commented Jul 5, 2023

Thanks @khill-fbmc!

hoodmane pushed a commit to hoodmane/pyodide that referenced this pull request Jul 5, 2023
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.

3 participants