You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Argument of type 'Test' is not assignable to parameter of type '{ badField: boolean; }'.
Types of property 'badField' are incompatible.
Type 'string' is not assignable to type 'boolean'
TODO: figure out how to get rid of false negative, like using custom scalars, etc.
@19majkel94
Very good feature, but is there a way to provide strong typing support for method parameters decorators? I can't make tsc to issue an error for this code:
exportinterfaceClassTypeextendsFunction{new(...args: any[]): unknown;}exporttypeStaticMethodParameterDecorator=(<TMethodNameextendsstring|symbol,TClassTypeextendsClassType&Record<TMethodName,(this: TClassType, ...args: unknown[])=>unknown>>(targetClass: TClassType,methodName: TMethodName,parameterIndex: number)=>void);functionstaticParameterDecorator(): StaticMethodParameterDecorator{return()=>{};}classCl{method(// instance method, but no error
@staticParameterDecorator()bool: boolean){returnbool;}}
@19majkel94 Well, ok, we can skip this part, as there are no decorators targeted to static accessors/properties/methods in typegraphql. I inspected some of ts-graphql code previously, but failed to find a solution for strongly typing parameter decorators, that you will face when implementing yours if haven't yet.
Hello @MichalLytek.
I hope all is well.
I have just found out about this behavior while using NestJS, and it led me to this GitHub issue, so, I am wondering if there are/will be any updates/solutions to this.
Right now it's dangerously easy to have inconsistence between schema type and TS type in class definition:
It can be easily fixed (I was not aware of this possibility in TS) by using generics instead of predefined types like
PropertyDecorator
.Quick demonstration of the proof of concept:
TODO: figure out how to get rid of false negative, like using custom scalars, etc.
Disclaimer: Inspired by @stephentuso ts-graphql 😃
The text was updated successfully, but these errors were encountered: