使用双引号 "
或单引号 '
来表示字符串。
关键字:string
let str: string = 'hello, world'
let res: string = "hello, world"
编译成js:
var str = 'hello, world';
var res = "hello, world";
模板字符串:
let name:string = 'xiaoming'
let str: string = `Hello, world, I am ${name}`
编译成js:
var name = 'xiaoming';
var str = "Hello, world, I am " + name;