Skip to content

Commit dbd8664

Browse files
committed
Do not report errors when inference is partially blocked
1 parent ed15865 commit dbd8664

4 files changed

+50
-1
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
14231423
let inlineLevel = 0;
14241424
let currentNode: Node | undefined;
14251425
let varianceTypeParameter: TypeParameter | undefined;
1426+
let isInferencePartiallyBlocked = false;
14261427

14271428
const emptySymbols = createSymbolTable();
14281429
const arrayVariances = [VarianceFlags.Covariant];
@@ -1824,7 +1825,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
18241825
} while (toMarkSkip && toMarkSkip !== containingCall);
18251826
getNodeLinks(containingCall).resolvedSignature = undefined;
18261827
}
1828+
isInferencePartiallyBlocked = true;
18271829
const result = fn();
1830+
isInferencePartiallyBlocked = false;
18281831
if (containingCall) {
18291832
let toMarkSkip = node!;
18301833
do {
@@ -32601,7 +32604,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3260132604
const isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression;
3260232605
const isDecorator = node.kind === SyntaxKind.Decorator;
3260332606
const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
32604-
const reportErrors = !candidatesOutArray;
32607+
const reportErrors = !isInferencePartiallyBlocked && !candidatesOutArray;
3260532608

3260632609
let typeArguments: NodeArray<TypeNode> | undefined;
3260732610

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)