npm install -g ts-node
数据类型
TS的数据类型
// ES6的数据类型:
基本数据类型:Boolean,Number,String,Symbol,undefined,null...}
const teacher: Person = {
name: 'jeskson'
}
基础类型和对象类型
// 基础类型 null, undefined, symbol, boolean,...和 null
// 一旦声明了undefined,就不能再被赋值为任何其他的数据类型了
let udf: undefined = undefined
let nu: null = null
let...undf: undefined = 1
// Type '1' is not assignable to type 'undefined'.
// 默认情况下,undefined和null也不能被赋值给任何其他类型...在TS中,undefined和null是任何类型的子类型,所以可以被赋值给其他类型
设置允许被赋值为其他类型
打开tsconfig.js,将strictNullChecks = false(默认true