mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
27 lines
555 B
TypeScript
27 lines
555 B
TypeScript
//// [tests/cases/compiler/functionOverloads43.ts] ////
|
|
|
|
//// [functionOverloads43.ts]
|
|
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;
|
|
}
|
|
|
|
var x = foo([{a: "str"}]);
|
|
var y = foo([{a: 100}]);
|
|
|
|
//// [functionOverloads43.js]
|
|
"use strict";
|
|
function foo([x]) {
|
|
if (x) {
|
|
return x.a;
|
|
}
|
|
return undefined;
|
|
}
|
|
var x = foo([{ a: "str" }]);
|
|
var y = foo([{ a: 100 }]);
|