Skip to content

fix(plugin): add async modifier when a reference is await import statement#3603

Merged
kamilmysliwiec merged 1 commit intonestjs:masterfrom
seonggukchoi:master
Nov 16, 2025
Merged

fix(plugin): add async modifier when a reference is await import statement#3603
kamilmysliwiec merged 1 commit intonestjs:masterfrom
seonggukchoi:master

Conversation

@seonggukchoi
Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

When the CLI compiles comments and types into Swagger decorators, it omits the async keyword in arrow functions that reference another DTO, even though those functions use the await keyword.
This change ensures that any arrow function using await within a DTO reference property is correctly prefixed with the async keyword.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

{
  // ...
  "compilerOptions": {
    "plugins": [{ "name": "@nestjs/swagger", "options": { "introspectComments": true, "esmCompatible": true } }]
  },
  // ...
}
import { Exclude, Expose } from 'class-transformer';

@Exclude()
export class Foo {
  /**
   * Foo
   */
  @Expose()
  bar!: Bar;
}

@Exclude()
export class Bar {
  /**
   * Property
   */
  @Expose()
  property!: string;
}
let Foo = class Foo {
    static _OPENAPI_METADATA_FACTORY() {
        return { bar: { required: true, type: () => (await import("./foo-bar.dto.js")).Bar, description: "Foo" } }; // There is no 'async' keyword at the arrow function.
    }
};

@seonggukchoi seonggukchoi marked this pull request as ready for review October 31, 2025 05:22
@kamilmysliwiec kamilmysliwiec merged commit d494c63 into nestjs:master Nov 16, 2025
1 check passed
@kamilmysliwiec
Copy link
Copy Markdown
Member

This caused a regression #3630

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants