TypeManager.TS icon indicating copy to clipboard operation
TypeManager.TS copied to clipboard

Add support for TypeScript v5 decorator syntax

Open Offlein opened this issue 1 year ago • 5 comments

Describe the bug

Out of the box, my PhpStorm (or WebStorm) IDE throws a TS1238 error on the @Type decorator when called as an expression, and a TS1240 error ("Unable to resolve signature of property decorator when called as an expression. Argument of type  undefined  is not assignable to parameter of type  Object") on the @Property decorator.

I have been having a lot of difficulty recently understanding how PhpStorm validates syntax across our monorepo, but I get this error when my "Node Interpreter" is set to my host machine's (version 20.5.0), and it goes AWAY when I set it to use Node within this app's docker dev environment (node version 18.16.0). It comes BACK if I set it to use a different container that uses node 16.13.1. On all of the above it's set to use Typescript version 5.0.4, and I don't understand why the Node version matters at all in that case.

Either way, I do see that @Type's signature is:

export declare function Type<TType>(typeOptions?: TypeOptions<TType>): ClassDecorator;

And indeed that accepts one optional parameter.

I am not intimately familiar enough with TypeScript to understand why the runtime will invoke it with 2 parameters, but is that a legitimate issue, and do these decorators' signatures need to be updated to handle that 2nd parameter?

image

Thanks!

Offlein avatar Aug 15 '23 18:08 Offlein