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

fix(types): allow custom props define in functional components #9127

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/dts-test/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,15 @@ describe('function syntax w/ runtime props', () => {
)
})

describe('function syntax w/ allowed props', () => {
const Foo = defineComponent((props: { msg: string }, ctx) => {
return () => {}
})
expectType<JSX.Element>(
<Foo msg="hi" class={'str'} style={'str'} custom={1} />
)
})

// check if defineComponent can be exported
export default {
// function components
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/apiDefineComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function defineComponent<
emits?: E | EE[]
slots?: S
}
): (props: Props & EmitsToProps<E>) => any
): (props: Props & EmitsToProps<E> & PublicProps) => any
export function defineComponent<
Props extends Record<string, any>,
E extends EmitsOptions = {},
Expand Down