1.类型声明空间
类型声明空间可以作为类型注解使用
class Foo {}
interface Bar {}
type Bas = {};
let foo: Foo;
let bar: Bar;
let bas: Bas;
interface Bar不能把它作为变量使用
interface Bar {}
const bar = Bar; // Error: "cannot find name 'Bar'"
2.变量声明空间
class Foo {}
const someVar = Foo;
const someOtherVar = 123;
class Foo既可以作为类型声明空间又可作为变量声明空间
用var, const,let声明的不能作为类型注解
const foo = 123;
let bar: foo; // ERROR: "cannot find name 'foo'"