feat(types): deny unknown attributes on component by default (#1614)

close #1519
This commit is contained in:
HcySunYang
2020-07-17 23:43:28 +08:00
committed by GitHub
parent 77659fa037
commit 5d8a64d53a
11 changed files with 100 additions and 58 deletions

View File

@@ -71,8 +71,14 @@ export type VNodeHook =
| VNodeMountHook[]
| VNodeUpdateHook[]
export interface VNodeProps {
[key: string]: any
export interface ComponentCustomProps {}
export interface AllowedComponentProps {
class?: unknown
style?: unknown
}
// https://github.com/microsoft/TypeScript/issues/33099
export type VNodeProps = {
key?: string | number
ref?: VNodeRef
@@ -104,7 +110,11 @@ export type VNodeNormalizedChildren =
| RawSlots
| null
export interface VNode<HostNode = RendererNode, HostElement = RendererElement> {
export interface VNode<
HostNode = RendererNode,
HostElement = RendererElement,
ExtraProps = { [key: string]: any }
> {
/**
* @internal
*/
@@ -114,7 +124,7 @@ export interface VNode<HostNode = RendererNode, HostElement = RendererElement> {
*/
__v_skip: true
type: VNodeTypes
props: VNodeProps | null
props: (VNodeProps & ExtraProps) | null
key: string | number | null
ref: VNodeNormalizedRef | null
scopeId: string | null // SFC only
@@ -597,7 +607,7 @@ export function mergeProps(...args: (Data & VNodeProps)[]) {
const incoming = toMerge[key]
if (existing !== incoming) {
ret[key] = existing
? [].concat(existing as any, toMerge[key])
? [].concat(existing as any, toMerge[key] as any)
: incoming
}
} else {