From: Stanislav <62983943+stanislavstrelnikov@users.noreply.github.com> Date: Sun, 19 Jul 2020 02:56:28 +0000 (+0300) Subject: chore(types): convert type literals to records (#1615) X-Git-Tag: v3.0.0-rc.2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa5ddf8d065eab22c79fe486c2f3335bdba30e26;p=thirdparty%2Fvuejs%2Fcore.git chore(types): convert type literals to records (#1615) --- diff --git a/packages/compiler-dom/src/decodeHtml.ts b/packages/compiler-dom/src/decodeHtml.ts index 3d9823c630..b28592d95c 100644 --- a/packages/compiler-dom/src/decodeHtml.ts +++ b/packages/compiler-dom/src/decodeHtml.ts @@ -102,7 +102,7 @@ export const decodeHtml: ParserOptions['decodeEntities'] = ( } // https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state -const CCR_REPLACEMENTS: { [key: number]: number | undefined } = { +const CCR_REPLACEMENTS: Record = { 0x80: 0x20ac, 0x82: 0x201a, 0x83: 0x0192, diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index c621d0f161..621d8ae6b4 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -51,7 +51,7 @@ import { import { startMeasure, endMeasure } from './profiling' import { componentAdded } from './devtools' -export type Data = { [key: string]: unknown } +export type Data = Record // Note: can't mark this whole interface internal because some public interfaces // extend it. diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index e0814c74b2..5e4c2c0541 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -80,7 +80,7 @@ type InferPropType = T extends null : T extends { type: null | true } ? any // As TS issue https://github.com/Microsoft/TypeScript/issues/14829 // somehow `ObjectConstructor` when inferred from { (): T } becomes `any` // `BooleanConstructor` when inferred from PropConstructor(with PropMethod) becomes `Boolean` : T extends ObjectConstructor | { type: ObjectConstructor } - ? { [key: string]: any } + ? Record : T extends BooleanConstructor | { type: BooleanConstructor } ? boolean : T extends Prop ? V : T diff --git a/packages/runtime-core/src/devtools.ts b/packages/runtime-core/src/devtools.ts index 6e62ee76ea..24fb23a31c 100644 --- a/packages/runtime-core/src/devtools.ts +++ b/packages/runtime-core/src/devtools.ts @@ -6,7 +6,7 @@ export interface AppRecord { id: number app: App version: string - types: { [key: string]: string | Symbol } + types: Record } enum DevtoolsHooks { diff --git a/packages/runtime-core/src/vnode.ts b/packages/runtime-core/src/vnode.ts index 30b5c240ad..f477933ab8 100644 --- a/packages/runtime-core/src/vnode.ts +++ b/packages/runtime-core/src/vnode.ts @@ -214,7 +214,7 @@ export function setBlockTracking(value: number) { */ export function createBlock( type: VNodeTypes | ClassComponent, - props?: { [key: string]: any } | null, + props?: Record | null, children?: any, patchFlag?: number, dynamicProps?: string[]