mili
mili copied to clipboard
compile TypeScript:... 'select' does not exist in type 'FindConditions<User>'
I met some problem,when i npm start on project root,
/home/workspace/mili/node_modules/ts-node/src/index.ts:240
return new TSError(diagnosticText, diagnosticCodes)
^
TSError: ⨯ Unable to compile TypeScript:
src/user/user.service.ts:486:17 - error TS2345: Argument of type '{ select: { id: boolean; username: boolean; avatarURL: boolean; }; where: { username: string; }; }' is not assignable to parameter of type 'FindConditions<User>'.
Object literal may only specify known properties, and 'select' does not exist in type 'FindConditions<User>'.
486 select: {
~~~~~~~~~
487 id: true,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
489 avatarURL: true,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
490 },
~~~~~~~~~~~~~~~~~
src/user/user.service.ts:673:17 - error TS2345: Argument of type '{ select: { id: boolean; username: boolean; avatarURL: boolean; }; skip: number; take: number; }' is not assignable to parameter of type 'FindConditions<User>'.
Object literal may only specify known properties, and 'select' does not exist in type 'FindConditions<User>'.
673 select: {
~~~~~~~~~
674 id: true,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
676 avatarURL: true,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
677 },
~~~~~~~~~~~~~~~~~
src/user/user.service.ts:696:13 - error TS2345: Argument of type '{ select: { id: boolean; username: boolean; avatarURL: boolean; introduce: boolean; job: boolean; company: boolean; }; skip: number; take: number; order: { articleCount: string; }; }' is not assignable to parameter of type 'FindConditions<User>'.
Object literal may only specify known properties, and 'select' does not exist in type 'FindConditions<User>'.
696 select: {
~~~~~~~~~
697 id: true,
~~~~~~~~~~~~~~~~~~~~~~~~~
...
702 company: true,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
703 },
~~~~~~~~~~~~~
so how to get this right
I do not know the model that was used here, but the normal TypeORM select format looks like:
userRepository.find({ select: ["id", "company"] });
(the select property will be stated to "not exist" if it contains anything other than array of column names).