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

Using Types with the metadata generator plugin doesn't seem to work #3016

Closed
2 of 4 tasks
Stono opened this issue Jul 23, 2024 · 1 comment
Closed
2 of 4 tasks

Using Types with the metadata generator plugin doesn't seem to work #3016

Stono opened this issue Jul 23, 2024 · 1 comment

Comments

@Stono
Copy link

Stono commented Jul 23, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I'm not sure if this should work, given this example:

export type Thing = {
  someNumber?: number
}

export class Test {
  public test2?: Thing

  public test3?: {
    someNumber?: number
  }
}

You get:

    '@nestjs/swagger': {
      models: [
        [
          import('lib/modules/chart-values/response'),
          {
            Test: {
              test2: { required: false, type: () => Object },
              test3: {
                required: false,
                type: () => ({
                  someNumber: { required: false, type: () => Number }
                })
              }
            }

Notice how the type is correct for test3 but not for test2, that just defaults to Object. This stops me reusing existing Types in the app and forces me to write a class version of them all.

Even weirder is if you change the type Thing to an interface, the property test2 doesn't get generated in the metadata at all.

Minimum reproduction code

See above

Steps to reproduce

No response

Expected behavior

Types to be honoured when generating metadata

Package version

7.3.1

NestJS version

10.3.9

Node.js version

22

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@kamilmysliwiec
Copy link
Member

type and interface "types" are not auto-converted to classes by the plugin

Please search through some of our old issues on this (this has been discussed several times in the past).

@nestjs nestjs locked and limited conversation to collaborators Jul 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants