logologo
指南
实践
配置
插件
案例
博客
生态
Module Federation Examples
Practical Module Federation
Zephyr Cloud
Nx
简体中文
English
指南
实践
配置
插件
案例
博客
Module Federation Examples
Practical Module Federation
Zephyr Cloud
Nx
简体中文
English
logologo

开始

介绍
设置环境
快速上手
功能导航
名词解释
npm 包

基础

运行时

Runtime 接入
Runtime API
Runtime Hooks
Rsbuild Plugin
Rspack 插件
Webpack Plugin
Rspress Plugin
Vite Plugin
Metro
类型提示
命令行工具
样式隔离

数据管理

数据获取
数据缓存
Prefetch

框架

Modern.js
Next.js

部署

使用 Zephyr Cloud 部署

调试

开启调试模式
Chrome Devtool
全局变量

Troubleshooting

概览

运行时

RUNTIME-001
RUNTIME-002
RUNTIME-003
RUNTIME-004
RUNTIME-005
RUNTIME-006
RUNTIME-007
RUNTIME-008
RUNTIME-009

构建

BUILD-001
BUILD-002

类型

概览
TYPE-001
其他
Edit this page on GitHub
Previous Page概览
Next Page其他

Failed to generate type declaration. Execute the below cmd to reproduce and fix the error.

  • Error Code: TYPE-001

#原因

编译导出(exposes)的文件 TS 类型时,会使用当前项目的 tsconfig.json 。如果配置文件有缺失一些属性会导致构建类型失败。

#解决方法

  1. 删除 cmd 命令中的 tsconfig.json incremental 和 tsBuildInfoFile 配置。
  2. 在 terminal 中执行报错信息参数中的 cmd 命令,根据错误信息对文件或者 tsconfig 进行修复。

若你希望忽略 ts 中的类型检查错误,可在 tsconfig.json 中设置 compilerOptions.noCheck 为 true(该选项仅支持 ts 5.5 及以上版本)

若 cmd 命令执行无报错,但仍然报错 TS 编译失败,需要检查 ModuleFederationPlugin 中的 exposes字段:

[modern|rspack|rsbuild|webpack].config.[js,ts]
new ModuleFederationPlugin({
    ...
    // 确保所有的 key 都以 "./" 开头
    exposes: { './Foo': './src/<path-to-file>/Foo.tsx' },
    ...
  })