contentlayerdev / contentlayerdev/contentlayer

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

未关闭
#26 3 条评论 5 个 reaction 已指派 0 人 在 GitHub 查看
feature pkg/source-files
主要语言
TypeScript
星标
3.5k
派生
192
PR 合并指标
30 天内没有已合并 PR

描述

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)

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。