打字稿无法在其他文件夹中编译

时间:2020-10-20 10:30:24

标签: typescript

我有这个非常古怪的typectript问题。我对问题所在很迷失,所以希望有人能帮助我解决问题。

我的问题仅在于REST API,这是一种用猫鼬表达的正常表达,全部用Typescript编写。最初,所有本地编译都完美无缺,而且也在我的服务器上。

我正在从pm2设置部署,但是突然项目不再构建了?!?有41个错误: 对于类型'B'的参数,不能将'A'类型的参数赋值给操作符'<=',不能将其应用于类型。

相同的错误发生在我们的github动作上。但是没有开发人员有这个问题。

唯一的区别是文件夹。

打字稿和节点版本相同: 打字稿:4.0.2 节点:12.19.0

这是错误的底部:

src/modules/projects/routes/project-directory.routes.ts:32:60 - error TS2345: Argument of type 'string | string[] | ParsedQs | ParsedQs[]' is not assignable to parameter of type 'string'.
  Type 'string[]' is not assignable to type 'string'.

32         ...(req.query.title) ? [projectQueries.match.title(req.query.title)] : [],
                                                              ~~~~~~~~~~~~~~~

src/modules/projects/routes/project-directory.routes.ts:33:68 - error TS2345: Argument of type 'string | string[] | ParsedQs | ParsedQs[]' is not assignable to parameter of type 'string'.
  Type 'string[]' is not assignable to type 'string'.

33         ...(req.query.organizer) ? [projectQueries.match.organizer(req.query.organizer)] : [],
                                                                      ~~~~~~~~~~~~~~~~~~~

src/modules/projects/routes/project-directory.routes.ts:61:46 - error TS2365: Operator '>' cannot be applied to types 'string | string[] | ParsedQs | ParsedQs[]' and 'number'.

61                 return req.query.distance && req.query.distance > 10 ?
                                                ~~~~~~~~~~~~~~~~~~~~~~~

src/modules/projects/routes/project-directory.routes.ts:62:21 - error TS2365: Operator '<=' cannot be applied to types 'number' and 'string | string[] | ParsedQs | ParsedQs[]'.

62                     distance <= req.query.distance :
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/modules/member/services/subscribtion.routes.ts:24:13 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Type '{ project: { news: true; }; workinggroup: { _id: string; news: true; generalDiscussion: true; organization: false; }[]; }' is not assignable to type 'Subscriptions'.
      Object literal may only specify known properties, and 'project' does not exist in type 'Subscriptions'.

24             project: {
               ~~~~~~~~~~
25                 news: true
   ~~~~~~~~~~~~~~~~~~~~~~~~~~
26             },
   ~~~~~~~~~~~~~

  src/modules/member/member.model.ts:150:2
    150  subscribtions: Subscriptions;
         ~~~~~~~~~~~~~
    The expected type comes from property 'subscribtions' which is declared here on type 'MongooseUpdateQuery<Pick<MemberType, "_id" | "isDeleted" | "isApproved" | "oAuthProvider" | "token" | "email" | "phone" | "isActive" | "password" | "passwordVersion" | "firstname" | ... 36 more ... | "privateFields">>'
  node_modules/@types/mongoose/index.d.ts:3467:5
    3467     findByIdAndUpdate(id: any | number | string, update: UpdateQuery<T>,
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    3468       options: QueryFindOneAndUpdateOptions,
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    3469       callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T, QueryHelpers> & QueryHelpers;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The last overload is declared here.

src/modules/zoom/zoom.routes.ts:10:11 - error TS2322: Type 'string | string[] | ParsedQs | ParsedQs[] | ZoomRole.Participant' is not assignable to type 'ZoomRole'.
  Type 'string' is not assignable to type 'ZoomRole'.

10     const role: ZoomRole = req.query.role ?? ZoomRole.Participant;
             ~~~~

src/modules/zoom/zoom.routes.ts:12:53 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.

12     const signature = ZoomService.generateSignature(meetingNumber, role)
                                                       ~~~~~~~~~~~~~

src/modules/plenary/plenary.routes.ts:55:5 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Type '{ questions: any; }' is not assignable to type 'PullOperator<Pick<({ questions: string[]; } & "member" & IMember & Document) | ({ questions: string[]; } & "moderator" & IMember & Document), number | "length" | ... 92 more ... | "questions">>'.
      Type '{ questions: any; }' is not assignable to type 'NotAcceptedFields<Pick<({ questions: string[]; } & "member" & IMember & Document) | ({ questions: string[]; } & "moderator" & IMember & Document), number | "length" | ... 92 more ... | "questions">, any[]>'.
        Types of property 'valueOf' are incompatible.
          Type '() => Object' is not assignable to type 'never'.

55              $pull: {
                ~~~~~

  node_modules/@types/mongodb/index.d.ts:1423:5
    1423     $pull?: PullOperator<TSchema>;
             ~~~~~
    The expected type comes from property '$pull' which is declared here on type 'MongooseUpdateQuery<Pick<({ questions: string[]; } & "member" & IMember & Document) | ({ questions: string[]; } & "moderator" & IMember & Document), number | "length" | ... 92 more ... | "questions">>'
  node_modules/@types/mongoose/index.d.ts:3467:5
    3467     findByIdAndUpdate(id: any | number | string, update: UpdateQuery<T>,
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    3468       options: QueryFindOneAndUpdateOptions,
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    3469       callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T, QueryHelpers> & QueryHelpers;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The last overload is declared here.


Found 41 errors.

0 个答案:

没有答案
相关问题