Git Product home page Git Product logo

mapped-types's People

Contributors

borntraegermarc avatar caucik avatar dependabot[bot] avatar kamilmysliwiec avatar kpkonghk01 avatar kuanwenchen avatar micalevisk avatar mikerossxyz avatar opportunityliu avatar renovate-bot avatar renovate[bot] avatar robertisaac avatar tf3 avatar tony133 avatar trycontrolmymind avatar wodcz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mapped-types's Issues

Remove @nestjs/common dependency

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

Hi,

I am currently trying to build a monorepo (using nrwl/nx) with both nestjs as a backend and nextjs as a frontend. My idea was to write DTOs in a single shared lib across my backend and frontend. The problem is that @nestjs/mapped-types uses @nestjs/common and I don't think it would be the best idea to have it has a dependency in my client side application.

But since I am fairly new to this ecosystem I could be mistaken. Maybe since it is in a monorepo, the tree shaking that should occur during the build of my nextjs application would remove the unused dependencies? Or is it not that simple?

I still have the same problem with nestjs/swagger dependency which I use to decorate my DTOs, but I think I could work around it using the cli plugin but that's just another matter I guess.

Describe the solution you'd like

Make @nestjs/mapped-types independent of @nestjs/common if possible

Teachability, documentation, adoption, migration strategy

N/A

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

It would make using @nestjs/mapped-types possible on client side applications

inherit methods in type helprs

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

This feature is related to my issue that closed without any solution.

Previous issue:
#471

Describe the solution you'd like

We can create inheritMethods function like this:

export function inheritMethods(
  parentClass: Type<any>,
  targetClass: Function,
  isPropertyInherited?: (key: string) => boolean,
) {
  Object.getOwnPropertyNames(parentClass.prototype)
    .filter(
      (propertyName) =>
        !isPropertyInherited || isPropertyInherited(propertyName),
    )
    .forEach((name) => {
      Object.defineProperty(
        targetClass.prototype,
        name,
        Object.getOwnPropertyDescriptor(parentClass.prototype, name) ||
          Object.create(null),
      );
    });
}

and edit omit-type.helper.ts like this:

import { Type } from '@nestjs/common';
import { MappedType } from './mapped-type.interface';
import {
  inheritPropertyInitializers,
  inheritTransformationMetadata,
  inheritValidationMetadata,
  inheritMethods,
} from './type-helpers.utils';

export function OmitType<T, K extends keyof T>(
  classRef: Type<T>,
  keys: readonly K[],
): MappedType<Omit<T, typeof keys[number]>> {
  const isInheritedPredicate = (propertyKey: string) =>
    !keys.includes(propertyKey as K);

  abstract class OmitClassType {
    constructor() {
      inheritPropertyInitializers(this, classRef, isInheritedPredicate);
    }
  }

  inheritValidationMetadata(classRef, OmitClassType, isInheritedPredicate);
  inheritTransformationMetadata(classRef, OmitClassType, isInheritedPredicate);
  inheritMethods(classRef, OmitClassType, isInheritedPredicate);

  return OmitClassType as MappedType<Omit<T, typeof keys[number]>>;
}

and add inheritMethods(classRef, OmitClassType, isInheritedPredicate); too all type helpers.

Teachability, documentation, adoption, migration strategy

We just need to add this function in type-helpers.utils.ts

export function inheritMethods(
  parentClass: Type<any>,
  targetClass: Function,
  isPropertyInherited?: (key: string) => boolean,
) {
  Object.getOwnPropertyNames(parentClass.prototype)
    .filter(
      (propertyName) =>
        !isPropertyInherited || isPropertyInherited(propertyName),
    )
    .forEach((name) => {
      Object.defineProperty(
        targetClass.prototype,
        name,
        Object.getOwnPropertyDescriptor(parentClass.prototype, name) ||
          Object.create(null),
      );
    });
}

and use it in all type-helpers.

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

We can now inherit methods using type helpers

Module '"@nestjs/mapped-types"' has no exported member 'PartialType'.

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I follow along the official NestJs Course. In the input validation chapter, mapped-types are installed and the UpdateCoffeeDto class should extend PartialType.

However i cannot import the PartialType clase, because of the error message:

Module '"@nestjs/mapped-types"' has no exported member 'PartialType'.

Minimum reproduction code

https://github.com/GBeushausen/nestjs-course

Steps to reproduce

No response

Expected behavior

The PartialType class should be importable

Package version

?

Node.js version

14.15.5

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

extends with OmitType removes methods from Base class

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When extends using OmitType(), the derived class does not contain Base class methods.

Expected behavior

Expect derived class to have parent class methods

Minimal reproduction of the problem with instructions

import { IsString } from 'class-validator';
import { OmitType } from '@nestjs/mapped-types';
import { plainToClass } from 'class-transformer';

class BaseClass {
  @IsString()
  a: string;

  @IsString()
  b: string;

  someMethod() {
    return 'this is a method';
  }
}

class DerivedClass extends OmitType(BaseClass, ['a']) {}

const instance = plainToClass(DerivedClass, {
  b: 'some value',
});

console.log(instance.someMethod());

expect this code to log this is a method but it will throw the following error:

console.log(instance.someMethod());
                     ^
TypeError: instance.someMethod is not a function
...

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

