microsoft / microsoft/TypeScript
random error TS2345 type incompatible
Nobody has claimed this yet.
- 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
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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