microsoft / microsoft/TypeScript

random error TS2345 type incompatible

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

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

Needs Investigation
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

TypeScript Version: 3.7.x-dev.201xxxxx

Search Terms:

Code

https://github.com/bluelovers/ws-glob/blob/fa6b1f033b353065dda276e524c680a81ee8c36d/packages/%40lazy-glob/rename/lib/util/globGroupsCollection.ts#L130-L149

		this._globPartsArray.forEach((g: IPartsPattern, idx) =>
		{
			// Use matches[idx + 1] because whole match is at index 0 of the array of matches
			if (g === EnumWildcard.Asterisk || g === EnumWildcard.QuestionMark)
			{
				this._groups.push(Object.freeze({
					type: EnumPartsAstType.wildcard,
					pattern: g,
					match: matches[idx + 1],
				}));
			}
			else
			{
				this._groups.push(Object.freeze({
					type: EnumPartsAstType.literal,
					pattern: g,
					match: matches[idx + 1],
				}));
			}
		});

Expected behavior:

no error by random happen

Actual behavior:

bandicam 2020-07-23 09-49-14-211.zip

Error:(143, 23) TS2345: Argument of type 'Readonly<{ type: EnumPartsAstType; pattern: string; match: string; }>' is not assignable to parameter of type 'Error | IAsterisk | IQuestionMark | ILiteral'.
  Type 'Readonly<{ type: EnumPartsAstType; pattern: string; match: string; }>' is not assignable to type 'ILiteral'.
    Types of property 'type' are incompatible.
      Type 'EnumPartsAstType' is not assignable to type 'EnumPartsAstType.literal'.

Playground Link:

Related Issues:

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

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

はじめの一歩

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

調査の方向性

まず、報告された TypeScript 3.7.x-dev バージョンと現行バージョンを使って、packages/@lazy-glob/rename/lib/util/globGroupsCollection.ts の 130-149 行目にあるエラーを再現します。_groups.push に渡されるオブジェクトの推論された型を調べ、診断が再現可能かどうかを判断します。完了の条件は、最小限の再現例、または適切なテストを伴うコンパイラの不具合の確認です。

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

評価

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

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

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