Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 如何从类型化数组中提取类型_Typescript_Typescript2.0 - Fatal编程技术网

Typescript 如何从类型化数组中提取类型

Typescript 如何从类型化数组中提取类型,typescript,typescript2.0,Typescript,Typescript2.0,我正在导入一个文件,该文件只导出我正在寻找的ie接口的类型化数组 导入的file.ts interface IOrg { name: string address: string phone: string rank: number } export type OrgArray = IOrg[] 我真的只想使用类型IOrg是否有任何方法可以从OrgArray:IOrg[]中提取它?您可以使用类型查询: import { OrgArray} from '. /f

我正在导入一个文件,该文件只导出我正在寻找的ie接口的类型化数组

导入的
file.ts

interface IOrg {
    name: string
    address: string
    phone: string
    rank: number
}

export type OrgArray = IOrg[]

我真的只想使用类型
IOrg
是否有任何方法可以从
OrgArray:IOrg[]
中提取它?

您可以使用类型查询:

import { OrgArray} from '. /file'
type IOrg = OrgArray [number] 
  • 制作一个index.d.ts文件

  • 在全局Daclariation中添加接口/
    接口IOrg{
    名称:string
    地址:string
    电话:string
    排名:数字
    }