-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
联合类型 #155
Labels
Comments
啦啦啦 |
oh my god! |
god! |
真好啊 |
666 |
最后那个例子被赋值后还是联合类型吗?还是变成了其中一个类型 |
还是联合类型。 |
|
卧槽 |
这手速只能是的撒 |
交叉类型是我没注意到吗。。 |
------------------ 原始邮件 ------------------
发件人: "Yomua"<notifications@github.com>;
发送时间: 2020年12月23日(星期三) 下午5:20
收件人: "xcatliu/typescript-tutorial"<typescript-tutorial@noreply.github.com>;
抄送: "李重泽"<352840359@qq.com>; "Comment"<comment@noreply.github.com>;
主题: Re: [xcatliu/typescript-tutorial] 联合类型 (#155)
交叉类型是我没注意到吗。。
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
真棒 |
针不戳 |
6 |
function getString(something: string | number): number { |
传入字符串返回字符串,传入数字返回数字 function getString(something: string | number): string | number {
return something.toString();
} 或者这么写 function getString(something: string): string;
function getString(something: number): number;
function getString(something: string | number): string | number {
return something.toString();
} |
确实是简单易懂。联合声明 | easyUnderstand |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://ts.xcatliu.com/basics/union-types.html
The text was updated successfully, but these errors were encountered: