contentlayerdev / contentlayerdev/contentlayer

Enable specifying list type in computed fields

Đang mở
#277 2 bình luận 2 reaction 0 người được giao Xem trên GitHub
improvement meta: never-stale topic: schema
Ngôn ngữ chính
TypeScript
Star
3.5k
Fork
192
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.