mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
18 lines
579 B
Plaintext
18 lines
579 B
Plaintext
functionOverloads43.ts(8,5): error TS2322: Type 'undefined' is not assignable to type 'string | number'.
|
|
|
|
|
|
==== functionOverloads43.ts (1 errors) ====
|
|
function foo(bar: { a:number }[]): number;
|
|
function foo(bar: { a:string }[]): string;
|
|
function foo([x]: { a:number | string }[]): string | number {
|
|
if (x) {
|
|
return x.a;
|
|
}
|
|
|
|
return undefined;
|
|
~~~~~~
|
|
!!! error TS2322: Type 'undefined' is not assignable to type 'string | number'.
|
|
}
|
|
|
|
var x = foo([{a: "str"}]);
|
|
var y = foo([{a: 100}]); |