Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Improve error handling for polymorphic field data with missing type value

オープン
#297 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
typescript
領域
data

調査の方向性

packages/@contentlayer/core/src/generation/generate-dotpkg.ts から始め、特に idToFileName とその周辺の makeDataExportFile フローを確認してください。TypeScript の多相なネストされたリストの例を再現し、欠落している型の値がどのように生成処理に到達するかを追跡し、そのケースで、報告されている undefined.replace TypeError ではなく、有用なハンドリング済みエラーが発生することを確認してください。

索引モデルが issue の本文から書いたものです。

説明

good first issue help wanted meta: never-stale topic: error-handling

I encountered an error with following code trying to add polymorphic nested objects to a list.

export const Link = defineNestedType(() => ({
    name: "Link",
    description: "Link to an external resource",
    fields: {
        text: {
            type: "string",
            required: true,
        },
        url: {
            type: "string",
            required: true,
        },
    },
}));

export const LinkList = defineNestedType(() => ({
    name: "LinkList",
    description: "List of links to external resources",
    fields: {
        text: {
            type: "string",
            required: true,
        },
        links: {
            type: "list",
            required: true,
            of: Link,
        },
    },
}));

export const NavbarLinks = defineDocumentType(() => ({
    name: "NavbarLinks",
    filePathPattern: "core/navbarLinks.json",
    isSingleton: true,
    fields: {
        links: {
            type: "list",
            of: [Link, LinkList],
            required: true,
        },
    },
}));

This produces following stack trace

TypeError: Cannot read properties of undefined (reading 'replace')
    at idToFileName (file://.../node_modules/@contentlayer/core/src/generation/generate-dotpkg.ts:389:89)
    at makeDataExportFile (file://.../node_modules/@contentlayer/core/src/generation/generate-dotpkg.ts:291:53)
    at file://.../node_modules/@contentlayer/core/src/generation/generate-dotpkg.ts:153:18
    at Array.map (<anonymous>)
    at next (file://.../node_modules/@contentlayer/core/src/generation/generate-dotpkg.ts:152:44)
    at Generator.next (<anonymous>)
    at ApplyFrame.apply (file://.../node_modules/@effect-ts/system/_src/Effect/gen.ts:148:36)
    at FiberContext.nextInstr (file://.../node_modules/@effect-ts/system/_src/Fiber/context.ts:357:28)
    at FiberContext.evaluateNow (file://.../node_modules/@effect-ts/system/_src/Fiber/context.ts:940:36)
    at file://.../node_modules/@effect-ts/system/_src/Fiber/context.ts:576:33

Fiber: #17 (started at: 2022-09-04T21:49:21.161Z) was supposed to continue to:

  a future continuation at packages/@contentlayer/core/src/generation/generate-dotpkg.ts:216:13

Fiber: #17 (started at: 2022-09-04T21:49:21.161Z) Execution trace:

  packages/@contentlayer/core/src/generation/generate-dotpkg.ts:144:22
  packages/@contentlayer/core/src/generation/generate-dotpkg.ts:143:60
  packages/@contentlayer/core/src/generation/generate-dotpkg.ts:125:10
  packages/@contentlayer/core/src/generation/generate-dotpkg.ts:82:13
  packages/@contentlayer/core/src/generation/generate-dotpkg.ts:78:16
主要言語
TypeScript
スター
3.5k
フォーク
192
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

contentlayerdev/contentlayer のほかの issue

contentlayerdev/contentlayer の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。