0
votes

I am getting a very strange typescript error and I have no clue why this is happening:

I have a a function "cleanArgs" works and is typed properly. But for some reason when I use this function within the class method there's an error on the method:

Return type of public method from exported class has or is using name 'CreatePlanGroupArgs' from external module "./project/file.ts" but cannot be named.ts(4053)

Return type of public method from exported class has or is using name 'ReadPlanGroupArgs' from external module "./project/file.ts" but cannot be named.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)
  }
}

The CreatePlanArgs class looks something like this:

@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
}
1

1 Answers

0
votes

For some reason, I had to break out each of the classes from CreatePlanArgs into new file.