I've been tasked with compiling an angular project that contains mostly code written by someone else.
Although the example below compiles successfully on one machine, it throws an error on different machines.
import { plainToClass } from 'class-transformer';
plainToClass(MyClass, myObject).filter(true);
When I run ng build
, I receive the following error message:
error TS2339: Property 'filter' does not exist on type 'MyClass'.
The variable myObject
is defined as any
but actually holds an array. By modifying the code like this, it works:
plainToClass(MyClass, myObject as any[]).filter(true);
This issue can be found throughout the entire project.
I'm puzzled as to why the same code functions properly on one machine but not on another.
Both machines are using version 0.2.0 of class-transformer in the same package.json
.
It appears that one version of the method is being selected on one machine while a different one is chosen on the other. This seems to occur randomly.
Is there a way to address this problem universally?