contentlayerdev / contentlayerdev/contentlayer

Support referencing TS type definitions for `type: 'json'` fields

Đang mở
#26 3 bình luận 5 reaction 0 người được giao Xem trên GitHub
feature pkg/source-files
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ả

In some cases where you're using `type: 'json'` you'd like to reference some existing TS type definitions instead of the `any` type that's currently used for `json` fields. This applies to both regular `fields` and `computedFields`.

Example:

![image](https://user-images.githubusercontent.com/1567498/140750539-bb4b8f33-517a-4afd-bfdc-df2a767c2767.png)

Rough API idea:

```ts
{
// ...
typescriptType: { name: 'IReadTimeResults', from: 'reading-time' }
}
```

## Notes

- A potential other direction/idea for this could be to "derive" nested document types based on existing TS types. (Would address #149)

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.