contentlayerdev / contentlayerdev/contentlayer

Enable specifying list type in computed fields

Offen
#277 2 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
improvement meta: never-stale topic: schema
Vorherrschende Sprache
TypeScript
Sterne
3.5k
Forks
192
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

As far as I can tell, it isn't possible to specify the `of` type of lists in computed fields the way that you can in non-computed fields. Thus, this is possible:

```typescript
fields: {
tags: {
type: "list",
of: { type: "string" },
default: []
}
}
```

But this is not:

```typescript
computedFields: {
segments: {
type: "list",
of: { type: "string" },
resolve: (doc) => { ... }
}
}
```

Instead, you can only specify an untyped list, and in the generated output you end up with this:

```typescript
segments: list
```

But this raw `list` type isn't defined!

There may be reasons to explicitly disallow typed lists in computed fields, and if so I'd be curious why! Otherwise, this feels like an oversight to me.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.