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

Export types from /server entrypoint #216

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rdsfj
Copy link

@rdsfj rdsfj commented Jan 27, 2025

Hello,

as suggested in #214, here's the MR to add type definitions for the package's /server entrypoint.
It follows the existing approach of the default entrypoint by adding single-spa-layout-server-interface.ts that reexports JS values and adds some type exports.

@@ -1,3 +1,3 @@
// This file exists so that typescript understands the following:
// import 'single-spa-layout/server'
export * from "../single-spa-layout-server";
export * from "../single-spa-layout-server-interface";
Copy link
Member

Choose a reason for hiding this comment

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

Why create a separate single-spa-layout-server-interface file rather than add the exports to src/server/index.ts?

Copy link
Author

Choose a reason for hiding this comment

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

The types for the package's /server entry point are located in ./dist/types/single-spa-layout-server.d.ts, as specified in the package.json file.

As far as I can tell, the src/server/index.ts file is not used by TypeScript, which means we cannot rely solely on it for type definitions. However, it's possible that older versions of TypeScript might still use src/server/index.ts. I don't know about that, but after all the file was certainly added for a reason.

In the end, I followed the same approach as with the package's default entry point by creating the single-spa-layout-server-interface file. Additionally, I added the rexport in src/server/index.ts to be on the safe side for older TypeScript versions.

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