我正在尝试在打字稿文件中创建更简化的输出,*.d.ts这些输出包含在我的模块代码的捆绑版本中。这些文件是通过涉及 typescript 编译器、babel 和 rollup 的链生成的。我也使用relay和graphql,但我认为这不会对问题产生太大影响。
举个例子,在.tsx源代码中,我有这样的内容:
import { graphql } from 'babel-plugin-relay/macro'
// produces some generated code
graphql`fragment task_model on Task { id message createdAt deadline modifiers { hard medium easy } }`
// There is a generated type for this fragment, but it is a little ugly
import { task_model } from './__generated__/task.graphql'
// We can "correct" the type information and export it with a nicer name
export type Task = Readonly<Omit<task_model & { …Run Code Online (Sandbox Code Playgroud)