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

TypeScript offers to import ad-hok functions from lib #79

Open
peterstuart opened this issue Dec 1, 2021 · 0 comments
Open

TypeScript offers to import ad-hok functions from lib #79

peterstuart opened this issue Dec 1, 2021 · 0 comments

Comments

@peterstuart
Copy link
Collaborator

peterstuart commented Dec 1, 2021

In a fresh file, the first suggestion TS makes for where to import some (but not all) functions is from ad-hok/lib/* rather than ad-hok. See this example:

2021-12-01-175252_897x190_scrot

In my editor (Emacs + lsp-mode), this makes it very easy to import the functions from the incorrect place, as accepting the autocomplete suggestion as you type the function name will automatically add the wrong import.

Also, the type of the functions if you import from the wrong place is incorrect. This seems to be the difference between the type of the actual function vs the "Published" type:

declare type AddWrapperPublishedType = <TAdditionalProps, TProps>(callback: AddWrapperCallback<TAdditionalProps, TProps>) => CurriedPropsAdder<TProps, TAdditionalProps>;
export declare const addWrapper: <TProps, TAdditionalProps>(callback: AddWrapperCallback<TAdditionalProps, TProps>) => (Component: React.ComponentType<TProps & TAdditionalProps>) => (props: TProps) => ReactElement | null;
declare const addWrapperPublishedType: AddWrapperPublishedType;

The lib version imports addWrapper directly, while the correct addWrapper import has the type of AddWrapperPublishedType.

I don't know if it's possible to control this, but it'd be nice to hint to TS that it should never import the "lib" versions of the functions.

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

No branches or pull requests

1 participant