add `IsNothing()` type guard

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

メンテナーはふだん 4 日以内に返信

@unional がすでに取り組んでいます。

2022年10月30日 から。

  • #989 @unional による — オープン

評価

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

調査の方向性

この issue ではソースファイル、テストファイル、エントリポイントが特定されていないため、まずリポジトリ内で既存の Nothing 型と、それに関連する型のテストを探してください。guard が説明どおりに string | Nothing | undefined のユニオンを絞り込むことを確認し、期待される制御フローの型を示すテストを追加してください。

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

説明

proposal

🚀 Feature Proposal

Add IsNothing() type guard that can exclude Nothing from a union type.

Motivation

The following does not work:

let x: string | Nothing | undefined

if (x === nothing) {
  // x type should be `Nothing`
}
else {
  // x type should be string
}

Since the Nothing type is implemented as a class, the x === nothing will not remove the Nothing type from the control flow analysis.

Adding a IsNothing() type guard will solve this problem.

Can this be solved in user-land code?

I can implement that easily in user-land, but this is a core concept of immer and IMO should live inside immer.

I can contribute to the project. Just want to know which file should I add the tests to.

主要言語
JavaScript
スター
29k
フォーク
905
平均マージ
3日 16時間
マージ済み PR(30日)
22

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

immerjs/immer のほかの issue

immerjs/immer の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

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

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