contentlayerdev / contentlayerdev/contentlayer

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

オープン
#26 コメント 3 件 リアクション 5 件 担当者 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 を短くまとめたダイジェスト。