It should work as normal extends.

Environment


Nest version: ^8.0.0
@nestjs/mapped-types:  ^1.0.0

 
For Tooling issues:
- Node version: v14.16.1
- Platform:  Mac

Others:

Class 'CreateUserDto' incorrectly extends base class 'RemoveFieldsWithType<Partial<User>, Function>'. Property 'status' is optional in type 'CreateUserDto' but required in type 'RemoveFieldsWithType<Partial<User>, Function>'

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

In version 2.0.0 we are getting this error. user Partial

Minimum reproduction code

https://github.com/nestjs/mapped-types

Steps to reproduce

install @nestjs/mapped-types with 2.0.0 version
User "Partial" method from it.
Getting the error like: Class 'CreateUserDto' incorrectly extends base class 'RemoveFieldsWithType<Partial, Function>'.
Property 'status' is optional in type 'CreateUserDto' but required in type 'RemoveFieldsWithType<Partial, Function>'.

Expected behavior

This error should not come.

Package version

2.0.0

Node.js version

14.21.3

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Update security dependencies

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

This repo has an hardcoded dependency to "class-validator:0.13.2" which is flagged as security risk. I can't update my project as this dependency breaks the update.

Describe the solution you'd like

Update the dependency to version "0.14.0".

Teachability, documentation, adoption, migration strategy

NA

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

So I can update my project to no include dependencies that are flagged as security risks.

Use a more specific type for mapped types

I'm submitting a...


[ ] Regression 
[ ] Bug report
[X] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

class A {
    constructor(a: string) {}
}

class B {
    constructor(b: number) {}
}

class C extends IntersectionType(A, B) {
    constructor() {
        super();// <- hint `Type(...args: any[]): A & B` shown here
    }
}

I've checked the source code, found that for each mapped type, a new class with no constructor is created, and "base"(?) classes's constructor are never called.

Expected behavior

Add a new type

export type MappedType<T> = new () => T

as return type of mapped types.

Minimal reproduction of the problem with instructions

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

This can clearify the constuctor parameter of mapped types, implies that constructors of base classes will not be called.

Environment


Nest version: 7.1.3

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Create build using latest code

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

The code published to NPM does not correspond with github code, root package.json doesn't seem to be receiving version bumps to properly publish

Minimum reproduction code

N/A

Steps to reproduce

yarn add @nestjs/mapped-types

Expected behavior

Installing this package should use the latest version. Bumping dependency versions in the package.json should at some point result in a build that can be pulled down and installed

Package version

1.0.0

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

I am specifically attempting to resolve the class-transformer warnings I am getting while installing. The fix appears to already be in the code here, but I can't pull it in

Cannot build with Webpack

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When running with nest start, it works as expected. When running with build --webpack, it fails because it cannot find some path. This seems to have been removed by upstream (typestack/class-transformer#563)

Implemented the proposed solution in the link

Minimum reproduction code

https://github.com/hjf/mapped-types-bug

Steps to reproduce

  1. yarn
  2. yarn build --webpack
  3. see error

Expected behavior

It should build with no errors

Package version

1.0.0

Node.js version

14.17.4

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Strange behaviour of IntersectionType() when overwrite properties

#339 (comment)
After comment @jmcdo29 I've checked override behaviour and found a bug

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

class ClassA {
    @MinLength(10)
    @Transform(({ value }) => value + '_transformed')
    login = 'default';

    @Transform(({ value }) => value + '_transformed')
    @MinLength(10)
    password!: string;
  }

  class ClassB {
    @IsString()
    @Transform(({ value }) => value + '_transformed2')
    login = 'default2';

    @Transform(({ value }) => value + '_transformed')
    @MinLength(5)
    lastName!: string;
  }

class UpdateUserDto extends IntersectionType(ClassA, ClassB) {}

// 1) overwrite property initializers
      const updateUserDto = new UpdateUserDto();
// Expected: "default2"
// Received: "default"
      expect(updateUserDto.login).toEqual('default2');

// 2) Is it better to remove older ValidationMetadata decorator properties from ClassA?
const validationErrors = await validate(updateDto);
console.log(validationErrors[0]);

ValidationError {
    target: UpdateUserDto { login: 'default', password: '1234567' },
    value: 'default',
    property: 'login',
    children: [],
    constraints: {
      minLength: 'login must be longer than or equal to 10 characters'
    }
  }

Expected behavior

1) override property initializers 
const updateUserDto = new UpdateUserDto();
// Expected: "default2"
console.log(updateUserDto.login);

Minimal reproduction of the problem with instructions

master...trycontrolmymind:test/intersection-overwrite
git clone [email protected]:trycontrolmymind/mapped-types.git
yarn test:e2e

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

If anyone wants to rewrite behaviour of the proporty from ClassB to ClassA, he will encounter with strange override behaviour.

Environment


- Nestjs v7.6.15
- Platform:  Linux
- Nodejs: v14.16.0

Others:

Extending using PartialType, OmitType… doesn't copy properties decorators

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Hi, I've noticed that when extending a class (Child) from another (Parent), using PartialType (for example, but this is the same with the other wrappers) doesn't add the Parent properties decorators to the Child.

How did I notice this ? I've some swagger @ApiProperty() decorators in my CreateDto, and when extending the UpdateDto extends PartialType(CreateDto) {}, the UpdateDto doesn't have any properties in the Swagger.``

