Skip to content

Commit

Permalink
🐛 fix: 修正类型定义
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Jan 17, 2023
1 parent 80087ae commit 8a7d053
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/demos/cases/MacSelect/ScrollArrow/style.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createStyles, css } from 'antd-style';

export const useStyles = createStyles(({ token, cx }, prefixCls) => ({
export const useStyles = createStyles(({ token, cx }, prefixCls: string) => ({
container: cx(
prefixCls,
css`
Expand Down
2 changes: 1 addition & 1 deletion docs/demos/cases/MacSelect/Select/style.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createStyles } from 'antd-style';

export const useStyles = createStyles(({ css, cx, token }, prefixCls) => ({
export const useStyles = createStyles(({ css, cx, token }, prefixCls: string) => ({
container: cx(
prefixCls,
css`
Expand Down
10 changes: 6 additions & 4 deletions src/functions/createStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export interface ReturnStyles<T extends StyleInputType> {
}

// 获取样式
export type GetStyleFn<Input extends StyleInputType, Props> = <P extends Props>(
export type GetStyleFn<Input extends StyleInputType, Props> = (
theme: CreateStylesTheme,
props?: P,
props: Props,
) => Input;

/**
Expand All @@ -45,7 +45,9 @@ export type StyleOrGetStyleFn<Input extends StyleInputType, Props> =
* 业务应用中创建样式基础写法
*/
export const createStyles =
<Props, Input extends StyleInputType>(styleOrGetStyleFn: StyleOrGetStyleFn<Input, Props>) =>
<Props, Input extends StyleInputType = StyleInputType>(
styleOrGetStyleFn: StyleOrGetStyleFn<Input, Props>,
) =>
(props?: Props): ReturnStyles<Input> => {
const theme = useTheme();

Expand All @@ -55,7 +57,7 @@ export const createStyles =
if (styleOrGetStyleFn instanceof Function) {
const { stylish, appearance, ...token } = theme;

tempStyles = styleOrGetStyleFn({ token, stylish, appearance, cx, css }, props) as any;
tempStyles = styleOrGetStyleFn({ token, stylish, appearance, cx, css }, props!) as any;
} else {
tempStyles = styleOrGetStyleFn as any;
}
Expand Down

0 comments on commit 8a7d053

Please sign in to comment.