Skip to content

Commit 7194be0

Browse files
egorioeverbits
andauthored
fix(53919): Cannot read properties of undefined (reading 'flags') in returnValueCorrect (#53921)
Co-authored-by: everbits <[email protected]>
1 parent 7a1f97a commit 7194be0

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/services/codefixes/returnValueCorrect.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ function getInfo(checker: TypeChecker, sourceFile: SourceFile, position: number,
219219
case Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code:
220220
if (!declaration || !isCallExpression(declaration.parent) || !declaration.body) return undefined;
221221
const pos = declaration.parent.arguments.indexOf(declaration as Expression);
222+
if (pos === -1) return undefined;
222223
const type = checker.getContextualTypeForArgumentAtIndex(declaration.parent, pos);
223224
if (!type) return undefined;
224225
return getFixInfo(checker, declaration, type, /*isFunctionType*/ true);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @strict: true
4+
5+
// @Filename: test.ts
6+
//// (function() {
7+
//// const config = {
8+
//// values: [],
9+
//// value: {},
10+
//// };
11+
////
12+
//// config.values.push(config.value);
13+
//// }());
14+
15+
goTo.file('test.ts');
16+
17+
verify.getSemanticDiagnostics([{
18+
code: 2345,
19+
message: "Argument of type '{}' is not assignable to parameter of type 'never'.",
20+
range: { pos: 91, end: 103,fileName: "test.ts" }
21+
}]);
22+
23+
verify.not.codeFixAvailable();

0 commit comments

Comments
 (0)