microsoft / microsoft/TypeScript

random error TS2345 type incompatible

Open
#39,711 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

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:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the error from packages/@lazy-glob/rename/lib/util/globGroupsCollection.ts at lines 130-149 with the reported TypeScript 3.7.x-dev version and a current version. Inspect the inferred type of the object passed to _groups.push and determine whether the diagnostic is reproducible; done requires a minimal reproduction or a confirmed compiler defect with an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.