contentlayerdev / contentlayerdev/contentlayer

Enable specifying list type in computed fields

Aperta
#277 2 commenti 2 reazioni 0 assegnatari Vedi su GitHub
improvement meta: never-stale topic: schema
Lingua principale
TypeScript
Stelle
3.5k
Fork
192
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.