Skip to content

Deferred function with explicit function #873

@hasezoey

Description

@hasezoey

Versions

  • System: linux / macos / windows
  • NodeJS: 0.0.0
  • Typescript: 0.0.0
  • Compiler / Transpiler: tsc / ts-node / ts-jest
  • Typegoose(NPM): 11.4.0
  • Typegoose(GIT): commithash
  • mongoose: 0.0.0
  • mongodb: 0.0.0
  • nestjs / nestjs-typegoose: 0.0.0 / 0.0.0
  • grahpql / type-graphql: 0.0.0 / 0.0.0

What is the Problem?

Typegoose currently does not properly handle explicit functions function() { } instead of () => {}

Code Example

class Testy {
  @prop({
    type: function () {
      return String;
    },
  })
  public test?: any;
}

Do you know why it happens?

because utils.ts:isConstructor tests for !isNullOrUndefined(obj.prototype?.constructor?.name), which exists in function() { } but not in () => {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedAny help would be appreciated

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions