export function makeMap (
str: string,
expectsLowerCase?: boolean
): (key: string) => true | void {
const map = Object.create(null)
const list: Array<string> = str.split(',')
for (let i = 0; i < list.length; i++) {
map[list[i]] = true
}
return expectsLowerCase
? val => map[val.toLowerCase()]
: val => map[val]
}
这是一段es6的代码“()”后面的“:”号是什么意思····es6有这样的写法吗??
求大神
这是typescript的写法,意思是返回值的类型。typescript是es6的超集,有强类型功能,
这段代码的大概意思就是
定义一个函数,函数有一个返回值,这个返回值也是个函数,然后对这个返回函数做了一个定义,也就是在冒号后面的定义
(key: string) => true | void