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

Mapped Types not working in the webpack browser shim #2610

Closed
1 task done
maciejgoscinski opened this issue Sep 11, 2023 · 1 comment
Closed
1 task done

Mapped Types not working in the webpack browser shim #2610

maciejgoscinski opened this issue Sep 11, 2023 · 1 comment
Labels

Comments

@maciejgoscinski
Copy link

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

Mapped types do not work in the browser with the browser shim from #1505

In the shim:

exports.PartialType = PartialType;
function PickType() {
    return () => { };
}

Usage as per docs:

export class UpdateCatDto extends PartialType(CreateCatDto) {}

Results in

Uncaught TypeError: Class extends value () => {} is not a constructor or null

Describe the solution you'd like

DTOs should be usable outside of the backend.
The browser shim should at least properly return blank extendable classes to allow sharing the dto package with frontends.
Even better, the swagger annotations should be a separate module without dependencies on nestjs core etc.

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

Using DTOs outside of the backend project.

@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue? Replacing return () => {} with return class {} should be sufficient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants