我可以在一个文件中包含以下对象
type MyType = { createdDate: Date }
export const myObject: MyType = { createdDate: new Date() }
我有兴趣在导入MyType
时导入myObject
。
答案 0 :(得分:3)
不必输出类型。
您可以通过以下方式推断出类型:
import typeof { MyType } from 'file';
答案 1 :(得分:0)
将您的type
声明更改为以下内容:
export type MyType = { createdDate: Date }
然后,在任何其他文件中,您可以执行以下操作:
import type MyType from 'file'
将'file'
替换为您文件的实际位置。