From f87871d03f4154ac58519ccfef87773738cdedc6 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 27 Mar 2023 22:41:17 +0000 Subject: [PATCH 1/2] Don't list every type in the world in the error message. --- src/compiler/checker.ts | 9 ++------- src/compiler/diagnosticMessages.json | 6 +----- src/services/codefixes/returnValueCorrect.ts | 6 ++---- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8d9311a087d26..94fa9abf88fd0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -35664,7 +35664,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const functionFlags = getFunctionFlags(func); const type = returnType && unwrapReturnType(returnType, functionFlags); - // Functions with an explicitly specified 'undefined, 'void', 'any' or 'unknown' return type don't need any return expressions. + // Functions with an explicitly specified 'undefined, 'void', 'any', or 'unknown' return type don't need any return expressions. if (type && maybeTypeOfKind(type, TypeFlags.Undefined | TypeFlags.Void | TypeFlags.Any | TypeFlags.Unknown)) { return; } @@ -35684,12 +35684,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { else if (type && !hasExplicitReturn) { // minimal check: function has syntactic return type annotation and no explicit return statements in the body // this function does not conform to the specification. - if (strictNullChecks) { - error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value); - } - else { - error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); - } + error(errorNode, Diagnostics.A_function_with_this_return_type_needs_to_explicitly_return_a_value); } else if (type && strictNullChecks) { error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 7ceffb97001ab..3ee32dc7ff1bf 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1880,10 +1880,6 @@ "category": "Error", "code": 2354 }, - "A function whose declared type is neither 'void' nor 'any' must return a value.": { - "category": "Error", - "code": 2355 - }, "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type.": { "category": "Error", "code": 2356 @@ -3619,7 +3615,7 @@ "category": "Error", "code": 2846 }, - "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value.": { + "A function with this return type needs to explicitly return a value.": { "category": "Error", "code": 2847 }, diff --git a/src/services/codefixes/returnValueCorrect.ts b/src/services/codefixes/returnValueCorrect.ts index fe9499d89d42b..e7a759cfef33d 100644 --- a/src/services/codefixes/returnValueCorrect.ts +++ b/src/services/codefixes/returnValueCorrect.ts @@ -51,8 +51,7 @@ const fixIdAddReturnStatement = "fixAddReturnStatement"; const fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody"; const fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen"; const errorCodes = [ - Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code, - Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code, + Diagnostics.A_function_with_this_return_type_needs_to_explicitly_return_a_value.code, Diagnostics.Type_0_is_not_assignable_to_type_1.code, Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code ]; @@ -214,8 +213,7 @@ function getInfo(checker: TypeChecker, sourceFile: SourceFile, position: number, const declaration = findAncestor(node.parent, isFunctionLikeDeclaration); switch (errorCode) { - case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code: - case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code: + case Diagnostics.A_function_with_this_return_type_needs_to_explicitly_return_a_value.code: if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node)) return undefined; return getFixInfo(checker, declaration, checker.getTypeFromTypeNode(declaration.type), /*isFunctionType*/ false); case Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code: From 82650b851b0e5c8235f8eff5051bfcdcf6abf454 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 27 Mar 2023 23:57:36 +0000 Subject: [PATCH 2/2] Accepted baselines. --- .../reference/ParameterList5.errors.txt | 4 ++-- .../asyncFunctionDeclaration15_es5.errors.txt | 8 ++++---- .../asyncFunctionDeclaration15_es6.errors.txt | 8 ++++---- .../conflictingTypeAnnotatedVar.errors.txt | 8 ++++---- .../reference/controlFlowGenericTypes.errors.txt | 4 ++-- ...errorOnContextuallyTypedReturnType.errors.txt | 4 ++-- .../errorOnFunctionReturnType.errors.txt | 12 ++++++------ .../functionImplementationErrors.errors.txt | 4 ++-- ...singReturnStatementsAndExpressions.errors.txt | 12 ++++++------ ...entsAndExpressionsStrictNullChecks.errors.txt | 8 ++++---- .../reference/invalidReturnStatements.errors.txt | 16 ++++++++-------- .../jsdocFunction_missingReturn.errors.txt | 4 ++-- .../jsdocOuterTypeParameters2.errors.txt | 4 ++-- .../reference/methodInAmbientClass1.errors.txt | 4 ++-- .../reference/missingReturnStatement.errors.txt | 4 ++-- .../reference/missingReturnStatement1.errors.txt | 4 ++-- .../reference/multiLineErrors.errors.txt | 4 ++-- .../parseInvalidNonNullableTypes.errors.txt | 8 ++++---- .../parserErrorRecovery_Block3.errors.txt | 8 ++++---- .../reference/parserParameterList5.errors.txt | 4 ++-- .../reference/reachabilityChecks5.errors.txt | 4 ++-- .../reference/reachabilityChecks7.errors.txt | 4 ++-- .../reference/recursiveFunctionTypes.errors.txt | 8 ++++---- .../reference/returnTypeParameter.errors.txt | 4 ++-- 24 files changed, 76 insertions(+), 76 deletions(-) diff --git a/tests/baselines/reference/ParameterList5.errors.txt b/tests/baselines/reference/ParameterList5.errors.txt index 618ce74091527..b5ab4cd9052f7 100644 --- a/tests/baselines/reference/ParameterList5.errors.txt +++ b/tests/baselines/reference/ParameterList5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/ParameterList5.ts(1,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/ParameterList5.ts(1,15): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/compiler/ParameterList5.ts(1,16): error TS2369: A parameter property is only allowed in a constructor implementation. tests/cases/compiler/ParameterList5.ts(1,29): error TS2304: Cannot find name 'C'. @@ -6,7 +6,7 @@ tests/cases/compiler/ParameterList5.ts(1,29): error TS2304: Cannot find name 'C' ==== tests/cases/compiler/ParameterList5.ts (3 errors) ==== function A(): (public B) => C { ~~~~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. ~~~~~~~~ !!! error TS2369: A parameter property is only allowed in a constructor implementation. ~ diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration15_es5.errors.txt index 7e3595ec6f4e0..66927f2c7b45a 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration15_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es5.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(6,23): error TS1055: Type '{}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(6,23): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(6,23): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(7,23): error TS1055: Type 'any' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(8,23): error TS1055: Type 'number' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(8,23): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(8,23): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(9,23): error TS1055: Type 'PromiseLike' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(10,23): error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. Construct signature return types 'Thenable' and 'PromiseLike' are incompatible. @@ -22,7 +22,7 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 ~~~ !!! error TS1055: Type '{}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. ~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. async function fn3(): any { } // error ~~~ !!! error TS1055: Type 'any' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. @@ -30,7 +30,7 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 ~~~~~~ !!! error TS1055: Type 'number' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. async function fn5(): PromiseLike { } // error ~~~~~~~~~~~~~~~~~ !!! error TS1055: Type 'PromiseLike' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt index 5b054a616893a..0e588d57a87da 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(6,23): error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise<{}>'? -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(6,23): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(6,23): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(7,23): error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(8,23): error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(8,23): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(8,23): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(9,23): error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(10,23): error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(17,16): error TS1058: The return type of an async function must either be a valid promise or must not contain a callable 'then' member. @@ -19,7 +19,7 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 ~~~ !!! error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise<{}>'? ~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. async function fn3(): any { } // error ~~~ !!! error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? @@ -27,7 +27,7 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 ~~~~~~ !!! error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. async function fn5(): PromiseLike { } // error ~~~~~~~~~~~~~~~~~ !!! error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? diff --git a/tests/baselines/reference/conflictingTypeAnnotatedVar.errors.txt b/tests/baselines/reference/conflictingTypeAnnotatedVar.errors.txt index 2ab30ece7a080..6d5bb07c735a2 100644 --- a/tests/baselines/reference/conflictingTypeAnnotatedVar.errors.txt +++ b/tests/baselines/reference/conflictingTypeAnnotatedVar.errors.txt @@ -1,10 +1,10 @@ tests/cases/compiler/conflictingTypeAnnotatedVar.ts(1,5): error TS2300: Duplicate identifier 'foo'. tests/cases/compiler/conflictingTypeAnnotatedVar.ts(2,10): error TS2300: Duplicate identifier 'foo'. tests/cases/compiler/conflictingTypeAnnotatedVar.ts(2,10): error TS2393: Duplicate function implementation. -tests/cases/compiler/conflictingTypeAnnotatedVar.ts(2,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/conflictingTypeAnnotatedVar.ts(2,17): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/compiler/conflictingTypeAnnotatedVar.ts(3,10): error TS2300: Duplicate identifier 'foo'. tests/cases/compiler/conflictingTypeAnnotatedVar.ts(3,10): error TS2393: Duplicate function implementation. -tests/cases/compiler/conflictingTypeAnnotatedVar.ts(3,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/conflictingTypeAnnotatedVar.ts(3,17): error TS2847: A function with this return type needs to explicitly return a value. ==== tests/cases/compiler/conflictingTypeAnnotatedVar.ts (7 errors) ==== @@ -17,11 +17,11 @@ tests/cases/compiler/conflictingTypeAnnotatedVar.ts(3,17): error TS2355: A funct ~~~ !!! error TS2393: Duplicate function implementation. ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. function foo(): number { } ~~~ !!! error TS2300: Duplicate identifier 'foo'. ~~~ !!! error TS2393: Duplicate function implementation. ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. \ No newline at end of file +!!! error TS2847: A function with this return type needs to explicitly return a value. \ No newline at end of file diff --git a/tests/baselines/reference/controlFlowGenericTypes.errors.txt b/tests/baselines/reference/controlFlowGenericTypes.errors.txt index 4686e36af6091..d51a5d437ad4f 100644 --- a/tests/baselines/reference/controlFlowGenericTypes.errors.txt +++ b/tests/baselines/reference/controlFlowGenericTypes.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/controlFlow/controlFlowGenericTypes.ts(49,15): error TS2 tests/cases/conformance/controlFlow/controlFlowGenericTypes.ts(55,15): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'Box'. tests/cases/conformance/controlFlow/controlFlowGenericTypes.ts(81,11): error TS2339: Property 'foo' does not exist on type 'MyUnion'. Property 'foo' does not exist on type 'AA'. -tests/cases/conformance/controlFlow/controlFlowGenericTypes.ts(90,44): error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. +tests/cases/conformance/controlFlow/controlFlowGenericTypes.ts(90,44): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/conformance/controlFlow/controlFlowGenericTypes.ts(91,11): error TS2339: Property 'foo' does not exist on type 'MyUnion'. Property 'foo' does not exist on type 'AA'. tests/cases/conformance/controlFlow/controlFlowGenericTypes.ts(156,16): error TS18048: 'obj' is possibly 'undefined'. @@ -109,7 +109,7 @@ tests/cases/conformance/controlFlow/controlFlowGenericTypes.ts(168,9): error TS1 const fn2 = (value: T): MyUnion => { ~~~~~~~ -!!! error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. value.foo; // Error ~~~ !!! error TS2339: Property 'foo' does not exist on type 'MyUnion'. diff --git a/tests/baselines/reference/errorOnContextuallyTypedReturnType.errors.txt b/tests/baselines/reference/errorOnContextuallyTypedReturnType.errors.txt index 403e79b874271..afdcf2600ce48 100644 --- a/tests/baselines/reference/errorOnContextuallyTypedReturnType.errors.txt +++ b/tests/baselines/reference/errorOnContextuallyTypedReturnType.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/errorOnContextuallyTypedReturnType.ts(1,5): error TS2322: Type '() => void' is not assignable to type '() => boolean'. Type 'void' is not assignable to type 'boolean'. -tests/cases/compiler/errorOnContextuallyTypedReturnType.ts(2,37): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/errorOnContextuallyTypedReturnType.ts(2,37): error TS2847: A function with this return type needs to explicitly return a value. ==== tests/cases/compiler/errorOnContextuallyTypedReturnType.ts (2 errors) ==== @@ -10,5 +10,5 @@ tests/cases/compiler/errorOnContextuallyTypedReturnType.ts(2,37): error TS2355: !!! error TS2322: Type 'void' is not assignable to type 'boolean'. var n2: () => boolean = function ():boolean { }; // expect an error here ~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. \ No newline at end of file diff --git a/tests/baselines/reference/errorOnFunctionReturnType.errors.txt b/tests/baselines/reference/errorOnFunctionReturnType.errors.txt index 4fa30fe7edf7f..4e5a809e380b8 100644 --- a/tests/baselines/reference/errorOnFunctionReturnType.errors.txt +++ b/tests/baselines/reference/errorOnFunctionReturnType.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/jsdoc/foo.js(7,10): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/jsdoc/foo.js(7,10): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/conformance/jsdoc/foo.js(13,5): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/jsdoc/foo.js(16,60): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/conformance/jsdoc/foo.js(21,20): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/jsdoc/foo.js(16,60): error TS2847: A function with this return type needs to explicitly return a value. +tests/cases/conformance/jsdoc/foo.js(21,20): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/conformance/jsdoc/foo.js(31,10): error TS2534: A function returning 'never' cannot have a reachable end point. tests/cases/conformance/jsdoc/foo.js(37,5): error TS2322: Type 'string' is not assignable to type 'never'. tests/cases/conformance/jsdoc/foo.js(40,56): error TS2534: A function returning 'never' cannot have a reachable end point. @@ -17,7 +17,7 @@ tests/cases/conformance/jsdoc/foo.js(45,18): error TS2534: A function returning /** @type {FunctionReturningPromise} */ function testPromise1() { ~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. console.log("Nope"); } @@ -30,14 +30,14 @@ tests/cases/conformance/jsdoc/foo.js(45,18): error TS2534: A function returning var testPromise3 = /** @type {FunctionReturningPromise} */ function() { ~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. console.log("test") } /** @type {FunctionReturningPromise} */ var testPromise4 = function() { ~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. console.log("test") } diff --git a/tests/baselines/reference/functionImplementationErrors.errors.txt b/tests/baselines/reference/functionImplementationErrors.errors.txt index cdd16bc902718..07247ed1b14b8 100644 --- a/tests/baselines/reference/functionImplementationErrors.errors.txt +++ b/tests/baselines/reference/functionImplementationErrors.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/functions/functionImplementationErrors.ts(25,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/functions/functionImplementationErrors.ts(25,16): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/conformance/functions/functionImplementationErrors.ts(30,17): error TS2373: Parameter 'n' cannot reference identifier 'm' declared after it. tests/cases/conformance/functions/functionImplementationErrors.ts(35,17): error TS2373: Parameter 'n' cannot reference identifier 'm' declared after it. tests/cases/conformance/functions/functionImplementationErrors.ts(40,1): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. @@ -31,7 +31,7 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(40,1): error T // Function implemetnation with non -void return type annotation with no return function f5(): number { ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. } var m; diff --git a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt index f4466e0b869e4..b3ca48c684355 100644 --- a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt +++ b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(1,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(99,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(107,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(1,16): error TS2847: A function with this return type needs to explicitly return a value. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(99,17): error TS2847: A function with this return type needs to explicitly return a value. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(107,17): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(112,16): error TS2378: A 'get' accessor must return a value. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(134,15): error TS18050: The value 'undefined' cannot be used here. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(135,5): error TS1003: Identifier expected. @@ -9,7 +9,7 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(135,5): e ==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (6 errors) ==== function f1(): string { ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. // errors because there are no return statements } @@ -109,7 +109,7 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(135,5): e function f21(): number | string { ~~~~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. // Not okay; union does not contain void or any } @@ -119,7 +119,7 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(135,5): e function f23(): undefined | number { ~~~~~~~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. // Error; because `undefined | number` becomes `number` without strictNullChecks. } diff --git a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressionsStrictNullChecks.errors.txt b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressionsStrictNullChecks.errors.txt index a570470cf2ea0..2ede5e7cf0f4c 100644 --- a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressionsStrictNullChecks.errors.txt +++ b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressionsStrictNullChecks.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/functionsMissingReturnStatementsAndExpressionsStrictNullChecks.ts(5,16): error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. -tests/cases/compiler/functionsMissingReturnStatementsAndExpressionsStrictNullChecks.ts(13,22): error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressionsStrictNullChecks.ts(5,16): error TS2847: A function with this return type needs to explicitly return a value. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressionsStrictNullChecks.ts(13,22): error TS2847: A function with this return type needs to explicitly return a value. ==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressionsStrictNullChecks.ts (2 errors) ==== @@ -9,7 +9,7 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressionsStrictNullChe function f2(): number { ~~~~~~ -!!! error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. // Error; return type does not include undefined } @@ -19,7 +19,7 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressionsStrictNullChe async function f4(): Promise { ~~~~~~~~~~~~~~~ -!!! error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. // Error; return type does not include undefined } \ No newline at end of file diff --git a/tests/baselines/reference/invalidReturnStatements.errors.txt b/tests/baselines/reference/invalidReturnStatements.errors.txt index fe34106169bf6..9051b3bec9401 100644 --- a/tests/baselines/reference/invalidReturnStatements.errors.txt +++ b/tests/baselines/reference/invalidReturnStatements.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(2,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(3,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(4,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(5,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(2,17): error TS2847: A function with this return type needs to explicitly return a value. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(3,17): error TS2847: A function with this return type needs to explicitly return a value. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(4,17): error TS2847: A function with this return type needs to explicitly return a value. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(5,17): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(16,22): error TS2739: Type '{ id: number; }' is missing the following properties from type 'D': name, dispose tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(18,22): error TS2741: Property 'name' is missing in type 'C' but required in type 'D'. @@ -10,16 +10,16 @@ tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(1 // all the following should be error function fn1(): number { } ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. function fn2(): string { } ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. function fn3(): boolean { } ~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. function fn4(): Date { } ~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. function fn7(): any { } // should be valid: any includes void interface I { id: number } diff --git a/tests/baselines/reference/jsdocFunction_missingReturn.errors.txt b/tests/baselines/reference/jsdocFunction_missingReturn.errors.txt index 8e102d797ec7c..39b01c83bdeff 100644 --- a/tests/baselines/reference/jsdocFunction_missingReturn.errors.txt +++ b/tests/baselines/reference/jsdocFunction_missingReturn.errors.txt @@ -1,9 +1,9 @@ -/a.js(1,24): error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. +/a.js(1,24): error TS2847: A function with this return type needs to explicitly return a value. ==== /a.js (1 errors) ==== /** @type {function(): number} */ ~~~~~~ -!!! error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. function f() {} \ No newline at end of file diff --git a/tests/baselines/reference/jsdocOuterTypeParameters2.errors.txt b/tests/baselines/reference/jsdocOuterTypeParameters2.errors.txt index a0a53680b66db..93f28a324fbb3 100644 --- a/tests/baselines/reference/jsdocOuterTypeParameters2.errors.txt +++ b/tests/baselines/reference/jsdocOuterTypeParameters2.errors.txt @@ -1,6 +1,6 @@ error TS5055: Cannot write file 'tests/cases/conformance/jsdoc/jsdocOuterTypeParameters1.js' because it would overwrite input file. Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -tests/cases/conformance/jsdoc/jsdocOuterTypeParameters1.js(1,14): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/jsdoc/jsdocOuterTypeParameters1.js(1,14): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/conformance/jsdoc/jsdocOuterTypeParameters1.js(7,35): error TS2339: Property 'foo' does not exist on type 'Bar'. @@ -9,7 +9,7 @@ tests/cases/conformance/jsdoc/jsdocOuterTypeParameters1.js(7,35): error TS2339: ==== tests/cases/conformance/jsdoc/jsdocOuterTypeParameters1.js (2 errors) ==== /** @return {T} */ ~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. const dedupingMixin = function(mixin) {}; /** @template T */ diff --git a/tests/baselines/reference/methodInAmbientClass1.errors.txt b/tests/baselines/reference/methodInAmbientClass1.errors.txt index c931cc0101c81..bc1a83a3ab2ca 100644 --- a/tests/baselines/reference/methodInAmbientClass1.errors.txt +++ b/tests/baselines/reference/methodInAmbientClass1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/methodInAmbientClass1.ts(2,12): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/methodInAmbientClass1.ts(2,12): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/compiler/methodInAmbientClass1.ts(2,20): error TS1183: An implementation cannot be declared in ambient contexts. @@ -6,7 +6,7 @@ tests/cases/compiler/methodInAmbientClass1.ts(2,20): error TS1183: An implementa declare class Foo { fn(): boolean { ~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. ~ !!! error TS1183: An implementation cannot be declared in ambient contexts. } diff --git a/tests/baselines/reference/missingReturnStatement.errors.txt b/tests/baselines/reference/missingReturnStatement.errors.txt index 8926d22be3d42..b4c2f84f734a9 100644 --- a/tests/baselines/reference/missingReturnStatement.errors.txt +++ b/tests/baselines/reference/missingReturnStatement.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/missingReturnStatement.ts(3,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/missingReturnStatement.ts(3,22): error TS2847: A function with this return type needs to explicitly return a value. ==== tests/cases/compiler/missingReturnStatement.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/missingReturnStatement.ts(3,22): error TS2355: A function w export class Bug { public foo():string { ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. } } } diff --git a/tests/baselines/reference/missingReturnStatement1.errors.txt b/tests/baselines/reference/missingReturnStatement1.errors.txt index 9d3cf78411edf..12755e7814c0e 100644 --- a/tests/baselines/reference/missingReturnStatement1.errors.txt +++ b/tests/baselines/reference/missingReturnStatement1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/missingReturnStatement1.ts(2,12): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/missingReturnStatement1.ts(2,12): error TS2847: A function with this return type needs to explicitly return a value. ==== tests/cases/compiler/missingReturnStatement1.ts (1 errors) ==== class Foo { foo(): number { ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. //return 4; } } diff --git a/tests/baselines/reference/multiLineErrors.errors.txt b/tests/baselines/reference/multiLineErrors.errors.txt index 851425baef434..9e2cd5d64255a 100644 --- a/tests/baselines/reference/multiLineErrors.errors.txt +++ b/tests/baselines/reference/multiLineErrors.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/multiLineErrors.ts(3,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/multiLineErrors.ts(3,22): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/compiler/multiLineErrors.ts(21,1): error TS2322: Type 'A2' is not assignable to type 'A1'. The types of 'x.y' are incompatible between these types. Type 'string' is not assignable to type 'number'. @@ -15,7 +15,7 @@ tests/cases/compiler/multiLineErrors.ts(21,1): error TS2322: Type 'A2' is not as ~~~~~~~~~~~~~~ } ~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. { var x = 4; var y = 10; diff --git a/tests/baselines/reference/parseInvalidNonNullableTypes.errors.txt b/tests/baselines/reference/parseInvalidNonNullableTypes.errors.txt index 378419d288544..205c639501362 100644 --- a/tests/baselines/reference/parseInvalidNonNullableTypes.errors.txt +++ b/tests/baselines/reference/parseInvalidNonNullableTypes.errors.txt @@ -4,9 +4,9 @@ tests/cases/compiler/parseInvalidNonNullableTypes.ts(9,16): error TS17019: '!' a tests/cases/compiler/parseInvalidNonNullableTypes.ts(10,16): error TS17019: '!' at the end of a type is not valid TypeScript syntax. Did you mean to write 'number'? tests/cases/compiler/parseInvalidNonNullableTypes.ts(12,16): error TS17020: '!' at the start of a type is not valid TypeScript syntax. Did you mean to write 'string'? tests/cases/compiler/parseInvalidNonNullableTypes.ts(13,16): error TS17020: '!' at the start of a type is not valid TypeScript syntax. Did you mean to write 'number'? -tests/cases/compiler/parseInvalidNonNullableTypes.ts(15,16): error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. +tests/cases/compiler/parseInvalidNonNullableTypes.ts(15,16): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/compiler/parseInvalidNonNullableTypes.ts(15,16): error TS17019: '!' at the end of a type is not valid TypeScript syntax. Did you mean to write 'string'? -tests/cases/compiler/parseInvalidNonNullableTypes.ts(16,16): error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. +tests/cases/compiler/parseInvalidNonNullableTypes.ts(16,16): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/compiler/parseInvalidNonNullableTypes.ts(16,16): error TS17020: '!' at the start of a type is not valid TypeScript syntax. Did you mean to write 'string'? tests/cases/compiler/parseInvalidNonNullableTypes.ts(18,16): error TS17019: '!' at the end of a type is not valid TypeScript syntax. Did you mean to write 'any'? tests/cases/compiler/parseInvalidNonNullableTypes.ts(19,10): error TS17019: '!' at the end of a type is not valid TypeScript syntax. Did you mean to write 'number'? @@ -43,12 +43,12 @@ tests/cases/compiler/parseInvalidNonNullableTypes.ts(22,10): error TS17020: '!' function f7(): string! {} ~~~~~~~ -!!! error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. ~~~~~~~ !!! error TS17019: '!' at the end of a type is not valid TypeScript syntax. Did you mean to write 'string'? function f8(): !string {} ~~~~~~~ -!!! error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. ~~~~~~~ !!! error TS17020: '!' at the start of a type is not valid TypeScript syntax. Did you mean to write 'string'? diff --git a/tests/baselines/reference/parserErrorRecovery_Block3.errors.txt b/tests/baselines/reference/parserErrorRecovery_Block3.errors.txt index e6033d05215d9..72e3f944c5a4e 100644 --- a/tests/baselines/reference/parserErrorRecovery_Block3.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_Block3.errors.txt @@ -1,18 +1,18 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(2,18): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(2,18): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(4,5): error TS1128: Declaration or statement expected. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(4,18): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(4,18): error TS2847: A function with this return type needs to explicitly return a value. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts (3 errors) ==== class C { private a(): boolean { ~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. private b(): boolean { ~~~~~~~ !!! error TS1128: Declaration or statement expected. ~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. } } \ No newline at end of file diff --git a/tests/baselines/reference/parserParameterList5.errors.txt b/tests/baselines/reference/parserParameterList5.errors.txt index 5f0899fa1a2a6..ee93b021fe4d2 100644 --- a/tests/baselines/reference/parserParameterList5.errors.txt +++ b/tests/baselines/reference/parserParameterList5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList5.ts(1,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList5.ts(1,15): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList5.ts(1,16): error TS2369: A parameter property is only allowed in a constructor implementation. tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList5.ts(1,29): error TS2304: Cannot find name 'C'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList5.t ==== tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList5.ts (3 errors) ==== function A(): (public B) => C { ~~~~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. ~~~~~~~~ !!! error TS2369: A parameter property is only allowed in a constructor implementation. ~ diff --git a/tests/baselines/reference/reachabilityChecks5.errors.txt b/tests/baselines/reference/reachabilityChecks5.errors.txt index f8c7e6f4dbc1a..e6bc141e158d9 100644 --- a/tests/baselines/reference/reachabilityChecks5.errors.txt +++ b/tests/baselines/reference/reachabilityChecks5.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/reachabilityChecks5.ts(5,17): error TS7030: Not all code paths return a value. -tests/cases/compiler/reachabilityChecks5.ts(18,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/reachabilityChecks5.ts(18,17): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/compiler/reachabilityChecks5.ts(30,17): error TS7030: Not all code paths return a value. tests/cases/compiler/reachabilityChecks5.ts(40,17): error TS7030: Not all code paths return a value. tests/cases/compiler/reachabilityChecks5.ts(51,17): error TS7030: Not all code paths return a value. @@ -33,7 +33,7 @@ tests/cases/compiler/reachabilityChecks5.ts(122,13): error TS7027: Unreachable c function f3(x): number { ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. while (x) { throw new Error(); } diff --git a/tests/baselines/reference/reachabilityChecks7.errors.txt b/tests/baselines/reference/reachabilityChecks7.errors.txt index 9ac2d0c1ad8ae..1c5553e3d5f0c 100644 --- a/tests/baselines/reference/reachabilityChecks7.errors.txt +++ b/tests/baselines/reference/reachabilityChecks7.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/reachabilityChecks7.ts(13,16): error TS7030: Not all code paths return a value. -tests/cases/compiler/reachabilityChecks7.ts(17,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/reachabilityChecks7.ts(17,22): error TS2847: A function with this return type needs to explicitly return a value. ==== tests/cases/compiler/reachabilityChecks7.ts (2 errors) ==== @@ -23,7 +23,7 @@ tests/cases/compiler/reachabilityChecks7.ts(17,22): error TS2355: A function who async function f4(): Promise { ~~~~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. } diff --git a/tests/baselines/reference/recursiveFunctionTypes.errors.txt b/tests/baselines/reference/recursiveFunctionTypes.errors.txt index 13ab49c4666ec..3f590b5412839 100644 --- a/tests/baselines/reference/recursiveFunctionTypes.errors.txt +++ b/tests/baselines/reference/recursiveFunctionTypes.errors.txt @@ -2,8 +2,8 @@ tests/cases/compiler/recursiveFunctionTypes.ts(1,28): error TS2322: Type 'number tests/cases/compiler/recursiveFunctionTypes.ts(3,5): error TS2322: Type '() => typeof fn' is not assignable to type 'number'. tests/cases/compiler/recursiveFunctionTypes.ts(4,5): error TS2322: Type '() => typeof fn' is not assignable to type '() => number'. Type '() => typeof fn' is not assignable to type 'number'. -tests/cases/compiler/recursiveFunctionTypes.ts(11,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/compiler/recursiveFunctionTypes.ts(12,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/recursiveFunctionTypes.ts(11,16): error TS2847: A function with this return type needs to explicitly return a value. +tests/cases/compiler/recursiveFunctionTypes.ts(12,16): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/compiler/recursiveFunctionTypes.ts(17,5): error TS2322: Type '() => I' is not assignable to type 'number'. tests/cases/compiler/recursiveFunctionTypes.ts(22,5): error TS2345: Argument of type 'number' is not assignable to parameter of type '(t: typeof g) => void'. tests/cases/compiler/recursiveFunctionTypes.ts(25,1): error TS2322: Type 'number' is not assignable to type '() => any'. @@ -40,10 +40,10 @@ tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2769: No overload function f2(): typeof g2 { } ~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. function g2(): typeof f2 { } ~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. interface I { } function f3(): I { return f3; } diff --git a/tests/baselines/reference/returnTypeParameter.errors.txt b/tests/baselines/reference/returnTypeParameter.errors.txt index 24b9e725de8fd..38c6e8562a6eb 100644 --- a/tests/baselines/reference/returnTypeParameter.errors.txt +++ b/tests/baselines/reference/returnTypeParameter.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/returnTypeParameter.ts(1,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/returnTypeParameter.ts(1,22): error TS2847: A function with this return type needs to explicitly return a value. tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2693: 'T' only refers to a type, but is being used as a value here. ==== tests/cases/compiler/returnTypeParameter.ts (2 errors) ==== function f(a: T): T { } // error, no return statement ~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +!!! error TS2847: A function with this return type needs to explicitly return a value. function f2(a: T): T { return T; } // bug was that this satisfied the return statement requirement ~ !!! error TS2693: 'T' only refers to a type, but is being used as a value here. \ No newline at end of file