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

Tab Pane slots type seems to be incorrect #6696

Open
5 tasks done
weeks6 opened this issue Jan 9, 2025 · 5 comments · May be fixed by #6690
Open
5 tasks done

Tab Pane slots type seems to be incorrect #6696

weeks6 opened this issue Jan 9, 2025 · 5 comments · May be fixed by #6690
Labels
untriaged need to sort

Comments

@weeks6
Copy link

weeks6 commented Jan 9, 2025

Describe the bug

Docs state these as available slots for TabPane:

  • default
  • tab

yet the type is

export interface TabPaneSlots { default?: () => VNode[]; prefix?: () => VNode[]; suffix?: () => VNode[]; }

Steps to reproduce

not relevant

Link to minimal reproduction

not relevant

System Info

not relevant

Used Package Manager

npm

Validations

@weeks6 weeks6 added the untriaged need to sort label Jan 9, 2025
@zsjbsn
Copy link

zsjbsn commented Jan 13, 2025

I have the same problem.

@weeks6
Copy link
Author

weeks6 commented Jan 13, 2025

I have the same problem.

My current workaround to make typescript happy is to wrap the slot markup in a render function and pass it as a :tab prop, hope it helps, but render functions are annoying and I hope the issue gets resolved sooner than later

@zsjbsn
Copy link

zsjbsn commented Jan 14, 2025

@weeks6

I have the same problem.

My current workaround to make typescript happy is to wrap the slot markup in a render function and pass it as a :tab prop, hope it helps, but render functions are annoying and I hope the issue gets resolved sooner than later

It is hard to me. Maybe it will be fixed in next version. I want to wait for it.

@foolishflyfox
Copy link

when I update naive-ui version from 2.40.3 to 2.41.0,compile will fail, back to 2.40.3 is ok

@jahnli jahnli linked a pull request Jan 25, 2025 that will close this issue
@cardonamarc
Copy link

cardonamarc commented Feb 6, 2025

My workaround is to augment TabPaneSlots interface through Typescript's module augmentation:
In, for example, ./src/@types/naive-ui.d.ts:

/* ./src/@types/naive-ui.d.ts */

declare module 'naive-ui/es/tabs/src/TabPane' {
  export interface TabPaneSlots {
    tab?: () => VNode[]
    default?: () => VNode[]
  }
}

If it's not working, make sure that your tsconfig.json is including this file in the include attribute or in compilerOptions.typeRoots attribute, for example:

/* ./tsconfig.json */

{
  // Make sure your file is included
  "include": [..., "src/**/*"] // Will include all files under src directory

  // Or define compilerOptions.typeRoots
  "compilerOptions": {
    "typeRoots": [..., "./src/@types"]
  } 
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged need to sort
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants