From d740b0579b5e9f70976ded200509d4867622c124 Mon Sep 17 00:00:00 2001 From: Outvi V Date: Sun, 14 May 2023 13:02:11 +0800 Subject: [PATCH] fix: type errors --- package.json | 2 +- src/parts/choiceGroup.ts | 2 +- src/utils/pick.ts | 14 +++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ac27d7c..846fed0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hoshimei/adv", - "version": "0.7.0", + "version": "0.7.1", "description": "Aipura adv reader.", "scripts": { "bundle": "bash scripts/build.sh", diff --git a/src/parts/choiceGroup.ts b/src/parts/choiceGroup.ts index daeb6a5..97ae662 100644 --- a/src/parts/choiceGroup.ts +++ b/src/parts/choiceGroup.ts @@ -8,7 +8,7 @@ export default function read(t: RawCommand): ChoiceGroup { return { _t: 'ChoiceGroup', choices: pickMany(t, 'choices', 'object').map((x) => - pickFirst(x, 'text', 'string') + pickFirst(x as RawCommand, 'text', 'string') ), startTime: pickObject(clip, '_startTime', 'number'), duration: pickObject(clip, '_duration', 'number'), diff --git a/src/utils/pick.ts b/src/utils/pick.ts index 1c7b3a6..9e526a4 100644 --- a/src/utils/pick.ts +++ b/src/utils/pick.ts @@ -1,4 +1,4 @@ -import type { ArgValueType, ArgValueTypeMap, RawCommand } from '../types' +import type { Arg, ArgValueType, ArgValueTypeMap, RawCommand } from '../types' function checkType( value: ArgValueType, @@ -28,7 +28,11 @@ export function tryPickFirst( } export function pickFirst( - c: RawCommand | Record, + c: + | RawCommand + | { + args: Arg[] + }, key: string, assertType: T ): ArgValueTypeMap[T] { @@ -43,7 +47,11 @@ export function pickFirst( } export function pickMany( - c: RawCommand | Record, + c: + | RawCommand + | { + args: Arg[] + }, key: string, assertType: T ): ArgValueTypeMap[T][] {