However, removing the PartialType wrapper "fix" the issue.

Reproduction

https://stackblitz.com/edit/nestjs-issue-minimum-repro-starter-2zmyjl

Expected behavior

All the Parent properties decorators should be copied to the Child.

Package version

2.0.2

Node.js version

18.16.1

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

PartialType can't work with class-validator

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

UpdateUserDto allow { name: null } thereby giving validation issues
QueryFailedError: SqliteError: NOT NULL constraint failed: user.name

For ORM, null and undefined usually have different meanings

  • usersRepository.update({ name: null }) means update user.name to null
  • usersRepository.update({ name: undefined }) means don't update user.name

I think that PartialType should not use the @IsOptional() decorator, but should use @ValidateIf((_object, value) => value !== undefined)

Minimum reproduction code

https://github.com/yodhcn/mapped-types-example

Steps to reproduce

  1. npm i
  2. npm start
  3. POST http://localhost:3000/users { "name": "user_1", "email": "[email protected]", "password": "12345678" }
  4. PATCH http://localhost:3000/users { "name"; null }
  5. see error QueryFailedError: SqliteError: NOT NULL constraint failed: user.name

Expected behavior

UpdateUserDto should allow { name: undefined }, but should not allow { name: null }

Package version

1.1.0

Node.js version

16.17.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Install fails when class-validtor 0.14.0 already installed

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

First install class-validator: npm install class-validator. This will install currently version 0.14.0
Afterwards install mapped-types: npm install @nestjs/mapped-types

This fails with a npm error unable to resolve dependency tree.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/class-validator
npm ERR!   class-validator@"^0.14.0" from the root project
npm ERR!   peerOptional class-validator@"*" from @nestjs/[email protected]
npm ERR!   node_modules/@nestjs/common
npm ERR!     @nestjs/common@"^9.0.0" from the root project
npm ERR!     peer @nestjs/common@"^7.0.8 || ^8.0.0 || ^9.0.0" from @nestjs/[email protected]
npm ERR!     node_modules/@nestjs/mapped-types
npm ERR!       @nestjs/mapped-types@"^1.2.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional class-validator@"^0.11.1 || ^0.12.0 || ^0.13.0" from @nestjs/[email protected]
npm ERR! node_modules/@nestjs/mapped-types
npm ERR!   @nestjs/mapped-types@"^1.2.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Just following your NestJS course.
Added some random nestjs example public repo in which it also occurs.

Minimum reproduction code

https://github.com/hantsy/nestjs-rest-sample

Steps to reproduce

  1. npm i class-validator
  2. npm i @nestjs/mapped-types

Expected behavior

Should install without errors.

Package version

1.2.0

Node.js version

16.19.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Default value of DTO Properties are not working with IntersectionType and ValidationPipe

I'm submitting a...


[ ] Regression 
[ x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When two DTO classes are combine into one through IntersectionType(A,B), default values are missing.

Controller

import {
  Controller,
  Get,
  Post,
  Body,
  UsePipes,
  ValidationPipe,
  Logger,
} from '@nestjs/common';
import { AppService } from './app.service';
import { combineDto } from './dto/CreateUserDto.dto';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  getHello(): string {
    return this.appService.getHello();
  }

  @Post()
  @UsePipes(new ValidationPipe({ transform: true }))
  create(@Body('table') dto: combineDto) {
    Logger.debug(dto);
    return 'This action adds a new user';
  }
}

DTO:

import { IsString, IsArray } from 'class-validator';
import { IntersectionType } from '@nestjs/swagger';

export class DtoA {
  @IsArray()
  table: number[] = [1, 2, 3, 4];
}

export class DtoB {
  @IsString()
  text: string = 'test';
}

export class combineDto extends IntersectionType(DtoA, DtoB) {}

Request:

:PORT=3000

POST http://localhost::PORT/
Content-Type: application/json

[]

Response

{
  "statusCode": 400,
  "message": [
    "table must be an array",
    "text must be a string"
  ],
  "error": "Bad Request"
}
// POST http://localhost:3000/
// HTTP/1.1 400 Bad Request
// X-Powered-By: Express
// Content-Type: application/json; charset=utf-8
// Content-Length: 101
// ETag: W/"65-SZ7wO0aLvWpcz1ckl5CCuSRtItI"
// Date: Mon, 26 Oct 2020 16:45:12 GMT
// Connection: keep-alive
// Request duration: 0.051707s

For one DTO:

  @Post()
  @UsePipes(new ValidationPipe({ transform: true }))
  create(@Body('table') dto: DtoA) {
    Logger.debug(dto);
    return 'OK';
  }

Response

OK
<!-- POST http://localhost:3000/ -->
<!-- HTTP/1.1 201 Created -->
<!-- X-Powered-By: Express -->
<!-- Content-Type: text/html; charset=utf-8 -->
<!-- Content-Length: 2 -->
<!-- ETag: W/"2-nOO9QiTIwXgNtWtBJezz8kv3SLc" -->
<!-- Date: Mon, 26 Oct 2020 16:50:52 GMT -->
<!-- Connection: keep-alive -->
<!-- Request duration: 0.021819s -->

Log:

[5:50:04 PM] File change detected. Starting incremental compilation...

