Skip to content

Commit

Permalink
fix(types): attrs default type
Browse files Browse the repository at this point in the history
  • Loading branch information
rudyxu1102 committed Jan 4, 2023
1 parent e4f4369 commit cc506ce
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 26 deletions.
2 changes: 1 addition & 1 deletion packages/runtime-core/src/componentPublicInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export type ComponentPublicInstance<
Omit<P & PublicProps, keyof Defaults> &
Omit<Attrs, keyof (P & PublicProps)>
: P & PublicProps & Omit<Attrs, keyof (P & PublicProps)>
$attrs: Omit<Attrs, keyof (P & PublicProps)> & AllowedComponentProps
$attrs: Omit<Attrs, keyof (P & PublicProps)>
$refs: Data
$slots: Slots
$root: ComponentPublicInstance | null
Expand Down
13 changes: 0 additions & 13 deletions test-dts/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1315,19 +1315,6 @@ describe('define attrs', () => {
)
expectType<JSX.Element>(<MyComp foo="1" />)
})

test('define attrs w/ default attrs such as class, style', () => {
const MyComp = defineComponent({
props: {
foo: String
},
created() {
expectType<unknown>(this.$attrs.class)
expectType<unknown>(this.$attrs.style)
}
})
expectType<JSX.Element>(<MyComp class="1" style={1} />)
})
})

// #5948
Expand Down
12 changes: 0 additions & 12 deletions test-dts/defineCustomElement.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,4 @@ describe('define attrs', () => {
}
)
})

test('define attrs w/ default attrs such as class, style', () => {
defineCustomElement({
props: {
foo: String
},
created() {
expectType<unknown>(this.$attrs.class)
expectType<unknown>(this.$attrs.style)
}
})
})
})

0 comments on commit cc506ce

Please sign in to comment.