typescript 参数类型
var myname:string = 'wzn'
=>
"use strict";
var myname = 'wzn';


var age:number = 13
=>
"use strict";
var age = 13;
var man:boolean = true
=>
"use strict";
var man = true;
function test(): void{}
=>
"use strict";
function test() {
}
这个标示不需要任何返回值
function test(): string{
return ''
}
=>
"use strict";
function test() {
return '';
}
function test(name: string){}
test('')
=>
"use strict";
function test(name) { }
test('');
class Person {
name: string;
age: number
}
var zhangsan: Person = new Person();
zhangsan.name = 'zhangsna',
zhangsan.age = 19
function test(a: string, b: string, c: string) {
console.log(a);
console.log(b);
console.log(c);
}
test('xx', 'yy', 'zz')
function test(a: string, b: string, c: string='zina') {
console.log(a);
console.log(b);
console.log(c);
}
test('xx', 'yy')
function test(a: string, b?: string, c: string='zina') {
console.log(a);
console.log(b);
console.log(c);
}
function test(a: string, b?: string, c: string='zina') {
console.log(a);
console.log(b);
console.log(c);
}
test('xx')
typescript 参数类型的更多相关文章
- TypeScript泛型类 - 把类作为参数类型的泛型类
/* TypeScript泛型类 - 把类作为参数类型的泛型类 */ /* 泛类:泛型可以帮助我们避免重复的代码以及对不特定数据类型的支持(类型校验),下面我们看看把类当做参数的泛型类 1.定义个类 ...
- C# vs TypeScript - 高级类型
总目录 从C#到TypeScript - 类型 从C#到TypeScript - 高级类型 从C#到TypeScript - 变量 从C#到TypeScript - 接口 从C#到TypeScript ...
- 从C#到TypeScript - 高级类型
C# vs TypeScript - 高级类型 上一篇讲了基础类型,基本上用基础类型足够开发了,不过如果要更高效的开发,还是要看下高级类型,这篇和C#共同点并不多,只是延用这个主题. 联合类型 可以从 ...
- TypeScript基础类型,类实例和函数类型声明
TypeScript(TS)是微软研发的编程语言,是JavaScript的超集,也就是在JavaScript的基础上添加了一些特性.其中之一就是类型声明. 一.基础类型 TS的基础类型有 Boolea ...
- typescript枚举,类型推论,类型兼容性,高级类型,Symbols(学习笔记非干货)
枚举部分 Enumeration part 使用枚举我们可以定义一些有名字的数字常量. 枚举通过 enum关键字来定义. Using enumerations, we can define some ...
- TypeScript 之 类型推导
https://m.runoob.com/manual/gitbook/TypeScript/_book/doc/handbook/Type%20Inference.html 类型推导:发生在初始化变 ...
- TypeScript 高级类型 接口(interface)
在代码的实现或者调用上能设定一定的限制和规范,就像契约一样.通常,我们把这种契约称为接口. TypeScript的核心原则之一是对值所具有的结构进行类型检查. 有时称为“鸭式辨型法”或“结构性子类型化 ...
- TypeScript入门三:TypeScript函数类型
TypeScript函数类型 TypeScript函数的参数 TypeScript函数的this与箭头函数 TypeScript函数重载 一.TypeScript函数类型 在上一篇博客中已经对声明Ty ...
- 编写TypeScript工具类型,你需要知道的知识
什么是工具类型 用 JavaScript 编写中大型程序是离不开 lodash 工具的,而用 TypeScript 编程同样离不开工具类型的帮助,工具类型就是类型版的 lodash .简单的来说,就是 ...
随机推荐
- [LeetCode] 227. Basic Calculator II 基本计算器 II
Implement a basic calculator to evaluate a simple expression string. The expression string contains ...
- [LeetCode] 815. Bus Routes 公交路线
We have a list of bus routes. Each routes[i] is a bus route that the i-th bus repeats forever. For e ...
- Bazel安装及使用入门
Bazel [文档][https://docs.bazel.build/versions/1.1.0/bazel-overview.html] MacOS安装 brew tap bazelbuild/ ...
- Laravel 数据库实例教程 —— 使用查询构建器对数据库进行增删改查
原文地址:https://blog.csdn.net/lmy_love_/article/details/72832259 获取查询构建器很简单,还是要依赖DB门面,我们使用DB门面的table方法, ...
- C/C++ 面试-面向对象的特性
面向对象的三大特性 此文只是简单介绍一下三大特性 详细介绍在: 封装:http://www.cnblogs.com/52why/p/7631381.html 继承:http://www.cnblo ...
- eNSP上配置RIPv2的认证
实验拓扑图如下 首先我们对各个路由器及终端PC进行基本ip设置 然后我们在路由器上设置RIPv2协议 并添加要通告的网段 然后我们查看路由表查看路由器已经学到的路由 接下来我们用R3模拟攻击者 通过 ...
- ADB 常用命令及详解
1.pull文件 adb pull (文件路径) (想要pull的路径) MacBook-Pro:~ caris$ adb pull /sdcard/Android/data/com.xiwi.log ...
- 小程序重置index,重置item
重置index,重置item <block wx:for="{{index_data.banner_list}}" wx:for-index="idx" ...
- Jenkins运行python脚本出现 configparser.NoSectionError: No section: 'XXXXXX'
原来的代码如下: def get_test_config(tag, key, config="config.ini"): cf = configparser.ConfigParse ...
- LeetCode 331. 验证二叉树的前序序列化(Verify Preorder Serialization of a Binary Tree) 27
331. 验证二叉树的前序序列化 331. Verify Preorder Serialization of a Binary Tree 题目描述 每日一算法2019/5/30Day 27LeetCo ...