TypeScript Union Types All In One
TypeScript Union Types All In One
vscode 智能提示
// 联合类型 Union Types
let mix: number | string | boolean;
// let mix: string | number | boolean
mix = 1;
mix.toFixed();
mix = 'a';
mix.endsWith('x');
mix = false;
mix.valueOf();
let arr: number[] | string[] | (number | string)[];
arr = [1, 2, 3];
arr = ['a', 'b', 'c'];
arr = [1, 'b', 3];
refs
https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html#union-types
https://www.typescriptlang.org/docs/handbook/advanced-types.html#using-the-in-operator
?xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有??xgqfrms, 禁止转载 ???,侵权必究??!