"declaring type" 和 "type" 有什么区别
What is the difference between "declaring type" and "type"
我在一些声明文件中遇到过这种语法
interfaces.d.ts
...
declare type TStringOrNumber = string | number
declare interface IObj {
name: string
value: TStringOrNumber
}
我声明了一个变量并为它添加了一个类型,但对我来说用它来打字没有意义。
declare
关键字有任何理由吗?
您仍然可以使用它,导出它,扩展它等等。
有什么区别吗?
没有区别。参见 this comment。
我在一些声明文件中遇到过这种语法
interfaces.d.ts
...
declare type TStringOrNumber = string | number
declare interface IObj {
name: string
value: TStringOrNumber
}
我声明了一个变量并为它添加了一个类型,但对我来说用它来打字没有意义。
declare
关键字有任何理由吗?
您仍然可以使用它,导出它,扩展它等等。
有什么区别吗?
没有区别。参见 this comment。