Open david2tdw opened 4 years ago
编译并执行ts文件:
base-type.ts
let name: string = 'tdw'
let age: number = 12
let sen: string = `hello , my name is ${name}, i will be ${age + 1} years `
console.log(sen + name)
export {}
代码中添加export {}的原因: 如何在typescript中解决 error TS2451: Cannot redeclare block-scoped variable 'name'
执行:
C:\Users\RS\Desktop\test\vue\typescript>ts-node base-type.ts
hello , my name is tdw, i will be 13 years tdw
初始化一个typescript项目: