Add an option to `createContextProvider` to throw an error instead of using a fallback in @solid-primitives/context
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- frontend
調査の方向性
createContextProvider のエントリーポイントから始め、現在の fallback 引数と生成される hook の戻り値の型を確認します。提案された config とエラー動作を比較し、その後、provider がない場合と fallback のケースを網羅します。完了条件は、provider がない場合に strict mode が例外をスローし、TypeScript で T を返し、既存の fallback 動作を維持することです。
索引モデルが issue の本文から書いたものです。
説明
Describe The Problem To Be Solved
Right now, if I want to use createContextProvider but maintain a strict "fail-fast" pattern (where it throws an error if used outside its provider). I either have to accept the T | undefined return type and manually wrap it with a null check, or I have to pass a dummy fallback object just to satisfy TypeScript, which actively hides the fact that the provider is missing. Since strict context is super common in Solid, support this would be a good idea.
Suggest A Solution
It would be awesome if the primitive natively supported strict mode. Maybe the second argument could be updated to accept a config object instead of just the fallback value, something like { fallback?: {...}, throws: ... }. The throws property could accept either a string for a standard error message, or even better, an Error class in case developers want to throw their own custom errors.
The ultimate goal is that the generated hook would automatically throw the error if the context is undefined, and the TypeScript return type would be strictly T without needing any extra wrapper hooks.
- 主要言語
- TypeScript
- スター
- 1.6k
- フォーク
- 162
- 平均マージ
- 19時間 40分
- マージ済み PR(30日)
- 8
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
solidjs-community/solid-primitives のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
solidjs-community/solid-primitives#1059 · コメント 1 件 ·
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
solidjs-community/solid-primitives#1000 · コメント 3 件 · リアクション 5 件 ·
-
help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 52/100
solidjs-community/solid-primitives#830 · コメント 2 件 ·
solidjs-community/solid-primitives の issue をすべて見る
似ている issue
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
Crush オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
ElementsProject/cln-application#167 · コメント 1 件 · リアクション 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Quantco/pnpm-licenses#17 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100