Type-graphql: [1.0.0-rc1] class-validator is peer dependency but seems to be required?

Created on 6 May 2020  路  7Comments  路  Source: MichalLytek/type-graphql

Describe the Bug
Trying to compile project using rc1 version results in type errors because types for class-validator are not available.

To Reproduce
1) Checkout https://github.com/rchl/type-graphql-class-validator
2) Run npm i
3) Run npm run build

Expected Behavior
Build succeeds.

Logs

> tsc

node_modules/type-graphql/dist/decorators/types.d.ts:2:39 - error TS2307: Cannot find module 'class-validator'.

2 import type { ValidatorOptions } from "class-validator";
                                        ~~~~~~~~~~~~~~~~~

node_modules/type-graphql/dist/errors/ArgumentValidationError.d.ts:1:38 - error TS2307: Cannot find module 'class-validator'.

1 import type { ValidationError } from "class-validator";
                                       ~~~~~~~~~~~~~~~~~

node_modules/type-graphql/dist/metadata/definitions/param-metadata.d.ts:1:39 - error TS2307: Cannot find module 'class-validator'.

1 import type { ValidatorOptions } from "class-validator";
                                        ~~~~~~~~~~~~~~~~~

node_modules/type-graphql/dist/schema/build-context.d.ts:2:39 - error TS2307: Cannot find module 'class-validator'.

2 import type { ValidatorOptions } from "class-validator";
                                        ~~~~~~~~~~~~~~~~~

Environment (please complete the following information):

  • OS: macos
  • Node 10.19.0
  • Package version 1.0.0-rc1
  • TypeScript version 3.8.3
Community Documentation Solved

Most helpful comment

@rchl
Actually, that's what I've done over a month ago:

image

So I will just remove the "optional" info from release notes as they might be confusing.

All 7 comments

OK, that clearly addresses my issue :)

Can maybe release notes be updated to mention that?
Currently they say Breaking Change: make class-validator an optional, peer dependency of version >=0.12.0 which gives an impression that it's not needed.

The goal is to have a separate plugin for validation that will be optional and installing class-validator won't be required.

For now, due to the typings issue with compiling, caused by monolith architecture, you need to have class-validator installed as a dev deps (when not using validation) or skipLibCheck set to true.

@rchl
What do you think is better - npm i class-validator in installation docs or skipLibCheck: true as the default recommended setting?

@MichalLytek I think it's better to have npm i class-validator as that is localized to this package and doesn't have type checking side effects on the whole project.

@rchl
Actually, that's what I've done over a month ago:

image

So I will just remove the "optional" info from release notes as they might be confusing.

Closing by 930a692 馃敀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tafelito picture tafelito  路  3Comments

limenutt picture limenutt  路  3Comments

oliversalzburg picture oliversalzburg  路  3Comments

MichalLytek picture MichalLytek  路  3Comments

maplesteve picture maplesteve  路  3Comments