Typescript 在使用Webpack的项目上运行“tsc”会抛出Webpack中未发现的错误

Typescript 在使用Webpack的项目上运行“tsc”会抛出Webpack中未发现的错误,typescript,webpack,Typescript,Webpack,我使用Webpack构建我的Typescript项目。然而,随着我的项目越来越大,webpack的速度越来越慢 我想使用tsc将typescript签出分解为一个单独的过程 然而,当我在我的项目上运行tsc时,我会收到类型声明错误,而在使用ts加载器进行Webpack时,我不会得到这些错误 我认为这是由于typescript和webpack在导入模块时的差异造成的 模块分辨率: 要知道这个插件使用了typescript的, 不是网页包的模块分辨率。这意味着您必须进行设置 tsconfig.jso

我使用Webpack构建我的Typescript项目。然而,随着我的项目越来越大,webpack的速度越来越慢

我想使用
tsc
将typescript签出分解为一个单独的过程

然而,当我在我的项目上运行
tsc
时,我会收到类型声明错误,而在使用
ts加载器
进行Webpack时,我不会得到这些错误

我认为这是由于typescript和webpack在导入模块时的差异造成的

模块分辨率: 要知道这个插件使用了typescript的, 不是网页包的模块分辨率。这意味着您必须进行设置 tsconfig.json正确。例如,如果设置文件: ['./src/someFile.ts']在tsconfig.json中,此插件将仅检查 someFile.ts查找语义错误。这是因为性能。目标 这个插件的功能是尽可能快。使用typescript的模块 解决方案我们不必等待webpack编译文件(这 在编译期间遍历依赖关系图)-我们有一个完整的列表 从一开始文件的数量。

以下是一些示例错误:

node_modules/@types/node/index.d.ts:143:13 - error TS2300: Duplicate identifier 'require'.
node_modules/@types/react-native/index.d.ts:8719:14 - error TS2300: Duplicate identifier 'require'.
node_modules/@types/react-native/index.d.ts:8745:18 - error TS2717: Subsequent property declarations must have the same type.  Property 'geolocation' must be of type 'Geolocation', but here has type 'GeolocationStatic'.
node_modules/@types/webpack-env/index.d.ts:203:13 - error TS2300: Duplicate identifier 'require'.
node_modules/rxjs/scheduler/VirtualTimeScheduler.d.ts:24:15 - error TS2416: Property 'work' in type 'VirtualAction<T>' is not assignable to the same property in base type 'AsyncAction<T>'.
node_modules/@types/node/index.d.ts:143:13-错误TS2300:重复标识符'require'。
node_modules/@types/react native/index.d.ts:8719:14-错误TS2300:重复标识符“require”。
node_modules/@types/react native/index.d.ts:8745:18-错误TS2717:后续属性声明必须具有相同的类型。属性“geolocation”的类型必须为“geolocation”,但此处的类型为“GeolocationStatic”。
node_modules/@types/webpack env/index.d.ts:203:13-错误TS2300:重复标识符'require'。
node_modules/rxjs/scheduler/VirtualTimeScheduler.d.ts:24:15-错误TS2416:类型“VirtualAction”中的属性“work”不能分配给基类型“AsyncAction”中的相同属性。
更多详情请点击此处:

感谢您的解答:

这是节点库和类型脚本库冲突的问题。见:

快速修复:返回到
@types/node v9.6.7
,直到可以修复v10