以下错误仅在DevOps管道上的Npm@1个任务期间发生.这款应用程序在本地构建得很好.一点错误都没有.

ANGLE CLI版本为8.3.29,打字版本为3.5.3.

它正在执行这个定制命令:

run build:artifact

而该自定义命令在package.json中指向以下内容:

ng build --configuration=artifact

抛出的错误是:

../node_modules/@types/lodash/common/lang.d.ts:577:74-错误TS2677: 类型谓词的类型必须可分配给其参数的类型.

管道中的完整日志(log):

Starting: Angular Build
==============================================================================
Task         : npm
Description  : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
Version      : 1.202.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
==============================================================================
C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\node\14.15.0\x64\npm.cmd --version"
6.14.8
C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\node\14.15.0\x64\npm.cmd config list"
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.8 node/v14.15.0 win32 x64"

; environment configs
prefix = "C:\\npm\\prefix"
userconfig = "D:\\a\\1\\npm\\11507.npmrc"

; globalconfig C:\npm\prefix\etc\npmrc
cache = "C:\\npm\\cache"

; node bin location = C:\hostedtoolcache\windows\node\14.15.0\x64\node.exe
; cwd = D:\a\1\s\client-site-spa
; HOME = C:\Users\VssAdministrator
; "npm config ls -l" to show all defaults.

C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\node\14.15.0\x64\npm.cmd run build:artifact"

ERROR in ../node_modules/@types/lodash/common/lang.d.ts:577:74 - error TS2677: A type predicate's type must be assignable to its parameter's type.
  Type 'EmptyObjectOf<T>' is not assignable to type 'T'.
    'EmptyObjectOf<T>' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'object'.
      Type 'EmptyObject<T>' is not assignable to type 'T'.
        'EmptyObject<T>' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'object'.

577         isEmpty<T extends object>(value: T | null | undefined): value is EmptyObjectOf<T> | null | undefined;
                                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project-angular@0.0.0 build:artifact: `ng build --configuration=artifact`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the project-angular@0.0.0 build:artifact script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\npm\cache\_logs\2022-08-17T15_41_17_869Z-debug.log

> project-angular@0.0.0 build:artifact D:\a\1\s\client-site-spa
> ng build --configuration=artifact

您知道如何查找引发此错误的位置吗?

当我用匹配的node\npm版本在我的dev box上手动运行相同的命令[ng build --configuration=artifact]时,没有发生错误:

enter image description here

####

在按照MikeOne的建议删除了node_modules文件夹和package-lock.json文件后,我能够从本地管道中得到相同的错误...然而,它仍然没有告诉我们错误是在哪个文件中发生的.:___

package-lock

####

没有迹象表明这个错误在我自己的源代码中的任何地方发生.这会是lodash本身的错误吗?我使用的是最新的版本,现在是4.17.21.

enter image description here

####

这似乎是TypeScrip编译器一直在抱怨的接口成员……但是,我不会在代码中的任何地方调用它.

enter image description here

推荐答案

A recent commit已经打破了包装.这个问题正在their Github上被跟踪,但在此期间,我们可以坚持使用@types/lodash的前一个版本,即4.14.182.

Typescript相关问答推荐

类型脚本如何将嵌套的通用类型展开为父通用类型

当类型断言函数返回假时,TypScript正在推断从不类型

参数类型undefined不能分配给参数类型字符串|未定义

SortKey类型不起作用,尽管它使用的单个类型工作正常<>'

为什么不能使用$EVENT接收字符串数组?

有没有办法防止类型交集绕过联合类型限制?

复选框Angular 在Ngfor中的其他块中重复

API文件夹内的工作员getAuth()帮助器返回:{UserID:空}

如何使用TypeScrip在EXPO路由链路组件中使用动态路由?

当传递带有或不带有参数的函数作为组件props 时,我应该如何指定类型?

如何通过转换器类继承使用多态将对象从一种类型转换为另一种类型

为什么数字是`{[key:string]:UNKNOWN;}`的有效密钥?

Typescript不允许在数组中使用联合类型

TypeScript:如何使用泛型和子类型创建泛型默认函数?

导航链接不触发自定义挂钩

为什么我会得到一个;并不是所有的代码路径都返回一个值0;switch 中的所有情况何时返回或抛出?(来自vsCode/TypeScript)

Karma Angular Unit测试如何创建未解析的promise并在单个测试中解决它,以判断当时的代码是否只在解决后运行

如何将 MUI 主题对象的自定义属性与情感样式组件中的自定义props 一起使用?

Typescript 子类继承的方法允许参数中未定义的键

使用react+ts通过props传递数据