|
|
@@ -98,6 +98,13 @@ import type { RendererElement } from './renderer'
|
|
|
|
|
|
export type Data = Record<string, unknown>
|
|
|
|
|
|
+/**
|
|
|
+ * For extending allowed non-declared attrs on components in TSX
|
|
|
+ */
|
|
|
+export interface AllowedAttrs {}
|
|
|
+
|
|
|
+export type Attrs = Data & AllowedAttrs
|
|
|
+
|
|
|
/**
|
|
|
* Public utility type for extracting the instance type of a component.
|
|
|
* Works with all valid component definition types. This is intended to replace
|
|
|
@@ -283,7 +290,7 @@ export type SetupContext<
|
|
|
S extends SlotsType = {},
|
|
|
> = E extends any
|
|
|
? {
|
|
|
- attrs: Data
|
|
|
+ attrs: Attrs
|
|
|
slots: UnwrapSlotsType<S>
|
|
|
emit: EmitFn<E>
|
|
|
expose: <Exposed extends Record<string, any> = Record<string, any>>(
|
|
|
@@ -1152,13 +1159,13 @@ export function createSetupContext(
|
|
|
if (__DEV__) {
|
|
|
// We use getters in dev in case libs like test-utils overwrite instance
|
|
|
// properties (overwrites should not be done in prod)
|
|
|
- let attrsProxy: Data
|
|
|
+ let attrsProxy: Attrs
|
|
|
let slotsProxy: Slots
|
|
|
return Object.freeze({
|
|
|
get attrs() {
|
|
|
return (
|
|
|
attrsProxy ||
|
|
|
- (attrsProxy = new Proxy(instance.attrs, attrsProxyHandlers))
|
|
|
+ (attrsProxy = new Proxy(instance.attrs, attrsProxyHandlers) as Attrs)
|
|
|
)
|
|
|
},
|
|
|
get slots() {
|
|
|
@@ -1171,7 +1178,7 @@ export function createSetupContext(
|
|
|
})
|
|
|
} else {
|
|
|
return {
|
|
|
- attrs: new Proxy(instance.attrs, attrsProxyHandlers),
|
|
|
+ attrs: new Proxy(instance.attrs, attrsProxyHandlers) as Attrs,
|
|
|
slots: instance.slots,
|
|
|
emit: instance.emit,
|
|
|
expose,
|