TypeScript/tests/baselines/reference/functionWithMultipleReturnStatements.errors.txt

93 lines
3.9 KiB
Plaintext

tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(4,10): error TS2354: No best common type exists among return expressions.
tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(12,10): error TS2354: No best common type exists among return expressions.
tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(22,10): error TS2354: No best common type exists among return expressions.
tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(31,10): error TS2354: No best common type exists among return expressions.
tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(43,10): error TS2354: No best common type exists among return expressions.
tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(48,10): error TS2354: No best common type exists among return expressions.
tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(56,10): error TS2354: No best common type exists among return expressions.
tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(56,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(56,26): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
==== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts (9 errors) ====
// return type of a function with multiple returns is the BCT of each return statement
// it is an error if there is no single BCT, these are error cases
function f1() {
~~
!!! error TS2354: No best common type exists among return expressions.
if (true) {
return 1;
} else {
return '';
}
}
function f2() {
~~
!!! error TS2354: No best common type exists among return expressions.
if (true) {
return 1;
} else if (false) {
return 2;
} else {
return '';
}
}
function f3() {
~~
!!! error TS2354: No best common type exists among return expressions.
try {
return 1;
}
catch (e) {
return '';
}
}
function f4() {
~~
!!! error TS2354: No best common type exists among return expressions.
try {
return 1;
}
catch (e) {
}
finally {
return '';
}
}
function f5() {
~~
!!! error TS2354: No best common type exists among return expressions.
return 1;
return '';
}
function f6<T, U>(x: T, y:U) {
~~
!!! error TS2354: No best common type exists among return expressions.
if (true) {
return x;
} else {
return y;
}
}
function f8<T extends U, U extends V, V>(x: T, y: U) {
~~
!!! error TS2354: No best common type exists among return expressions.
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
if (true) {
return x;
} else {
return y;
}
}