标签:span pre oom rgba function ever rev type string
function reverse(str: string): string; function reverse<T>(arr: T[]): T[]; function reverse<T>(stringOrArray: string | T[]): string | T[] { if (typeof stringOrArray === ‘string‘) { return stringOrArray .split(‘‘) .reverse() .join(‘‘); } return stringOrArray.slice().reverse(); } reverse(‘Pepperoni‘); reverse([‘bacon‘, ‘pepperoni‘, ‘chili‘, ‘mushrooms‘]);
Function overload doesn‘t compile to Javascript, it is just a way to tell typescript about type information
[Typescript] Function Overloads
标签:span pre oom rgba function ever rev type string
原文地址:https://www.cnblogs.com/Answer1215/p/13774097.html