We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
component.d.ts
import { DefineComponent, RenderFunction, SetupContext, } from '@vue/runtime-core'; export declare type Emits<T> = { [K in keyof T as `on${Capitalize<K & string>}`]?: T[K]; }; export declare type KeyNames<T> = { [K in keyof T]: `${K & string}`; }[keyof T]; export declare interface DefineComponentOption<P, E, R> { name?: string; props?: Array<KeyNames<P>> | Record<KeyNames<P>, any>; emits?: Array<KeyNames<E>> | Record<KeyNames<P>, any>; setup?: ( props: Readonly<P>, ctx: SetupContext<Required<E>>, ) => R | RenderFunction; } export declare function defineComponent<P, E, R = Record<string, unknown>>( options: DefineComponentOption<P, E, R>, ): DefineComponent<P & Emits<E>, R>;
example Button.tsx
export interface ButtonProps { label?: string; } export interface ButtonEmits { click: (value?: string) => void; close: () => void; } export default defineComponent({ name: 'Button', props: ['label'], emits: ['click', 'close'], setup(props: ButtonProps, { emit }: SetupContext<ButtonEmits>) { return () => (<></>); }, });
VButton.tsx
import { ButtonProps , ButtonEmits } form './Button'; export interface VButtonProps extends ButtonProps { color?: string; } export interface VButtonEmits extends Omit<ButtonEmits, 'close'> {} export default defineComponent({ name: 'VButton', props: ['label','color'], emits: ['click'], setup(props: VButtonProps, { emit }: SetupContext<VButtonEmits>) { return () => (<></>); }, });
The text was updated successfully, but these errors were encountered:
duplicate of #4294 ?
Sorry, something went wrong.
not script-setup
Duplicate of #4408
Please, take the time to explain what you are trying to achieve instead of just copy-pasting big chunks or code and letting maintainers try to guess.
No branches or pull requests
What problem does this feature solve?
component.d.ts
What does the proposed API look like?
example
Button.tsx
VButton.tsx
The text was updated successfully, but these errors were encountered: