diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d9722099699..2a0ffc49b0d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4051,7 +4051,7 @@ module ts { } // This function does not conform to the specification. - error(func.type, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_have_a_return_expression_or_consist_of_a_single_throw_statement); + error(func.type, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpression(node: FunctionExpression, contextualType?: Type, contextualMapper?: TypeMapper): Type { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 75f49efc36c..4f831b185bc 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -115,7 +115,7 @@ module ts { The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2119, category: DiagnosticCategory.Error, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2126, category: DiagnosticCategory.Error, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2127, category: DiagnosticCategory.Error, key: "Getter and setter accessors do not agree in visibility." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_have_a_return_expression_or_consist_of_a_single_throw_statement: { code: 2131, category: DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2131, category: DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, Untyped_function_calls_may_not_accept_type_arguments: { code: 2158, category: DiagnosticCategory.Error, key: "Untyped function calls may not accept type arguments." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2120, category: DiagnosticCategory.Error, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2121, category: DiagnosticCategory.Error, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 40da04b3988..0f92044f877 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -454,7 +454,7 @@ "category": "Error", "code": 2127 }, - "A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement.": { + "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.": { "category": "Error", "code": 2131 }, diff --git a/tests/baselines/reference/ParameterList5.errors.txt b/tests/baselines/reference/ParameterList5.errors.txt index 113afa1008a..412fb71eb14 100644 --- a/tests/baselines/reference/ParameterList5.errors.txt +++ b/tests/baselines/reference/ParameterList5.errors.txt @@ -1,7 +1,7 @@ ==== tests/cases/compiler/ParameterList5.ts (3 errors) ==== function A(): (public B) => C { ~~~~~~~~~~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. ~~~~~~~~ !!! A parameter property is only allowed in a constructor implementation. ~ diff --git a/tests/baselines/reference/ambientGetters.errors.txt b/tests/baselines/reference/ambientGetters.errors.txt index 9c2cbe0dbad..a8c913b66c7 100644 --- a/tests/baselines/reference/ambientGetters.errors.txt +++ b/tests/baselines/reference/ambientGetters.errors.txt @@ -5,7 +5,7 @@ ~ !!! '{' expected. ~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. } declare class B { diff --git a/tests/baselines/reference/conflictingTypeAnnotatedVar.errors.txt b/tests/baselines/reference/conflictingTypeAnnotatedVar.errors.txt index 7e864771685..6bb45b67ee7 100644 --- a/tests/baselines/reference/conflictingTypeAnnotatedVar.errors.txt +++ b/tests/baselines/reference/conflictingTypeAnnotatedVar.errors.txt @@ -4,9 +4,9 @@ ~~~ !!! Duplicate identifier 'foo'. ~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. function foo(): number { } ~~~ !!! Duplicate identifier 'foo'. ~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. \ No newline at end of file +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. \ No newline at end of file diff --git a/tests/baselines/reference/errorOnContextuallyTypedReturnType.errors.txt b/tests/baselines/reference/errorOnContextuallyTypedReturnType.errors.txt index e472cb83185..414fa7dc4c2 100644 --- a/tests/baselines/reference/errorOnContextuallyTypedReturnType.errors.txt +++ b/tests/baselines/reference/errorOnContextuallyTypedReturnType.errors.txt @@ -5,5 +5,5 @@ !!! Type 'void' is not assignable to type 'boolean'. var n2: () => boolean = function ():boolean { }; // expect an error here ~~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. \ No newline at end of file diff --git a/tests/baselines/reference/functionImplementationErrors.errors.txt b/tests/baselines/reference/functionImplementationErrors.errors.txt index e9876914bac..3da56bd6818 100644 --- a/tests/baselines/reference/functionImplementationErrors.errors.txt +++ b/tests/baselines/reference/functionImplementationErrors.errors.txt @@ -48,7 +48,7 @@ // Function implemetnation with non -void return type annotation with no return function f5(): number { ~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. } var m; diff --git a/tests/baselines/reference/functionWithThrowButNoReturn1.errors.txt b/tests/baselines/reference/functionWithThrowButNoReturn1.errors.txt index 817cf95d6be..b354a9f8852 100644 --- a/tests/baselines/reference/functionWithThrowButNoReturn1.errors.txt +++ b/tests/baselines/reference/functionWithThrowButNoReturn1.errors.txt @@ -1,7 +1,7 @@ ==== tests/cases/compiler/functionWithThrowButNoReturn1.ts (1 errors) ==== function fn(): number { ~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. throw new Error('NYI'); var t; } diff --git a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt index 97170cf4df1..6ddbc91db57 100644 --- a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt +++ b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt @@ -2,7 +2,7 @@ function f1(): string { ~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. // errors because there are no return statements } @@ -66,7 +66,7 @@ function f14(): number { ~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. // Not fine, since we can *only* consist of a single throw statement // if no return statements are present but we are annotated. throw undefined; diff --git a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.errors.txt b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.errors.txt index d43866c3874..1320a21f46b 100644 --- a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.errors.txt +++ b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.errors.txt @@ -3,7 +3,7 @@ export class MemberName { static create(arg1: any, arg2?: any, arg3?: any): MemberName { ~~~~~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. ~~~~~~~~~~ !!! Generic type 'MemberName' requires 3 type argument(s). } diff --git a/tests/baselines/reference/gettersAndSettersErrors.errors.txt b/tests/baselines/reference/gettersAndSettersErrors.errors.txt index 32531ccf4ef..dbd06a744f0 100644 --- a/tests/baselines/reference/gettersAndSettersErrors.errors.txt +++ b/tests/baselines/reference/gettersAndSettersErrors.errors.txt @@ -17,7 +17,7 @@ ~~~ !!! Accessors are only available when targeting ECMAScript 5 and higher. ~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. } class E { diff --git a/tests/baselines/reference/invalidReturnStatements.errors.txt b/tests/baselines/reference/invalidReturnStatements.errors.txt index b37a2935370..ee371f5f000 100644 --- a/tests/baselines/reference/invalidReturnStatements.errors.txt +++ b/tests/baselines/reference/invalidReturnStatements.errors.txt @@ -2,16 +2,16 @@ // all the following should be error function fn1(): number { } ~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. function fn2(): string { } ~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. function fn3(): boolean { } ~~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. function fn4(): Date { } ~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. function fn7(): any { } // should be valid: any includes void interface I { id: number } diff --git a/tests/baselines/reference/missingReturnStatement.errors.txt b/tests/baselines/reference/missingReturnStatement.errors.txt index 5a920744119..9a92adf4c03 100644 --- a/tests/baselines/reference/missingReturnStatement.errors.txt +++ b/tests/baselines/reference/missingReturnStatement.errors.txt @@ -3,7 +3,7 @@ export class Bug { public foo():string { ~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. } } } diff --git a/tests/baselines/reference/missingReturnStatement1.errors.txt b/tests/baselines/reference/missingReturnStatement1.errors.txt index b0f2f5ef884..d1d47368bb1 100644 --- a/tests/baselines/reference/missingReturnStatement1.errors.txt +++ b/tests/baselines/reference/missingReturnStatement1.errors.txt @@ -2,7 +2,7 @@ class Foo { foo(): number { ~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. //return 4; } } diff --git a/tests/baselines/reference/multiLineErrors.errors.txt b/tests/baselines/reference/multiLineErrors.errors.txt index f0ee4fa4835..911c07731e3 100644 --- a/tests/baselines/reference/multiLineErrors.errors.txt +++ b/tests/baselines/reference/multiLineErrors.errors.txt @@ -9,7 +9,7 @@ ~~~~~~~~~~~~~~ } ~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. { var x = 4; var y = 10; diff --git a/tests/baselines/reference/parserErrorRecovery_Block3.errors.txt b/tests/baselines/reference/parserErrorRecovery_Block3.errors.txt index 900c0acab92..354cfff1fdd 100644 --- a/tests/baselines/reference/parserErrorRecovery_Block3.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_Block3.errors.txt @@ -2,12 +2,12 @@ class C { private a(): boolean { ~~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. private b(): boolean { ~~~~~~~ !!! Statement expected. ~~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. } } \ No newline at end of file diff --git a/tests/baselines/reference/parserGenericsInTypeContexts1.errors.txt b/tests/baselines/reference/parserGenericsInTypeContexts1.errors.txt index 8567f11b77d..574c03823df 100644 --- a/tests/baselines/reference/parserGenericsInTypeContexts1.errors.txt +++ b/tests/baselines/reference/parserGenericsInTypeContexts1.errors.txt @@ -30,7 +30,7 @@ function f2(): F { ~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. ~~~~ !!! Cannot find name 'F'. } diff --git a/tests/baselines/reference/parserGenericsInTypeContexts2.errors.txt b/tests/baselines/reference/parserGenericsInTypeContexts2.errors.txt index 26631669d8f..f3b47f04368 100644 --- a/tests/baselines/reference/parserGenericsInTypeContexts2.errors.txt +++ b/tests/baselines/reference/parserGenericsInTypeContexts2.errors.txt @@ -30,7 +30,7 @@ function f2(): F, Y>> { ~~~~~~~~~~~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. ~~~~~~~~~~~~~~~~ !!! Cannot find name 'F'. } diff --git a/tests/baselines/reference/parserParameterList5.errors.txt b/tests/baselines/reference/parserParameterList5.errors.txt index 3b677a57e48..ccc5d8c0dbf 100644 --- a/tests/baselines/reference/parserParameterList5.errors.txt +++ b/tests/baselines/reference/parserParameterList5.errors.txt @@ -1,7 +1,7 @@ ==== tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList5.ts (3 errors) ==== function A(): (public B) => C { ~~~~~~~~~~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. ~~~~~~~~ !!! A parameter property is only allowed in a constructor implementation. ~ diff --git a/tests/baselines/reference/parserSetAccessorWithTypeAnnotation1.errors.txt b/tests/baselines/reference/parserSetAccessorWithTypeAnnotation1.errors.txt index 00084e4607a..f4898163e0f 100644 --- a/tests/baselines/reference/parserSetAccessorWithTypeAnnotation1.errors.txt +++ b/tests/baselines/reference/parserSetAccessorWithTypeAnnotation1.errors.txt @@ -4,6 +4,6 @@ ~~~ !!! A 'set' accessor cannot have a return type annotation. ~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. } } \ No newline at end of file diff --git a/tests/baselines/reference/recursiveFunctionTypes.errors.txt b/tests/baselines/reference/recursiveFunctionTypes.errors.txt index ab20996c933..833fcf386c0 100644 --- a/tests/baselines/reference/recursiveFunctionTypes.errors.txt +++ b/tests/baselines/reference/recursiveFunctionTypes.errors.txt @@ -18,10 +18,10 @@ function f2(): typeof g2 { } ~~~~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. function g2(): typeof f2 { } ~~~~~~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. interface I { } function f3(): I { return f3; } diff --git a/tests/baselines/reference/returnTypeParameter.errors.txt b/tests/baselines/reference/returnTypeParameter.errors.txt index 1f97ca1cfb4..f8927fef427 100644 --- a/tests/baselines/reference/returnTypeParameter.errors.txt +++ b/tests/baselines/reference/returnTypeParameter.errors.txt @@ -1,7 +1,7 @@ ==== tests/cases/compiler/returnTypeParameter.ts (2 errors) ==== function f(a: T): T { } // error, no return statement ~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. function f2(a: T): T { return T; } // bug was that this satisfied the return statement requirement ~ !!! Cannot find name 'T'. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterUsedAsTypeParameterConstraint4.errors.txt b/tests/baselines/reference/typeParameterUsedAsTypeParameterConstraint4.errors.txt index e8891b1072f..da073522ae8 100644 --- a/tests/baselines/reference/typeParameterUsedAsTypeParameterConstraint4.errors.txt +++ b/tests/baselines/reference/typeParameterUsedAsTypeParameterConstraint4.errors.txt @@ -35,12 +35,12 @@ ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. ~ !!! Cannot find name 'V'. function bar(): X { // error ~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. ~ !!! Cannot find name 'X'. function baz(a: X, b: Y): T { @@ -58,12 +58,12 @@ ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. ~ !!! Cannot find name 'W'. function bar(): Y { // error ~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. ~ !!! Cannot find name 'Y'. function baz(a: X, b: Y): T { diff --git a/tests/baselines/reference/unknownSymbols1.errors.txt b/tests/baselines/reference/unknownSymbols1.errors.txt index 2d16630a69e..beb39743441 100644 --- a/tests/baselines/reference/unknownSymbols1.errors.txt +++ b/tests/baselines/reference/unknownSymbols1.errors.txt @@ -10,7 +10,7 @@ ~~~~ !!! Cannot find name 'asdf'. ~~~~ -!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. +!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. ~~~~ !!! Cannot find name 'asdf'. function foo2() {