Skip to content

fix: export symbol and interface to fix type exporting in consuming packages #1

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

Closed
wants to merge 3 commits into from

Conversation

wyattberlinic
Copy link

@wyattberlinic wyattberlinic commented Nov 25, 2021

I'm trying to use the library and I get TS4023.

Exported variable 'promiseAction' has or is using name 'promiseSymbol' from external module ".../git/saga-test/node_modules/@teroneko/redux-saga-promise/dist/src/index" but cannot be named.

Minimal example:

const promiseAction = promiseActionFactory<string>().simple<string>('ACTION');
export { promiseAction };

See microsoft/TypeScript#37888 (comment) for a discussion of the solution.

If I export these types then I have no issues.

@teneko
Copy link
Owner

teneko commented Nov 25, 2021

Hey. Okay, let's investigate this. Currently promiseSymbol's only purpose is to to be used to infer the resolve value type of the promise. It is NOT intended to be ever used in productive code or in other words: they symbol should just lying around without being used once in the view of JavaScript. 😄

The symbol should only serve as unique path in the language system of TypeScript to store custom types. I already spotted the problematic line: https://github.com/teroneko/redux-saga-promise/blob/f1b5cd6e23215b36e4fbfd74999c6321e6008413/src/index.ts#L124

I appreciate your effort but this drastic solution to export everything is really the last resort. I will report back when the fix has been introduced.

@wyattberlinic
Copy link
Author

So, I think an alternative solution is to ensure that symbol is not in any of the exported types. It might be possible to do some type surgery on the exported types/functions to eliminate that symbol from the public API.

@teneko
Copy link
Owner

teneko commented Nov 25, 2021

So I have done. Version 1.2.3 has been published. Can you take a look?

@wyattberlinic
Copy link
Author

Seems to have solved my problem, thank you!

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