TypeScript/tests/baselines/reference/classPropertyErrorOnNameOnly.errors.txt
Anders Hejlsberg e1fda834f3
Cache complex union and intersection relations (#37910)
* Cache complex union/intersection relations

* Accept new baselines

* Accept new baselines
2021-01-04 15:15:01 -10:00

53 lines
2 KiB
Plaintext

tests/cases/compiler/classPropertyErrorOnNameOnly.ts(7,3): error TS2322: Type '(val: Values) => "1" | "2" | "3" | "4" | "5" | undefined' is not assignable to type 'FuncType'.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
tests/cases/compiler/classPropertyErrorOnNameOnly.ts(24,7): error TS2322: Type '(val: Values) => "1" | "2" | "3" | "4" | "5" | undefined' is not assignable to type 'FuncType'.
Type 'string | undefined' is not assignable to type 'string'.
==== tests/cases/compiler/classPropertyErrorOnNameOnly.ts (2 errors) ====
type Values = 1 | 2 | 3 | 4 | 5 | 6
type FuncType = (arg: Values) => string
// turn on strictNullChecks
class Example {
insideClass: FuncType = function(val) { // error span goes from here
~~~~~~~~~~~
!!! error TS2322: Type '(val: Values) => "1" | "2" | "3" | "4" | "5" | undefined' is not assignable to type 'FuncType'.
!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'.
!!! error TS2322: Type 'undefined' is not assignable to type 'string'.
switch (val) {
case 1:
return "1";
case 2:
return "2";
case 3:
return "3"
case 4:
return "4"
case 5:
return "5"
// forgot case 6
}
} // all the way to here
}
const outsideClass: FuncType = function(val) { // compare to errors only on this line in this case
~~~~~~~~~~~~
!!! error TS2322: Type '(val: Values) => "1" | "2" | "3" | "4" | "5" | undefined' is not assignable to type 'FuncType'.
!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'.
switch (val) {
case 1:
return "1";
case 2:
return "2";
case 3:
return "3"
case 4:
return "4"
case 5:
return "5"
// forgot case 6
}
}