[5:50:04 PM] Found 0 errors. Watching for file changes.

[Nest] 12954   - 10/26/2020, 5:50:04 PM   [NestFactory] Starting Nest application...
[Nest] 12954   - 10/26/2020, 5:50:04 PM   [InstanceLoader] AppModule dependencies initialized +14ms
[Nest] 12954   - 10/26/2020, 5:50:04 PM   [RoutesResolver] AppController {}: +5ms
[Nest] 12954   - 10/26/2020, 5:50:04 PM   [RouterExplorer] Mapped {, GET} route +3ms
[Nest] 12954   - 10/26/2020, 5:50:04 PM   [RouterExplorer] Mapped {, POST} route +1ms
[Nest] 12954   - 10/26/2020, 5:50:04 PM   [NestApplication] Nest application successfully started +3ms
[Nest] 12954   - 10/26/2020, 5:50:04 PM    Listen to port : 3000 +5ms
[Nest] 12954   - 10/26/2020, 5:50:52 PM   Object:
{
  "table": [
    1,
    2,
    3,
    4
  ]
}
 +47510ms

Expected behavior

We should be able to combine two classes, with default value properties.
Combined class shall get all default values;

export class combineDto extends IntersectionType(DtoA, DtoB) {

  @IsArray()
  table: number[] = [1, 2, 3, 4];

  @IsString()
  text: string = 'test';
}
OK
<!-- POST http://localhost:3000/ -->
<!-- HTTP/1.1 201 Created -->
<!-- X-Powered-By: Express -->
<!-- Content-Type: text/html; charset=utf-8 -->
<!-- Content-Length: 2 -->
<!-- ETag: W/"2-nOO9QiTIwXgNtWtBJezz8kv3SLc" -->
<!-- Date: Mon, 26 Oct 2020 17:43:57 GMT -->
<!-- Connection: keep-alive -->
<!-- Request duration: 0.053858s -->
[6:44:15 PM] File change detected. Starting incremental compilation...

[6:44:16 PM] Found 0 errors. Watching for file changes.

[Nest] 20063   - 10/26/2020, 6:44:16 PM   [NestFactory] Starting Nest application...
[Nest] 20063   - 10/26/2020, 6:44:16 PM   [InstanceLoader] AppModule dependencies initialized +13ms
[Nest] 20063   - 10/26/2020, 6:44:16 PM   [RoutesResolver] AppController {}: +5ms
[Nest] 20063   - 10/26/2020, 6:44:16 PM   [RouterExplorer] Mapped {, GET} route +3ms
[Nest] 20063   - 10/26/2020, 6:44:16 PM   [RouterExplorer] Mapped {, POST} route +2ms
[Nest] 20063   - 10/26/2020, 6:44:16 PM   [NestApplication] Nest application successfully started +2ms
[Nest] 20063   - 10/26/2020, 6:44:16 PM    Listen to port : 3000 +5ms
test
combineDto { table: [ 1, 2, 3, 4 ], text: 'test' }
[Nest] 20063   - 10/26/2020, 6:45:59 PM   Object:
{
  "table": [
    1,
    2,
    3,
    4
  ],
  "text": "test"
}
 +103031ms

Minimal reproduction of the problem with instructions

