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

[DataTable] onSelect prop has a type broken #3430

Closed
nayurin opened this issue Aug 5, 2022 · 0 comments · Fixed by #3443
Closed

[DataTable] onSelect prop has a type broken #3430

nayurin opened this issue Aug 5, 2022 · 0 comments · Fixed by #3443
Labels
bug Something isn't working

Comments

@nayurin
Copy link

nayurin commented Aug 5, 2022

TuSimple/naive-ui version (版本)

2.32.1

Vue version (Vue 版本)

3.2.37

Browser and its version (浏览器及其版本)

Chrome(104.0.5112.79)

System and its version (系统及其版本)

macOS(12.5)

Node version (Node 版本)

v18.4.0

Reappearance link (重现链接)

https://codesandbox.io/s/infallible-carson-7ik425?file=/src/App.vue

Reappearance steps (重现步骤)

ide intellisense or execute npx vue-tsc --noEmit for a type check.

Expected results (期望的结果)

pageData could have a correctly predicted type.
at least avoid error on type checking.

Actual results (实际的结果)

type broken on both ide intellisense and pre-build type checking

Remarks (补充说明)

demo on source code and online documents:
(src/data-table/demos/zhCN/custom-select.demo.md:44)
(https://www.naiveui.com/zh-CN/os-theme/components/data-table#custom-select)
shows onSelect prop may have an argument pageData

{
  label: '选中前 2 行',
  key: 'f2',
  onSelect: (pageData) => {
    ...
  }
}

but the type definition on:
(src/data-table/src/interface.ts:167)
shows onSelect prop should be a function like onSelect: () => void rather than onSelect: (pageData: InternalRowData[]) => void

this will occur an error on running the type checking with vue-tsc --noEmit:
TS2322: Type '(pageData: any[]) => void' is not assignable to type '() => void'.

@github-actions github-actions bot added the untriaged need to sort label Aug 5, 2022
@XieZongChen XieZongChen added bug Something isn't working and removed untriaged need to sort labels Aug 7, 2022
07akioni added a commit to 07akioni/naive-ui-fork that referenced this issue Aug 7, 2022
07akioni added a commit to 07akioni/naive-ui-fork that referenced this issue Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants