Skip to content

Commit

Permalink
fix: type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
outloudvi committed May 14, 2023
1 parent 8180494 commit d740b05
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/parts/choiceGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
14 changes: 11 additions & 3 deletions src/utils/pick.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ArgValueType, ArgValueTypeMap, RawCommand } from '../types'
import type { Arg, ArgValueType, ArgValueTypeMap, RawCommand } from '../types'

function checkType(
value: ArgValueType,
Expand Down Expand Up @@ -28,7 +28,11 @@ export function tryPickFirst<T extends keyof ArgValueTypeMap>(
}

export function pickFirst<T extends keyof ArgValueTypeMap>(
c: RawCommand | Record<string, any>,
c:
| RawCommand
| {
args: Arg[]
},
key: string,
assertType: T
): ArgValueTypeMap[T] {
Expand All @@ -43,7 +47,11 @@ export function pickFirst<T extends keyof ArgValueTypeMap>(
}

export function pickMany<T extends keyof ArgValueTypeMap>(
c: RawCommand | Record<string, any>,
c:
| RawCommand
| {
args: Arg[]
},
key: string,
assertType: T
): ArgValueTypeMap[T][] {
Expand Down

0 comments on commit d740b05

Please sign in to comment.