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

IntersectionType clause for more than 4 classes is not available in the npm version #860

Closed
2 of 4 tasks
marekbrainhub opened this issue Sep 22, 2022 · 4 comments
Closed
2 of 4 tasks

Comments

@marekbrainhub
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Using IntersectionType on more than 4 classes produces a TypeScript error.

Minimum reproduction code

n/a

Steps to reproduce

class ClassA {}
class ClassB {}
class ClassC {}
class ClassD {}
class ClassE {}
IntersectionType(ClassA, ClassB, ClassC, ClassD, ClassE)
<snip>:10:50 - error TS2554: Expected 2-4 arguments, but got 5.

8  IntersectionType(ClassA, ClassB, ClassC, ClassD, ClassE)
                                                    ~~~~~~

Expected behavior

TypeScript does not complain about more than four arguments.

Package version

1.1.0

Node.js version

18.7.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

I suspect this is because the declaration file in the compiled library does not have the wildcard clause. I'm not sure if that is intended or if there is a workaround.

@micalevisk
Copy link
Member

micalevisk commented Sep 22, 2022

that's expected

export function IntersectionType<A, B>(
target: Type<A>,
source: Type<B>,
): MappedType<A & B>;
export function IntersectionType<A, B, C>(
target: Type<A>,
sourceB: Type<B>,
sourceC: Type<C>,
): MappedType<A & B & C>;
export function IntersectionType<A, B, C, D>(
target: Type<A>,
sourceB: Type<B>,
sourceC: Type<C>,
sourceD: Type<D>,
): MappedType<A & B & C & D>;

not sure if we should add more one level

@jmcdo29
Copy link
Member

jmcdo29 commented Sep 22, 2022

We could add another level, or you could just nest the IntersectionType classes. IntersectionType(ClassA, ClassB, IntersectionType(ClassC, ClassD), ClassE) ad infinitum as necessary

@micalevisk
Copy link
Member

micalevisk commented Sep 22, 2022

indeed. That sounds better to me. Otherwise someone may request another level again and again

@kamilmysliwiec
Copy link
Member

#860 (comment)

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

No branches or pull requests

4 participants