-
Notifications
You must be signed in to change notification settings - Fork 486
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
TS editor inference and autocomplete doesn't seem to work. #2775
Comments
It seems to work correctly if you add |
similar reported issue microsoft/TypeScript#28009 |
I think I've hit a bit of a dead end here. A few possible solutions:
Any other ideas for this or have anyone ran into this? cc @matuzalemsteles @wincent |
It seems to me @andresfulla reported something about autocomplete in #2235 not 100% sure if it's related though. |
Using FWIW, I think the appeal of avoiding importing the entire namespace may be more theoretical than practical: even if you do tree-shaking, real apps end up using just about all of React somewhere, so treating it as a monolithic bundle is probably not as bad as it sounds. |
Fun fact: I remember talking about this back in February so I went back to see if anything had changed about the way React declares its exports. It's still the same (React master, still b87aabd, ReactDOM master, still b87aabd) and I guess will be for the foreseeable future. |
Hmm that's weird, why would using |
By switching to use I am going to test a different route and see if I can just get away with using |
Essentially the type definitions are being generated with import React from 'react';
export declare type DisplayType = 'primary' | 'secondary' | 'link' | 'unstyled';
interface IProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
borderless?: boolean;
block?: boolean;
displayType?: DisplayType;
monospaced?: boolean;
outline?: boolean;
small?: boolean;
}
declare const _default: React.ForwardRefExoticComponent<IProps & React.RefAttributes<HTMLButtonElement>> & {
Group: React.FunctionComponent<import("./Group").IButtonGroupProps>;
};
export default _default; When this definition gets loaded into a project without If I remove import * as React from 'react';
export declare type DisplayType = 'primary' | 'secondary' | 'link' | 'unstyled';
interface IProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
borderless?: boolean;
block?: boolean;
displayType?: DisplayType;
monospaced?: boolean;
outline?: boolean;
small?: boolean;
}
declare const _default: React.ForwardRefExoticComponent<IProps & React.RefAttributes<HTMLButtonElement>> & {
Group: React.FunctionComponent<import("./Group").IButtonGroupProps>;
};
export default _default; This then works correctly in a project consuming Clay without having to set The only different is the |
I believe this PR should fix this issue. Its just a matter of discussion if we want to actually go this route of removing Note: the CSB build doesnt pick up types, but I think that is an issue with their CI. I tried to build and use the package locally and it worked fine. |
Excellent detective work! 🕵 |
Hmm, this is still strange to me, why am I wondering why the editor is not getting the types from |
@matuzalemsteles I don't think we would have any difference for tree shaking purposes, plus im not even sure we utilize and tree shaking at the moment. One thing to note is that we would have to do this for all packages that we normally just take the default import. See this pr, #2816, for changes required. |
@bryceosterhaus Yeah, no problem for me. |
reopening because of #2851 |
I'm closing this because this doesn't seem to be a problem for the developer anymore, we also added an improvement in the types to provide the descriptions of the props recently #4836. In case this is still an issue for the Storybook environment, jest, and development I will open this again or create a new issue to keep it on top. |
Check out the example below. The
antd
library correctly allows users to autocomplete its value fortype
. The ClayButton does not work for autocompleting values. Note this is in the editor, not related to the UI.https://codesandbox.io/s/sad-panini-o3oez
The text was updated successfully, but these errors were encountered: