Skip to content

Export types from /server entrypoint#216

Open
rdsfj wants to merge 1 commit into
single-spa:mainfrom
rdsfj:export-types-from-server-entrypoint
Open

Export types from /server entrypoint#216
rdsfj wants to merge 1 commit into
single-spa:mainfrom
rdsfj:export-types-from-server-entrypoint

Conversation

@rdsfj

@rdsfj rdsfj commented Jan 27, 2025

Copy link
Copy Markdown

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.

Comment thread src/server/index.ts
// 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
Copy Markdown
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
Copy Markdown
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