Skip to content

Commit

Permalink
fix(types): ensure this.$props type does not include string (#12123)
Browse files Browse the repository at this point in the history
close #12122
  • Loading branch information
jh-leong authored Oct 11, 2024
1 parent d9d4d4e commit 704173e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages-private/dts-test/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2068,3 +2068,13 @@ expectString(instance.actionText)
// public prop on $props should be optional
// @ts-expect-error
expectString(instance.$props.actionText)

// #12122
defineComponent({
props: { foo: String },
render() {
expectType<{ readonly foo?: string }>(this.$props)
// @ts-expect-error
expectType<string>(this.$props)
},
})
2 changes: 1 addition & 1 deletion packages/runtime-core/src/apiDefineComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export function defineComponent<
Mixin,
Extends,
ResolvedEmits,
RuntimeEmitsKeys,
{},
{},
false,
InjectOptions,
Expand Down

0 comments on commit 704173e

Please sign in to comment.