Skip to content

Commit 879dbcd

Browse files
authored
Do not report errors when inference is partially blocked (#52728)
1 parent 4b534dc commit 879dbcd

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
14271427
let inlineLevel = 0;
14281428
let currentNode: Node | undefined;
14291429
let varianceTypeParameter: TypeParameter | undefined;
1430+
let isInferencePartiallyBlocked = false;
14301431

14311432
const emptySymbols = createSymbolTable();
14321433
const arrayVariances = [VarianceFlags.Covariant];
@@ -1839,7 +1840,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
18391840
toMarkSkip = toMarkSkip.parent;
18401841
} while (toMarkSkip && toMarkSkip !== containingCall);
18411842
}
1843+
1844+
isInferencePartiallyBlocked = true;
18421845
const result = runWithoutResolvedSignatureCaching(node, fn);
1846+
isInferencePartiallyBlocked = false;
1847+
18431848
if (containingCall) {
18441849
let toMarkSkip = node!;
18451850
do {
@@ -32667,7 +32672,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3266732672
const isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression;
3266832673
const isDecorator = node.kind === SyntaxKind.Decorator;
3266932674
const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
32670-
const reportErrors = !candidatesOutArray;
32675+
const reportErrors = !isInferencePartiallyBlocked && !candidatesOutArray;
3267132676

3267232677
let typeArguments: NodeArray<TypeNode> | undefined;
3267332678

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
///<reference path="fourslash.ts"/>
2+
// @strict: true
3+
////
4+
//// declare function func<T extends { foo: 1 }>(arg: T): void;
5+
//// func({ foo: 1, bar/*1*/: 1 });
6+
7+
goTo.marker("1");
8+
verify.completions({ exact: undefined });
9+
verify.noErrors();
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
///<reference path="fourslash.ts"/>
2+
// @strict: true
3+
////
4+
//// // repro from #50818#issuecomment-1278324638
5+
////
6+
//// declare function func<T extends { foo: 1 }>(arg: T): void;
7+
//// func({ foo: 1, bar/*1*/: 1 });
8+
9+
goTo.marker("1");
10+
edit.insert("2");
11+
verify.completions({ exact: undefined });
12+
verify.noErrors();
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
///<reference path="fourslash.ts"/>
2+
// @strict: true
3+
////
4+
//// // repro from #52580#issuecomment-1416131055
5+
////
6+
//// type Funcs<A, B extends Record<string, unknown>> = {
7+
//// [K in keyof B]: {
8+
//// fn: (a: A, b: B) => void;
9+
//// thing: B[K];
10+
//// }
11+
//// }
12+
////
13+
//// function foo<A, B extends Record<string, unknown>>(fns: Funcs<A, B>) {}
14+
////
15+
//// foo({
16+
//// bar: { fn: (a: string, b) => {}, thing: "asd" },
17+
//// /*1*/
18+
//// });
19+
20+
goTo.marker("1");
21+
const markerPosition = test.markers()[0].position;
22+
edit.paste(`bar: { fn: (a: string, b) => {}, thing: "asd" },`)
23+
edit.replace(markerPosition + 4, 1, 'z')
24+
verify.completions({ isNewIdentifierLocation: true });
25+
verify.noErrors();

0 commit comments

Comments
 (0)