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

类型定义冲突 #7

Closed
usercao opened this issue Jan 13, 2022 · 17 comments
Closed

类型定义冲突 #7

usercao opened this issue Jan 13, 2022 · 17 comments

Comments

@usercao
Copy link

usercao commented Jan 13, 2022

image
类型定义名称theme asstyled-components起冲突,最小实例地址:https://github.com/usercao/ice-test

@MinJieLiu
Copy link
Owner

看来得换名字咯

@MinJieLiu
Copy link
Owner

theme 不冲突, as 可以用 forwardedAs 代替

@MinJieLiu
Copy link
Owner

image

@MinJieLiu
Copy link
Owner

theme 还是换个名字吧,表现形式还不一样

@usercao
Copy link
Author

usercao commented Jan 27, 2022

自定义滚动条宽度和固定的滚动容器高度[例如select里防止继续resize高度]可以考虑下

@MinJieLiu
Copy link
Owner

固定的容器高度[select里防止继续resize高度] 场景体现在哪里,select 高度会一直 resize 吗

@usercao
Copy link
Author

usercao commented Jan 28, 2022

固定的容器高度[select里防止继续resize高度] 场景体现在哪里,select 高度会一直 resize 吗

我的错,我猜的会不会有这个问题,因为没有细滚动条还没写过select

@MinJieLiu
Copy link
Owner

@usercao
Copy link
Author

usercao commented Mar 1, 2022

@MinJieLiu forwardedAs没搞明白如何使用,我这样使用会触发TS类型错误

<Scrollbar forwardedAs='ul'>
  <div style={{ height: 2000 }}>{children}</div>
</Scrollbar>
const Wrapper = styled(MacScrollbar)<ScrollbarProps>`
  height: inherit;
`;

const Scrollbar: React.FC<ScrollbarProps> = (props: ScrollbarProps) => {
  const { forwardedAs,children, ...rest } = props;
  return (
    <Wrapper forwardedAs={'li'} {...rest}>
      {children}
    </Wrapper>
  );
};

最小实例地址https://github.com/usercao/ice-test

@usercao
Copy link
Author

usercao commented Mar 1, 2022

image

同时新版下会有如下警告

@MinJieLiu
Copy link
Owner

image
我觉得这是 vite 的问题,因为 在导出的 css 中提供了 map 文件,vite 没有正确解析

@MinJieLiu
Copy link
Owner

vitejs/vite#659

@usercao
Copy link
Author

usercao commented Mar 1, 2022

vitejs/vite#659

感谢🙏我明白了,请问可以看一下forwardedAs为什么类型错误吗?

@MinJieLiu
Copy link
Owner

有仓库吗

@usercao
Copy link
Author

usercao commented Mar 1, 2022

有仓库吗

https://github.com/usercao/ice-test 就是这个仓库里面的components->scrollbar组件
在layouts->BasicLayout里面引用了

@MinJieLiu
Copy link
Owner

const Scrollbar: React.FC<ScrollbarProps> = (props: ScrollbarProps) => {
  const { as, children, ...rest } = props;
  return (
    <Wrapper forwardedAs={as as keyof JSX.IntrinsicElements} {...rest}>
      {children}
    </Wrapper>
  );
};

@usercao
Copy link
Author

usercao commented Mar 1, 2022

@MinJieLiu 非常感谢🙏我TS写的有点少不好意思😂

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

2 participants