0
我使用apollo-codegen从我的项目中嵌入tsx文件的GraphQL查询生成TypeScript类型。所产生的类型的一个例子是:Typescript:我如何引用一个匿名类型,它是一个命名类型的子类?
export type MooQuery = {
wines: {
edges: Array< {
node: {
nodeId: string,
wineName: string | null,
wineryId: number | null,
vintageId: number | null,
uomId: number | null
},
} | null > | null,
} | null,
};
我将经过“节点”,以呈现为每个节点阵营成分的辅助方法。我想做类似的事情:
renderHelper(node: MooQuery.wines.edges.node) { // this won't work
}
有没有办法实现我想要的?我想甚至有意义吗?
这看起来不错,谢谢!但是我得到一个很奇怪的错误:错误TS2339:属性'边缘'在类型'{边缘:({node:{nodeId:string; wineName:string | null; wineryId:number | null; vintageId:.. '。' - 看起来和我矛盾?! –
我不能重现那个,我建议你打开一个新的问题,并链接到这个。 –
请问,谢谢:) –