Skip to content

Commit baa058e

Browse files
committed
types: fix mergePlatformItems key type
1 parent 90134b8 commit baa058e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/core/src/context.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { CommentObject, CommentSymbol } from 'comment-json'
33
import type { Logger, ViteDevServer } from 'vite'
44
import type { TabBar, TabBarItem } from './config'
55
import type { PagesConfig } from './config/types'
6-
import type { PageMetaDatum, PagePath, ResolvedOptions, SubPageMetaDatum, UserOptions } from './types'
6+
import type { ExcludeIndexSignature, PageMetaDatum, PagePath, ResolvedOptions, SubPageMetaDatum, UserOptions } from './types'
77

88
import fs from 'node:fs'
99
import path from 'node:path'
@@ -437,7 +437,7 @@ export class PageContext {
437437
for (const existing of pageJson.subPackages as unknown as SubPageMetaDatum[]) {
438438
const sub = newSubPackages.get(existing.root)
439439
if (sub) {
440-
existing.pages = mergePlatformItems(existing.pages as unknown as CommentArray<CommentObject>, currentPlatform, sub.pages, 'path') as any
440+
existing.pages = mergePlatformItems(existing.pages as any, currentPlatform, sub.pages, 'path') as any
441441
newSubPackages.delete(existing.root)
442442
}
443443
}
@@ -512,7 +512,7 @@ function getPagePaths(dir: string, options: ResolvedOptions) {
512512
return pagePaths
513513
}
514514

515-
function mergePlatformItems<T = any>(source: CommentArray<CommentObject> | undefined, currentPlatform: string, items: T[], uniqueKeyName: keyof T): CommentArray<CommentObject> {
515+
function mergePlatformItems<T = any>(source: CommentArray<CommentObject> | undefined, currentPlatform: string, items: T[], uniqueKeyName: keyof ExcludeIndexSignature<T>): CommentArray<CommentObject> {
516516
const src = source || new CommentArray<CommentObject>()
517517
currentPlatform = currentPlatform.toUpperCase()
518518

packages/core/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ export interface PageMetaDatum {
139139
[x: string]: any
140140
}
141141

142+
export type ExcludeIndexSignature<T> = {
143+
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]
144+
}
145+
142146
export interface SubPageMetaDatum {
143147
root: string
144148
pages: PageMetaDatum[]

0 commit comments

Comments
 (0)