Types
Type errors are divided into two types: fixed error code errors and scenario-related errors.
Fixed error code errors
This type of error can be clearly captured in the code, and a fixed error code is assigned to each error. The error code consists of the error type and ID, such as TYPE-001.
Error code list
TYPE-001
Failed to generate type declaration. Execute the below cmd to reproduce and fix the error.
- Error Code:
TYPE-001
Reasons
When compiling TS types for exposed (exposes) files, the current project's tsconfig.json is used. Missing compiler options may cause the type build to fail.
Solutions
- Remove tsconfig.json
incrementalandtsBuildInfoFilefrom thecmdcommand. - Run the
cmdfrom the error message in terminal and fix the file ortsconfigbased on the output.
If you want to ignore TS type checking errors, set compilerOptions.noCheck to true in tsconfig.json (requires TS 5.5+).
If the cmd runs without error but you still get a TS compile failure, check the exposes field in ModuleFederationPlugin:
Scenario-related errors
This type of error is generated based on the user's specific scenario and has no fixed error code. The error message and handling method will vary depending on the scenario.
Generated type contains aliases
Phenomenon description
The type generated by the producer contains aliases and cannot be processed normally in the consumer.
How to solve
- Install typescript-transform-paths and ts-patch
- Apply
typescript-transform-pathsintsconfig.json
- Set dts.generateTypes.compilerInstance to
tspc(ts-patchcli) - Regenerate types
Generated types not updating when working behind a local proxy
Phenomenon description
The types generated by the producer are successfully generated, the consumer log shows that the types are successfully processed, but the @mf-types directory does not update.
The issue can be a proxy configuration problem not allowing the resource to be downloaded.
How to solve
- Check if the
@mf-typesdirectory is generated in thedistdirectory of the producer. - Check your proxy log for any errors related to
TLSorSSL. - Adapt your proxy configuration to add
TLScertification for your local environment. - In some scenarios this is not working. An alternative is, to define the environment variable
NODE_TLS_REJECT_UNAUTHORIZED=0to ignore theTLSorSSLerrors. This will allow the@mf-types.zipto be properly handled.
Only set NODE_TLS_REJECT_UNAUTHORIZED=0 in your local development environment. It is not meant for production use. If you go this route, please make sure to commit the generated types to your repository.