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

Fixed TS issues when used with single-spa-react #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/dom-element-getter-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ type AllProps<ExtraProps = {}> = AppProps &
appName?: string;
};

interface HelperOpts {
domElementGetter?(): HTMLElement;
interface HelperOpts<ExtraProps = {}> {
domElementGetter?(props?: ExtraProps): HTMLElement;
Copy link
Member

Choose a reason for hiding this comment

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

Hmm I think this should be more than just the extra props - also the AppProps. This is because the single-spa props get merged with the extra props to form the final props.

Suggested change
domElementGetter?(props?: ExtraProps): HTMLElement;
domElementGetter?(props?: ExtraProps & AppProps): HTMLElement;

See code below for AppProps.

https://github.com/single-spa/single-spa/blob/e63af429ad676fa2468af08b076ee154ebaa42be/typings/single-spa.d.ts#L12

Looking at the single-spa-react types, I'm not sure it's doing that part correct either, with RootComponentProps not including the sinlge-spa AppProps. So it's possible that updating the code in dom-element-getter-helpers to use AppProps causes issues with single-spa-react, in which case I think I'd prefer trying to fix both places.

}

export function chooseDomElementGetter<ExtraProps = {}>(
opts: HelperOpts,
opts: HelperOpts<ExtraProps>,
props: AllProps<ExtraProps>
): () => HTMLElement {
let domElementGetter;
Expand Down