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

table pagination position typescript type is wrong, document is Array, such as ['bottomRight'] #24409

Closed
1 task
mizhousoft opened this issue May 23, 2020 · 8 comments
Labels
🤔 Need Reproduce We cannot reproduce your problem

Comments

@mizhousoft
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

https://ant.design/components/table-cn/

Steps to reproduce

const pagination = {
position: ['bottomLeft']
}

let locale = getTableLocale(fetchStatus)

return (
<Table loading={loading} columns={columns} dataSource={dataSources.content}
pagination={pagination} rowKey={record => record.id} size="middle" bordered locale={locale} />
)

What is expected?

typescript project does not report the error

What is actually happening?

error : 不能将类型“string[]”分配给类型“TablePaginationPosition[]”。

Environment Info
antd 4.2.4
React 16.13.1
System windows
Browser chrome 83
@ant-design-bot
Copy link
Contributor

Hello @vmwell. Please provide a online reproduction by forking this link https://u.ant.design/codesandbox-repro or a minimal GitHub repository. Issues labeled by Need Reproduce will be closed if no activities in 7 days.

你好 @vmwell, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。7 天内未跟进的 issue 将会被自动关闭。

@afc163 afc163 added the 🤔 Need Reproduce We cannot reproduce your problem label May 23, 2020
@mizhousoft
Copy link
Author

@ant-design-bot I know, but open the webpage too slow, no vpn

@afc163
Copy link
Member

afc163 commented May 23, 2020

You can choose to provide a minimal GitHub repository.

@mizhousoft
Copy link
Author

@afc163 GitHub repository: https://github.com/vmwell/antd-demo

Table define in App.tsx file

@keithort
Copy link

@afc163 Here is a codesandbox repo of the issue:
repo

@afc163
Copy link
Member

afc163 commented May 29, 2020

- position: ["bottomLeft"]
+ position: ["bottomLeft" as "bottomLeft"]

You can try this as workaround now.

@mizhousoft
Copy link
Author

it is ok, thanks.

@afc163 afc163 reopened this May 30, 2020
@zombieJ
Copy link
Member

zombieJ commented May 30, 2020

It's not a antd bug. Typescript will tread as string[] when not define its type. So any const will make TS covert:

position: ["bottomLeft" as const]

ref https://www.typescriptlang.org/play?#code/C4TwDgpgBACg9gZwDIEsHCgXigCgOQA2EAZsHlAD5R4BOKA5gBZkCUA2gLoDcAUDwMZwAduigBDLFDaESZcQiiCRwbnyWiARgC54yNBmxjeA4QjhEAdATj0cGllyA

Or you can just reuse pagination define:

const pagination: TableProps<any>['pagination'] = {
  position: ['bottomLeft'],
};

const table = <Table pagination={pagination} />;

@zombieJ zombieJ closed this as completed May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤔 Need Reproduce We cannot reproduce your problem
Projects
None yet
Development

No branches or pull requests

5 participants