(checker, declaration, expectType, isFunctionType)
| 154476 | return checker.createAnonymousType(/*symbol*/ undefined, members, [], [], []); |
| 154477 | } |
| 154478 | function getFixInfo(checker, declaration, expectType, isFunctionType) { |
| 154479 | if (!declaration.body || !ts.isBlock(declaration.body) || ts.length(declaration.body.statements) !== 1) |
| 154480 | return undefined; |
| 154481 | var firstStatement = ts.first(declaration.body.statements); |
| 154482 | if (ts.isExpressionStatement(firstStatement) && checkFixedAssignableTo(checker, declaration, checker.getTypeAtLocation(firstStatement.expression), expectType, isFunctionType)) { |
| 154483 | return { |
| 154484 | declaration: declaration, |
| 154485 | kind: ProblemKind.MissingReturnStatement, |
| 154486 | expression: firstStatement.expression, |
| 154487 | statement: firstStatement, |
| 154488 | commentSource: firstStatement.expression |
| 154489 | }; |
| 154490 | } |
| 154491 | else if (ts.isLabeledStatement(firstStatement) && ts.isExpressionStatement(firstStatement.statement)) { |
| 154492 | var node = ts.factory.createObjectLiteralExpression([ts.factory.createPropertyAssignment(firstStatement.label, firstStatement.statement.expression)]); |
| 154493 | var nodeType = createObjectTypeFromLabeledExpression(checker, firstStatement.label, firstStatement.statement.expression); |
| 154494 | if (checkFixedAssignableTo(checker, declaration, nodeType, expectType, isFunctionType)) { |
| 154495 | return ts.isArrowFunction(declaration) ? { |
| 154496 | declaration: declaration, |
| 154497 | kind: ProblemKind.MissingParentheses, |
| 154498 | expression: node, |
| 154499 | statement: firstStatement, |
| 154500 | commentSource: firstStatement.statement.expression |
| 154501 | } : { |
| 154502 | declaration: declaration, |
| 154503 | kind: ProblemKind.MissingReturnStatement, |
| 154504 | expression: node, |
| 154505 | statement: firstStatement, |
| 154506 | commentSource: firstStatement.statement.expression |
| 154507 | }; |
| 154508 | } |
| 154509 | } |
| 154510 | else if (ts.isBlock(firstStatement) && ts.length(firstStatement.statements) === 1) { |
| 154511 | var firstBlockStatement = ts.first(firstStatement.statements); |
| 154512 | if (ts.isLabeledStatement(firstBlockStatement) && ts.isExpressionStatement(firstBlockStatement.statement)) { |
| 154513 | var node = ts.factory.createObjectLiteralExpression([ts.factory.createPropertyAssignment(firstBlockStatement.label, firstBlockStatement.statement.expression)]); |
| 154514 | var nodeType = createObjectTypeFromLabeledExpression(checker, firstBlockStatement.label, firstBlockStatement.statement.expression); |
| 154515 | if (checkFixedAssignableTo(checker, declaration, nodeType, expectType, isFunctionType)) { |
| 154516 | return { |
| 154517 | declaration: declaration, |
| 154518 | kind: ProblemKind.MissingReturnStatement, |
| 154519 | expression: node, |
| 154520 | statement: firstStatement, |
| 154521 | commentSource: firstBlockStatement |
| 154522 | }; |
| 154523 | } |
| 154524 | } |
| 154525 | } |
| 154526 | return undefined; |
| 154527 | } |
| 154528 | function checkFixedAssignableTo(checker, declaration, exprType, type, isFunctionType) { |
| 154529 | if (isFunctionType) { |
| 154530 | var sig = checker.getSignatureFromDeclaration(declaration); |
no test coverage detected