Comments (3)
箭头函数可选参数
const xjjInfo: (name: string, age?: number) => void = (
name: string,
age: number
) => {
if (age) {
console.log(`小姐姐姓名:${name}, 今年:${age}岁`);
} else {
console.log(`小姐姐姓名:${name}`);
}
};
下面哪种写法更加合理
const xjjInfo: (name: string, age?: number) => void = (
...
- age: number
+ age?: number
) => {
...
};
from typescript-tutorial.
下面这句话是有问题的
- 需要注意的是,可选参数必须接在必需参数后面。换句话说,可选参数后面不允许再出现必需参数了
+ 需要注意的是,函数允许参数全部都是可选参数,可选参数后面不允许再出现必需参数
from typescript-tutorial.
下面这条断言语句会报错
(window as any).foo = 1;
from typescript-tutorial.
Related Issues (20)
- undefined和null赋值给number
- 写得不错哈~是不是还没写完,比如infer反推之类的好像还没涉及? HOT 3
- 重新整理目录和大纲 HOT 3
- 【示例代码错误】类 / ES6 中类的用法 / 属性和方法 部分示例代码 ,public 是typescript中的关键字
- 在线预览地址错误 HOT 5
- 文档页面显示BUG HOT 2
- 目录中漏了一页文章,为什么选择 TypeScript HOT 2
- 类型断言这一页“类型断言 vs 类型声明“里“但是 Cat 并不兼容 Animal”是否错误? HOT 2
- 微信群 HOT 2
- ts-node 多处报错
- 这边是把es6的类用作类型去判定的意思不,有点不理解
- 任意属性那个章节运行的效果和教程不同
- 在项目根目录下npm run start报错,提示找不到pagic/mod.ts文件 HOT 1
- 数组的类型这一节,有个类数组,我有个问题想问下。 HOT 3
- 一个接口中只能定义一个任意属性这里的age不能是可选的 HOT 1
- 元组一章
- 在线看文档的网站,github登录功能是不是有问题?
- 缺少调用签名相关内容
- 用pagic创建页面,创建部署有问题,build-and-deploy failed,gh-pages.yml没啥问题,跪求作者指导
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript-tutorial.