`collection().columns` should allow `array` fields (runtime works, types reject them)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript
調査の方向性
dist/declarations/src/config.d.ts の生成された宣言から始め、collection() の columns オプションのソース宣言を見つけます。既存の scalar フィールドと slug フィールドの型制約を確認し、array フィールドが受け入れられる一方で、サポートされていないフィールドが引き続き拒否されることを検証します。利用可能であれば、プロジェクトの TypeScript チェックまたは型テストスイートで完了を確認します。
索引モデルが issue の本文から書いたものです。
説明
Problem
We want to show an array field in a collection list view via the columns option. For example, a list of external project slugs so editors can see at a glance which entries are linked to another system:
steckbriefe: collection({
label: 'Steckbriefe',
slugField: 'slug',
path: 'src/data/steckbriefe/*/',
format: { data: 'yaml' },
columns: ['title', 'state', 'trassenscoutProjectSlugs', 'lastCheckedDate'],
schema: {
title: fields.text({ label: 'Titel', validation: { isRequired: true } }),
trassenscoutProjectSlugs: fields.array(fields.text({ label: 'Trassenscout slug' }), {
label: 'Trassenscout',
itemLabel: (props) => props.value || 'Slug',
}),
// ...
},
}),
Runtime: This works. The Admin UI renders array column values by stringifying them (val + ''), so ['rs8', 'rs8-north'] shows as rs8,rs8-north and [] shows as empty.
Types: TypeScript rejects trassenscoutProjectSlugs in columns because collection() only allows keys whose schema field is a scalar FormField or SlugFormField:
// dist/declarations/src/config.d.ts (current)
columns?: {
[K in keyof Schema]: Schema[K] extends
| FormField<any, any, string | number | boolean | Date | null | undefined>
| SlugFormField<any, any, any, string>
? K & string
: never;
}[keyof Schema][];
ArrayField (kind: 'array') is excluded even though the list view handles it fine.
Expected behavior
Array fields should be valid in columns, since the collection table already displays them.
Actual behavior
- Admin UI: works
- TypeScript: error —
Type '"trassenscoutProjectSlugs"' is not assignable to type ...
Suggested fix
Extend the columns mapped type to also allow ArrayField keys:
columns?: {
[K in keyof Schema]: Schema[K] extends
| FormField<any, any, string | number | boolean | Date | null | undefined>
| SlugFormField<any, any, any, string>
? K & string
: Schema[K] extends { kind: 'array' }
? K & string
: never;
}[keyof Schema][];
Environment
@keystatic/core: 0.5.50@keystatic/astro: 5.1.0- TypeScript: 6.x
- Package manager: Bun 1.3
Workarounds (until upstream fix)
Option A: @ts-expect-error (minimal)
steckbriefe: collection({
// Keystatic renders array columns as comma-separated values; types only allow scalars.
// @ts-expect-error array field used as list column
columns: ['title', 'state', 'trassenscoutProjectSlugs', 'lastCheckedDate'],
schema: {
trassenscoutProjectSlugs: fields.array(fields.text({ label: 'Trassenscout slug' }), {
label: 'Trassenscout',
}),
// ...
},
}),
Option B: Patch @keystatic/core (what we use)
We patch the published type definition so columns accepts array fields without suppressions.
1. Start a patch (Bun):
bun patch @keystatic/core
2. Edit node_modules/@keystatic/core/dist/declarations/src/config.d.ts:
columns?: {
- [K in keyof Schema]: Schema[K] extends FormField<any, any, string | number | boolean | Date | null | undefined> | SlugFormField<any, any, any, string> ? K & string : never;
+ [K in keyof Schema]: Schema[K] extends FormField<any, any, string | number | boolean | Date | null | undefined> | SlugFormField<any, any, any, string> ? K & string : Schema[K] extends {
+ kind: 'array';
+ } ? K & string : never;
}[keyof Schema][];
3. Commit the patch:
bun patch --commit 'node_modules/@keystatic/core'
This creates patches/@keystatic%[email protected] and adds to package.json:
"patchedDependencies": {
"@keystatic/[email protected]": "patches/@keystatic%[email protected]"
}
Bun reapplies the patch on every bun install. After upgrading @keystatic/core, regenerate the patch for the new version.
- 主要言語
- TypeScript
- スター
- 2.4k
- フォーク
- 164
- 平均マージ
- 5時間 46分
- マージ済み PR(30日)
- 3
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Thinkmill/keystatic のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
Typo/Grammar on Website Homepage対応中かも @Punith1117 が 128 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
Thinkmill/keystatic の issue をすべて見る
似ている issue
-
component:sight
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
agentic-os-org/ANOLISA#6738 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug Durable Agents Observability (AI Telemetry) status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
mastra-ai/mastra#26470 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
paperclipai/paperclip#15630 ·
メンテナーはふだん 1 日以内に返信
-
[good first issue, hacktoberfest] ⛩️ Add new Theme: Sakura Latte (good-first-issue)対応中かも @PGrayCS が今日担当しました。 オープンcommunity first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
lingdojo/kana-dojo#31937 · コメント 1 件 · リアクション 5 件 ·
メンテナーはふだん 1 日以内に返信
-
feature/cohorts feature/feature-flags team/feature-flags
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信