函式引數和返回值中的型別。字串

例:

function hello(name: string): string {
    return `Hello ${name}!`;
}

這裡的語法 name: string 意味著該函式可以接受一個 name 引數,這個引數只能是字串而 (...): string { 意味著返回值只能是一個字串

用法:

hello('StackOverflow Documentation') // will be return Hello StackOverflow Documentation!