maticzav / graphql-shield

🛡 A GraphQL tool to ease the creation of permission layer.

Home Page:https://graphql-shield.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build error with yup latest version `^0.32.0`

vipex opened this issue · comments

Bug report

  • I have checked other issues to make sure this is not a duplicate.

Describe the bug

If in the project is installed yup@^0.32.0 build fails with errors:

../../node_modules/graphql-shield/dist/constructors.d.ts:39:122 - error TS2694: Namespace '".../node_modules/yup/lib/index"' has no exported member 'Schema'.

39 export declare const inputRule: <T>(name?: string | undefined) => (schema: (yup: typeof Yup, ctx: IShieldContext) => Yup.Schema<T, object>, options?: Yup.ValidateOptions<object> | undefined) => InputRule<T>;
                                                                                                                            ~~~~~~

../../node_modules/graphql-shield/dist/constructors.d.ts:39:155 - error TS2694: Namespace '".../node_modules/yup/lib/index"' has no exported member 'ValidateOptions'.

39 export declare const inputRule: <T>(name?: string | undefined) => (schema: (yup: typeof Yup, ctx: IShieldContext) => Yup.Schema<T, object>, options?: Yup.ValidateOptions<object> | undefined) => InputRule<T>;
                                                                                                                                                             ~~~~~~~~~~~~~~~

../../node_modules/graphql-shield/dist/rules.d.ts:69:85 - error TS2694: Namespace '".../node_modules/yup/lib/index"' has no exported member 'Schema'.

69     constructor(name: string, schema: (yup: typeof Yup, ctx: IShieldContext) => Yup.Schema<T>, options?: Yup.ValidateOptions);
                                                                                       ~~~~~~

../../node_modules/graphql-shield/dist/rules.d.ts:69:110 - error TS2694: Namespace '".../node_modules/yup/lib/index"' has no exported member 'ValidateOptions'.

69     constructor(name: string, schema: (yup: typeof Yup, ctx: IShieldContext) => Yup.Schema<T>, options?: Yup.ValidateOptions);
                                                                                                                ~~~~~~~~~~~~~~~

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

import { rule } from 'graphql-shield';
export const r = rule()((): boolean => false);

Add yup to the project and build typescript:

yarn add yup@latest
tsc

Hey @vipex 👋,

Thank you for opening an issue. We will get back to you as soon as we can. Have you seen our Open Collective page? Please consider contributing financially to our project. This will help us involve more contributors and get to issues like yours faster.

https://opencollective.com/graphql-shield

We offer priority support for all financial contributors. Don't forget to add priority label once you become one! 😄

I don't think you should add a yup dependency yourself since we don't import it as a peer.

I use it for other purposes in the application.

For now skipLibCheck: true will ignore the errors

I just came across this issue too. I'm attempting to use nexus-validate (which requires yup to be installed) but yup^0.32 causes the above TS errors.

(Unfortunately older versions of yup have a many more TS errors)

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.