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

[Feature Request] El Table Column should carry type definition in default slot #3233

Open
ziw opened this issue Sep 4, 2021 · 13 comments
Open
Labels
inactive Quality::TypeScript Related this issue is related to type definition 🔨 Vue issue Issue caused by Vue. Can't do anything

Comments

@ziw
Copy link

ziw commented Sep 4, 2021

Existing Component

Yes

Component Name

El Table Column

Description

When using typescript and rendering a custom table column template like below

<template #default="scope">
  <span>{{ scope.row.date }}</span>
</template>

the scope.row does not carry any type definition. It should be able to infer from the data property passed into the table. i.e.

const tableData: User[] = [...];
<el-table :data="tableData" />

// in custom column template
<template #default="scope">
  <span>{{ scope.row.firstName }}</span>  //scope.row should carry type User for extensions like Volar to provide intellisense
</template>
@adaex
Copy link
Member

adaex commented Sep 4, 2021

Yes, this is a problem, are you interested in fixing it?

@adaex adaex added the Contribution::Help Wanted Extra attention is needed label Sep 4, 2021
@sxzz
Copy link
Collaborator

sxzz commented Sep 4, 2021

slot-scope has been deprecated in Vue 3

@ziw
Copy link
Author

ziw commented Sep 4, 2021

The snippet is copied from the official doc. But I'm actually using <template #default="scope">. Updated the issue.

@ziw
Copy link
Author

ziw commented Sep 4, 2021

@adaex will give it a try but may not have enough context. If anyone else wants to help, it's very appreciated.

@sxzz
Copy link
Collaborator

sxzz commented Sep 4, 2021

vuejs/rfcs#192

Vue doesn’t seem to implement this feature yet

@adaex
Copy link
Member

adaex commented Sep 4, 2021

Don't worry, go ahead and try it. There are many enthusiastic developers.

@ziw
Copy link
Author

ziw commented Sep 4, 2021

@sxzz Thanks. Good to know.. will follow the RFC.

@sxzz sxzz added Quality::TypeScript Related this issue is related to type definition and removed Contribution::Help Wanted Extra attention is needed labels Sep 10, 2021
@PiscineMolitorPatel
Copy link

关注到了这个问题,不仅仅是El Table Column,目前应该是所有带有 scope slot 的组件都没有类型支持,这对于 ts 项目开发有很大的影响,希望能尽快提交PR完善这个需求。

例如:

    <template #default="{ row: { type } }">
      {{ types[type] }} // types 是一个对象,这将导致 type 不能作为索引,因为它是一个 any,意味着我必须额外书写一个函数来实现
    </template>

@sxzz
Copy link
Collaborator

sxzz commented Sep 14, 2021

关注到了这个问题,不仅仅是El Table Column,目前应该是所有带有 scope slot 的组件都没有类型支持,这对于 ts 项目开发有很大的影响,希望能尽快提交PR完善这个需求。

例如:

    <template #default="{ row: { type } }">
      {{ types[type] }} // types 是一个对象,这将导致 type 不能作为索引,因为它是一个 any,意味着我必须额外书写一个函数来实现
    </template>

需要等待 Vue 支持。相关的 RFC 讨论 vuejs/rfcs#192

@sxzz
Copy link
Collaborator

sxzz commented Oct 2, 2021

@sxzz sxzz added the upstream label Nov 4, 2021
@sxzz sxzz added 🔨 Vue issue Issue caused by Vue. Can't do anything and removed upstream labels Dec 4, 2021
@a1mersnow
Copy link

There are defineSlots and Generic Type defineComponent since Vue 3.3.
I think we can do this now!

@Royce-DaDaDa
Copy link

Been wondering how's the process going on, is there anyone working on using defineSlots to define types for those slots ?

@a1mersnow
Copy link

a1mersnow commented Nov 30, 2023

First, we need to move to 3.3.
I tried to bump vue to 3.3, but while running tests, there are some weird errors like:

el[assignKey] is not a function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Quality::TypeScript Related this issue is related to type definition 🔨 Vue issue Issue caused by Vue. Can't do anything
Projects
None yet
Development

No branches or pull requests

6 participants