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: explicitly add types to exports #576

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

LukasHeimann
Copy link
Contributor

The types are exported and should be able to be used by library consumers. However, when these consumers use recommended TypeScript moduleResolution setting "node16" (https://www.typescriptlang.org/tsconfig#moduleResolution), that will force the resolution to follow what is declared in the exports section of package.json -- where an explicit export of the types is currently missing.

Note that this is different from the types field at the top-level of package.json, which is a legacy mechanism for the old module resolution (this comment explains it pretty well for a different project, which dropped support for the legacy approach: typescript-eslint/typescript-eslint#7186 (comment)).

As wdi5 is released with dual packaging (commonjs + esm), and both version should support typescript, keeping the top-level types field around makes sense. This is also what the wdio-reporter plugin does: https://github.com/webdriverio/webdriverio/blob/d3e494d089d0545cf14ca88043d9599eaf98fa53/packages/wdio-reporter/package.json#L35

They even go a step further and have subpath exports combined with the conditional exports that wdi5 has at the moment (see https://nodejs.org/api/packages.html#subpath-exports and https://nodejs.org/api/packages.html#conditional-exports). Given that in my project, the conditional export only approach works fine, I have opted to not add the subpath variant as well in this PR.

@LukasHeimann
Copy link
Contributor Author

Tested against a local project of mine (npm link), where this resolved the issue of importing the types in my code.

package.json Show resolved Hide resolved
@vobu vobu merged commit 1d827b9 into ui5-community:main Jan 15, 2024
3 checks passed
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