【发布时间】:2020-04-05 11:27:54
【问题描述】:
我收到一个非常奇怪的打字错误,我不知道为什么会这样:
我有一个函数“cleanArgs”可以正常工作并且输入正确。但是由于某种原因,当我在类方法中使用此函数时,该方法出现错误:
导出类的公共方法的返回类型已经或正在使用来自外部模块“./project/file.ts”的名称“CreatePlanGroupArgs”,但不能命名为.ts(4053)
导出类的公共方法的返回类型已经或正在使用来自外部模块“./project/file.ts”的名称“ReadPlanGroupArgs”,但不能命名为.ts(4053)
import { CreatePlanArgs } from 'createPlan/CreatePlanArgs'
import { Helper } from 'helper/Helper'
// this is typed properly
const cleanArgs = (createPlanArgs: CreatePlanArgs) => {
const { planGroup, ...plan } = Helper.sanitize(createPlanArgs)
const create = Helper.sanitize(planGroup.create)
const find = Helper.sanitize(planGroup.find)
const pg = { create, find }
return { planGroup: pg, plan }
}
export class Process {
constructor (
private readonly args: {
createPlanArgs: CreatePlanArgs;
}
) {}
cleanArgs () { // < the error is on this line
return cleanArgs(this.args.createPlanArgs)
}
}
CreatePlanArgs 类看起来像这样:
@InputType()
class CreatePlanGroupArgs {
@Field(() => String)
name: string
}
@InputType()
class ReadPlanGroupArgs {
@Field(() => String)
uuid: string
}
@InputType()
class SelectPlanGroupArgs {
@Field(() => ReadPlanGroupArgs, { nullable: true })
find: ReadPlanGroupArgs
@Field(() => CreatePlanGroupArgs, { nullable: true })
create: CreatePlanGroupArgs
}
@ArgsType()
export class CreatePlanArgs {
@Field(() => SelectPlanGroupArgs)
planGroup: SelectPlanGroupArgs
}
【问题讨论】:
标签: typescript