(https://github.com/tosiek88/nest_research)

Environment


    "@nestjs/common": "^7.0.0",
    "@nestjs/core": "^7.0.0",
    "@nestjs/mapped-types": "^0.1.0",
    "@nestjs/platform-express": "^7.0.0",
    "@nestjs/swagger": "^4.6.1",


 
For Tooling issues:
- Node version: v10.19
- Platform:  Linux


Feature request: ExactType

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

@Entity()
export class User {
  // ...
  // TOP SECRET
  @Column()
  @IsString()
  @IsNotEmpty()
  secret!: string;
  // ...
}
import { OmitType } from '@nestjs/mapped-types';

import { User } from '../entities/user.entity';

export class UserDto extends OmitType(User, ['secret'] as const) {
  // WORKAROUND to prevent leaking `secret` to public
  secret?: never;
}

export const userToDto = ({ secret, ...dto }: User): UserDto => dto;
// without the above workaround (`secret?: never`)
@Get('/user')
getUser(): UserDto {
  // find user
  return user; // no error, user contains secret
}

// with the workaround
@Get('/user')
getUser(): UserDto {
  // find user
  // return user; // error!
  return userToDto(user);
}

Expected behavior

import { OmitType, ExactType } from '@nestjs/mapped-types';

import { User } from '../entities/user.entity';

export class UserDto extends ExactType(OmitType(User, ['secret'] as const)) {}

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

Hi folks, thanks to the nestjs team for the great work.

Is it possible to add Exact type?
One use case is not leaking secret information as mentioned above.

Thank you.

`prettier/@typescript-eslint` in ESLint config now throws error

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When running npm run lint locally, the command does not complete due to an error:

$ npm run lint

> @nestjs/[email protected] lint
> eslint 'lib/**/*.ts' --fix


Oops! Something went wrong! :(

ESLint: 8.32.0

Error: Cannot read config file: /Users/rossm/projects/mapped-types/node_modules/eslint-config-prettier/@typescript-eslint.js
Error: "prettier/@typescript-eslint" has been merged into "prettier" in eslint-config-prettier 8.0.0. See: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21
Referenced from: /Users/rossm/projects/mapped-types/.eslintrc.js
    at Object.<anonymous> (/Users/rossm/projects/mapped-types/node_modules/eslint-config-prettier/@typescript-eslint.js:1:7)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at module.exports [as default] (/Users/rossm/projects/mapped-types/node_modules/import-fresh/index.js:31:59)
    at loadJSConfigFile (/Users/rossm/projects/mapped-types/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2562:47)
    at loadConfigFile (/Users/rossm/projects/mapped-types/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2646:20)
    at ConfigArrayFactory._loadConfigData (/Users/rossm/projects/mapped-types/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2963:42)

Minimum reproduction code

Not applicable -- reproducible from command line alone

Steps to reproduce

  1. npm run lint

Expected behavior

$ npm run lint

Output:

> @nestjs/[email protected] lint
> eslint 'lib/**/*.ts' --fix

Package version

1.2.0

Node.js version

18.13.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Using a PartialType inside a PickType will result in a type error.

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

As the title says, using a PartialType inside a PickType will result in a type error.

I'm guessing this is due to the generic not being properly typed.

class CreateOneSomeThing {
  @IsString()
  name: string;
  @IsNumber()
  age: number;
}

export class UpdateOneSomeThing extends PickType(
  PartialType(CreateOneSomeThing),
  [], // Argument of type 'undefined[]' is not assignable to parameter of type 'readonly never[]'.
  Type 'undefined' is not assignable to type 'never'.
) {}

export class UpdateOneSomeThingAndPickTypeArrayString extends PickType(
  PartialType(CreateOneSomeThing),
  ['age'], // Type 'string' is not assignable to type 'never'.
) {}

This would solve it, but it would require me to modify too much of my code. This code worked fine the first time I used it, and I haven't updated the version (stayed on 2.0.2 for 5 months), so why is this happening?

export class UpdateOneSomeThingAndPickTypeArrayString extends PickType<
  Partial<CreateOneSomeThing>,
  keyof CreateOneSomeThing
>(PartialType(CreateOneSomeThing), ['age']) {}

I'm using a translator, so please excuse any awkward sentences.

Minimum reproduction code

https://github.com/

Steps to reproduce

No response

Expected behavior

I'm only getting type errors and no errors are being detected in nest, build is fine I hope it's my version of typescript T.T

Package version

2.0.2

Node.js version

21.1.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

"dependencies": {
"@arendajaelu/nestjs-passport-apple": "^1.0.4",
"@nestjs/axios": "^3.0.0",
"@nestjs/cache-manager": "^2.1.0",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/jwt": "^10.1.0",
"@nestjs/mapped-types": "^2.0.2",
"@nestjs/mongoose": "^10.0.1",
"@nestjs/passport": "^10.0.1",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/schedule": "^3.0.3",
"@nestjs/serve-static": "^4.0.0",
"@nestjs/swagger": "^7.1.8",
...
}

Can't inherit getter/setter and function

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Can't inherit getter/setter and function.

import { PickType } from "@nestjs/mapped-types";

class A {
  foo: number;

  bar: number;

  get baz() {
    return this.foo;
  }
}

class B extends PickType(A, ['foo', 'baz']) {}

const b = new B();
b.foo = 1;

console.log(b.baz); // undefined

Minimum reproduction code

https://github.com/CodyTseng/example/blob/master/mapped-types/index.js

Steps to reproduce

No response

Expected behavior

Can inherit getter/setter and function.

import { PickType } from "@nestjs/mapped-types";

class A {
  foo: number;

  bar: number;

  get baz() {
    return this.foo;
  }
}

class B extends PickType(A, ['foo', 'baz']) {}

const b = new B();
b.foo = 1;

console.log(b.baz); // 1

Package version

1.1.0

Node.js version

16.14.2

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

IntersectionType breaks returning value of methods

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I'm trying to interect two classes to obtain a dto like that:

export class QueryPageDto extends IntersectionType(PartialType(OmitType(CreatePageDto,['metafields','translations'])),PaginationDTO) {}
export default class PaginationDTO {
  @ApiProperty({
    minimum: 1,
    default: 1,
  })
  @IsNumber()
  @IsOptional()
  @IsInt()
  @Min(1)
  @Type(() => Number)
  readonly page?:number = 1;

  @ApiProperty({
    minimum: 1,
    maximum: 250,
    default: 50,
  })
  @IsNumber()
  @IsOptional()
  @IsInt()
  @Min(1)
  @Max(250)
  @Type(() => Number)
  readonly limit?:number = 50;

  get skip(): number {
    return (this.page - 1) * this.limit;
  }

  get take(): number {
    return this.limit;
  }
}

but when i type queryPageDto.skip (or take) also if is suggested they always returns undefined
i tried that whitout IntersectionType and obviously works.

Minimum reproduction code

https://github.com

Steps to reproduce

No response

Expected behavior

I'm expecting returning values

Package version

2.0.5

Node.js version

20.11.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

"@nestjs/mapped-types": "*",
"@nestjs/swagger": "^7.2.0",

Breaking change in 2.0.3 for override fields

Did you read the migration guide?

  • I have read the whole migration guide

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Potential Commit/PR that introduced the regression

c65d434

Versions

2.0.0 -> 2.0.3

Describe the regression

sample entities hierarchy:

abstract class BaseEntityHelper {
        @IsUUID()
        @Expose()
        id!: string | number;
        
        @Expose()
        anotherField!: string;
    }

    class SampleEntity extends BaseEntityHelper {

        @Expose()
        @IsUUID()
        override id!: string;

        @Expose()
        @IsString()
        name!: string;

    }

    class SampleEntityDto extends OmitType(SampleEntity, ['name'] as const) {

    }

So we have an abstract class with an id that can be a number or string overriding it and exposing it. Using omit type to create DTO, that has just a name field.

Let's implement a simple test:

it('instance to instance', () => {


            let sampleEntityWithoutId = new SampleEntity();

            sampleEntityWithoutId.id = 'just id';
            sampleEntityWithoutId.name = 'name';
            sampleEntityWithoutId.anotherField = 'anotherField';


            let dto = plainToInstance(SampleEntityDto, sampleEntityWithoutId, {
              excludeExtraneousValues: true,
              exposeDefaultValues: true,
              ignoreDecorators: true,
              exposeUnsetFields: false,
            });

            let justCopy = plainToInstance(SampleEntity, sampleEntityWithoutId, {
                excludeExtraneousValues: true,
                exposeDefaultValues: true,
                ignoreDecorators: true,
                exposeUnsetFields: false,
            });

            // this is failing but should be ok
            expect(dto.anotherField).toEqual('anotherField');
        })

The error is handled over here
image

but thrown over here
image

this behavior recently changed, and it's a breaking change for this case at least.

I'm ok to fix it by myself, just some comments from maintainers on expected behavior will be good to hear

as for me we should apply the most closest decorators or probably merge it somehow, but not sure is it that obvious to do the merge or no

Minimum reproduction code

No response

Input code

provided

Expected behavior

need suggestion

Other

No response

Use OmitType with abstract class

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I have a abstract base class and want to use OmitType to omit some properties

abstract class OptionalClass {
  @IsOptional()
  @IsString()
  name?: string | null;

  @IsInt()
  age!: number;
}

class RequiredClass extends OmitType(OptionalClass, ['name']) {
  @IsString()
  name: string;
}

RequiredClass removes name property from OptionalClass.

Expected behavior

Expect to work properly.
But it shows me this error:

Argument of type 'typeof OptionalClass' is not assignable to parameter of type 'Type<OptionalClass>'. 
Cannot assign an abstract constructor type to a non-abstract constructor type.

Minimal reproduction of the problem with instructions

The above code.

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

To be able use abstract classes with mapped-types.

Environment


@nestjs/mapped-types: ^1.0.0

 
For Tooling issues:
- Node version: 14.16.1
- Platform:  Mac

Mapped Types are not transformed with [email protected]+ in browser

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

We are using nesjs in a mono repo setup. To share DTOs between nestjs server app and react client app, we include them in the shared library. We are using class-transformer.plainToClass() on both server and client to transform objects into request and response DTOs respectively.

We found out that mapped types are transformed correctly on server but not in the browser if we use [email protected]+.
It works fine on both server and browser with class-transformer0.3.1. Here's an example
(Using {excludeExtraneousValues: true} as the options object to plainToClass())

export class ReferralDto {
  @Expose()
  @IsString()
  id: string;

  @Expose()
  @IsString()
  refNum: string;

  @Expose()
  @IsString()
  firstName: string;

  @Expose()
  @IsString()
  lastName: string;

  @Expose()
  @Type(() => Date)
  @IsDate()
  dob: Date;

  @Expose()
  @IsString()
  @IsOptional()
  healthCardNumber: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  email: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  phone: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  streetAddress: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  city: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  state: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  country: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  postalCode: string | null;

  @Expose()
  @IsString()
  referrerFirstName: string;

  @Expose()
  @IsString()
  referrerLastName: string;

  @Expose()
  @IsString()
  referrerProviderNumber: string;

  @Expose()
  @IsString()
  referrerEmail: string;

  @Expose()
  @IsString()
  @IsOptional()
  clinicName: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  referrerPhone: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  referrerFax: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  referrerStreetAddress: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  referrerCity: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  referrerState: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  referrerCountry: string | null;

  @Expose()
  @IsString()
  @IsOptional()
  referrerPostalCode: string | null;

  @Expose()
  @Type(() => Date)
  @IsDate()
  updatedAt: Date;

  @Expose()
  @Type(() => Date)
  @IsDate()
  createdAt: Date;

  @Expose()
  @IsString()
  status: ReferralStatus;

  @Expose()
  @IsOptional()
  @Type(() => ShortUserDto)
  assignedProgramFacilitator: ShortUserDto | null;

  @Expose()
  @IsString()
  program: Program;

  @Expose()
  @IsOptional()
  @Type(() => ShortUserDto)
  updatedBy: ShortUserDto | null;

  @Expose()
  @IsBoolean()
  requiredFieldsCheckPassed: boolean;
}
import { PickType } from '@nestjs/mapped-types';
import { ReferralDto } from './referral.dto';
export class ReferralListItemDto extends PickType(ReferralDto, [
  'id',
  'refNum',
  'firstName',
  'lastName',
  'dob',
  'healthCardNumber',
  'referrerFirstName',
  'referrerLastName',
  'createdAt',
  'updatedAt',
  'status',
  'assignedProgramFacilitator',
  'program',
  'requiredFieldsCheckPassed',
] as const) {}

Transformed ReferralListItemDto on client side ([email protected])
image

Transformed ReferralListItemDto on client side ([email protected])
image

For reference here's the webpack config for client

const { merge } = require('webpack-merge');
const webpack = require('webpack');

module.exports = (config, context) => {
  const lazyImports = [
    'class-transformer/storage',
    'class-transformer/cjs/storage',
    'class-validator',
  ];

  return merge(config, {
    plugins: [
      ...config.plugins,

      new webpack.IgnorePlugin({
        checkResource(resource) {
          if (lazyImports.includes(resource)) {
            try {
              require.resolve(resource);
            } catch (err) {
              return true;
            }
          }
          return false;
        },
      }),
    ],
  });
};

Minimum reproduction code

dsd

Steps to reproduce

No response

Expected behavior

[email protected]+ should transform mapped types correctly

Package version

1.1.0

Node.js version

16.15.1

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Error when creating mapped types

I'm submitting a...


[ ] Regression 
[x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Error when using PartialType from '@nestjs/mapped-types'.

[Nest] 99355   - 01/14/2021, 2:38:25 PM   [MappedTypes] Transformer ("class-transformer") metadata cannot be inherited for "CreateCoffeeDto" class.
[Nest] 99355   - 01/14/2021, 2:38:25 PM   [MappedTypes] Object:

Expected behavior

Create a variant from a dto to avoid code redundancy

Minimal reproduction of the problem with instructions

https://gist.github.com/gmwill934/c3c68650f773018aa8c656697ea2c625

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

Environment


{
  "name": "iluvcoffee",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },
  "dependencies": {
    "@nestjs/common": "^7.5.1",
    "@nestjs/core": "^7.5.1",
    "@nestjs/mapped-types": "^0.1.1",
    "@nestjs/platform-express": "^7.5.1",
    "@nestjs/typeorm": "^7.1.5",
    "class-transformer": "^0.3.2",
    "class-validator": "^0.13.1",
    "pg": "^8.5.1",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^6.6.3",
    "typeorm": "^0.2.30"
  },
  "devDependencies": {
    "@nestjs/cli": "^7.5.1",
    "@nestjs/schematics": "^7.1.3",
    "@nestjs/testing": "^7.5.1",
    "@types/express": "^4.17.8",
    "@types/jest": "^26.0.15",
    "@types/node": "^14.14.6",
    "@types/supertest": "^2.0.10",
    "@typescript-eslint/eslint-plugin": "^4.6.1",
    "@typescript-eslint/parser": "^4.6.1",
    "eslint": "^7.12.1",
    "eslint-config-prettier": "^6.15.0",
    "eslint-plugin-prettier": "^3.1.4",
    "jest": "^26.6.3",
    "prettier": "^2.1.2",
    "supertest": "^6.0.0",
    "ts-jest": "^26.4.3",
    "ts-loader": "^8.0.8",
    "ts-node": "^9.0.0",
    "tsconfig-paths": "^3.9.0",
    "typescript": "^4.0.5"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  }
}


Nest version: 7.5.1

 
For Tooling issues:
- Node version: 14.15.1
- Platform:  Mac
- Using npm

OmitType not respecting deep parent class after compiled to webpack

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

It respects parent's class but it does not respect parent class's parent class when it's packed to webpack

Expected behavior

It should respect every parent class

Minimal reproduction of the problem with instructions

https://github.com/asomethings/mapped-types-webpack-bug

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

Well, I have a lot of multiple base classes and use them extending a lot. So I hope the bug gets fixed.

Environment


Nest version: 8.0.9

 
For Tooling issues:
- Node version: 14
- Platform:  Linux Ubuntu 20.04

Others:

Update the class-validator dependency to 0.14.0

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

Raising this for visibility. There is a critical vulnerability in class-validator which is resolved in 0.14.0.

Describe the solution you'd like

Please update the packages dependency and peerDependency of class-validator to 0.14.0 only.

Teachability, documentation, adoption, migration strategy

There is an automated PR open: #930. It has been open for some time, can we please merge it? Many people are urgently waiting for this.

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

Critical security vulnerability.

PartialType and IntersectionType doesn't work as expected

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

import { IntersectionType, PartialType } from '@nestjs/mapped-types';
import { IsOptional, IsString } from 'class-validator';

class MandatoryField {
  @IsString()
  public my_test: string;
}

class OtherFields {
  @IsOptional()
  @IsString()
  public my_optional_field?: string;
}

class MyCombinaison extends IntersectionType(
  PartialType(MandatoryField),
  OtherFields,
) {}

function t(r: MyCombinaison) {
  console.debug(r);
}

t({});
# Argument of type '{}' is not assignable to parameter of type 'MyCombinaison'.
  Type '{}' is missing the following properties from type 'MyCombinaison': my_test, my_optional_field

Here I expect to have only optional parameter, but they are all mandatory.
When I use @nestjs/swagger, no issue.
Also version < 2 works as expected.

Minimum reproduction code

https://see.example.above

Steps to reproduce

  1. install last version of nestjs
  2. install last version of @nestjs/mapped-types

Expected behavior

All fields above should be optional.

Package version

2.0.1

Node.js version

v18.16.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Add new mapped-type for intersection more than two classes

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

import { IntersectionType } from '@nestjs/mapped-types';
import { BaseTemplateFiltering } from 'validators/BaseTemplateFiltering';
import { LimitOffsetQuery } from 'validators/LimitOffsetQuery';
import { SortByQuery } from 'validators/SortByQuery';

export class BaseTemplateQueryDto extends IntersectionType(
  BaseTemplateFiltering,
  IntersectionType(LimitOffsetQuery, SortByQuery),
) {}

Wanted behavior

import { IntersectionMultipleType } from '@nestjs/mapped-types';
import { BaseTemplateFiltering } from 'validators/BaseTemplateFiltering';
import { LimitOffsetQuery } from 'validators/LimitOffsetQuery';
import { SortByQuery } from 'validators/SortByQuery';

export class BaseTemplateQueryDto extends IntersectionMultipleType(
  BaseTemplateFiltering,
  LimitOffsetQuery, 
  SortByQuery,
) {}

I don't think is it possible to do things such this...

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

circleci
.circleci/config.yml
  • cimg/node 21.6
  • cimg/node 21.6
npm
package.json
  • @commitlint/cli 19.2.0
  • @commitlint/config-angular 19.1.0
  • @nestjs/common 10.3.4
  • @types/jest 29.5.12
  • @types/node 20.11.29
  • @typescript-eslint/eslint-plugin 7.3.1
  • @typescript-eslint/parser 7.3.1
  • class-transformer 0.5.1
  • class-validator 0.14.1
  • eslint 8.57.0
  • eslint-config-prettier 9.1.0
  • eslint-plugin-import 2.29.1
  • husky 9.0.11
  • jest 29.7.0
  • lint-staged 15.2.2
  • prettier 3.2.5
  • reflect-metadata 0.2.1
  • release-it 17.1.1
  • rimraf 5.0.5
  • ts-jest 29.1.2
  • typescript 5.4.2
  • @nestjs/common ^8.0.0 || ^9.0.0 || ^10.0.0
  • class-transformer ^0.4.0 || ^0.5.0
  • class-validator ^0.13.0 || ^0.14.0
  • reflect-metadata ^0.1.12 || ^0.2.0

  • Check this box to trigger a request for Renovate to run again on this repository

PickType ignore parent's @Transform when grandparent use @Transform

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Same issue from Nestjs/swagger#2659
I have three class:

class Grandparent {
  @Expose()
  @Transform(function grandparentTransform() {
    transformExecuteSequenceList.push(Grandparent.name);
    return 0;
  })
  value!: number;
}
class Parent extends Grandparent {
  @Transform(function parentTransform() {
    transformExecuteSequenceList.push(Parent.name);
    return 1;
  })
  value!: number;
}
class Children extends PickType(Parent, ["value"]) {
  @Transform(function childrenTransform(params) {
    transformExecuteSequenceList.push(Children.name);
    return params.value;
  })
  value!: number;
}

Execute

const children = plainToInstance(Children, {});
console.log({ transformExecuteSequenceList, childrenValue: children.value });

image

It should be

{
  transformExecuteSequenceList: [ 'Grandparent', 'Parent', 'Children' ],
  childrenValue: 1
}

Children ignored Parent's Transform function.

Minimum reproduction code

https://github.com/KuanWenChen/mapped-types-issue

Steps to reproduce

  1. npm install
  2. npm run start

Expected behavior

Result should be:

{
  transformExecuteSequenceList: [ 'Grandparent', 'Parent', 'Children' ],
  childrenValue: 1
}

Package version

^2.0.2

Node.js version

v20.9.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

RequiredType

I'm submitting a...


[x] Feature request

Details

Could you add RequiredType besides to PartialType that already exists, please?

Or whether any other variant with the type optional fields are created into with the same fields required.

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

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.

Could not resolve dependency: peerOptional class-validator@"^0.11.1 || ^0.12.0 || ^0.13.0" from @nestjs/[email protected]

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Unable to resolve dependency tree when installing npm i @nestjs/mapped-types using:

  • node: v18.12.1
  • nest: 9.1.5
  • class-validator: ^0.14.0

Screenshot 2022-12-11 at 11 44 32 PM

Minimum reproduction code

https://github.com/mnrendra/iluvcoffee

Steps to reproduce

  1. npm i class-validator class-transformer
  2. npm i @nestjs/mapped-types
  3. See error:

Screenshot 2022-12-11 at 11 44 32 PM

Expected behavior

When intalling npm i @nestjs/mapped-types should be success with:
"class-validator": "^0.14.0"

Package version

1.2.0

Node.js version

18.12.1

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Support for class-validator 0.14.0

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

Updated my deps today & came across this warning

 WARN  Issues with peer dependencies found
apps/api
└─┬ @nestjs/mapped-types 1.2.0
  └── βœ• unmet peer class-validator@"^0.11.1 || ^0.12.0 || ^0.13.0": found 0.14.0

Describe the solution you'd like

I guess we can bump up peer deps to 0.14.0 since there arent any breaking changes?

Teachability, documentation, adoption, migration strategy

I dont think so these would be required.

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

To support class-validator 0.14.0 and future versions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.