Skip to content

Commit

Permalink
fix(53919): Cannot read properties of undefined (reading 'flags') in …
Browse files Browse the repository at this point in the history
…returnValueCorrect (#53921)

Co-authored-by: everbits <everbitskiy@linkedin.com>
  • Loading branch information
egorio and everbits committed Jul 21, 2023
1 parent 7a1f97a commit 7194be0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/services/codefixes/returnValueCorrect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ function getInfo(checker: TypeChecker, sourceFile: SourceFile, position: number,
case Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code:
if (!declaration || !isCallExpression(declaration.parent) || !declaration.body) return undefined;
const pos = declaration.parent.arguments.indexOf(declaration as Expression);
if (pos === -1) return undefined;
const type = checker.getContextualTypeForArgumentAtIndex(declaration.parent, pos);
if (!type) return undefined;
return getFixInfo(checker, declaration, type, /*isFunctionType*/ true);
Expand Down
23 changes: 23 additions & 0 deletions tests/cases/fourslash/codeFixCorrectReturnValue28.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// <reference path='fourslash.ts' />

// @strict: true

// @Filename: test.ts
//// (function() {
//// const config = {
//// values: [],
//// value: {},
//// };
////
//// config.values.push(config.value);
//// }());

goTo.file('test.ts');

verify.getSemanticDiagnostics([{
code: 2345,
message: "Argument of type '{}' is not assignable to parameter of type 'never'.",
range: { pos: 91, end: 103,fileName: "test.ts" }
}]);

verify.not.codeFixAvailable();

0 comments on commit 7194be0

Please sign in to comment.