Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deferred function with explicit function #873

Open
hasezoey opened this issue Jul 21, 2023 · 1 comment
Open

Deferred function with explicit function #873

hasezoey opened this issue Jul 21, 2023 · 1 comment
Labels
bug Something isn't working help wanted Any help would be appreciated

Comments

@hasezoey
Copy link
Member

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 () => {}

@hasezoey hasezoey added the bug Something isn't working label Jul 21, 2023
@hasezoey hasezoey changed the title Defferred function with explicit function Deferred function with explicit function Jul 21, 2023
@hasezoey
Copy link
Member Author

i dont think this is properly fixable because there is no universal way to differentiate between native functions (and mocked native functions) and other types like mongoose's Schema.Types.* and Types.* which are callable without new (and dont have class in their toString representation)

because of those same reasons i also dont think there is a proper way to add a error for this

@hasezoey hasezoey added the help wanted Any help would be appreciated label Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Any help would be appreciated
Projects
None yet
Development

No branches or pull requests

1 participant