You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

按文件夹自定义TypeScript编译选项(Angular CLI+Fuse Theme场景)

Solution: Use Separate TypeScript Config for the src/@fuse Folder

Absolutely, you can make this work! Angular CLI supports multiple TypeScript configuration files, which lets you apply different compile options to specific parts of your codebase without modifying the uneditable Fuse theme files. Here's how to set it up:

1. Create a dedicated TS config for Fuse

First, make a new config file in your project root called tsconfig.fuse.json. This will extend your main TS config but override the strict settings that clash with Fuse:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    // Disable the strict settings that break Fuse—tweak these based on your actual errors
    "strict": false,
    // Or disable specific strict sub-options instead of turning off all strict mode:
    // "strictNullChecks": false,
    // "strictPropertyInitialization": false
  },
  "include": [
    "src/@fuse/**/*"
  ],
  "exclude": []
}

2. Update your angular.json configuration

Open angular.json and find the architect -> build and architect -> serve sections for your project. Update the options in both to use the dual config setup:

For the build target:

"options": {
  "tsConfig": "tsconfig.json",
  // Add the Fuse-specific config as an additional TS config
  "additionalTsConfigs": ["tsconfig.fuse.json"],
  // Exclude @fuse from the main config to avoid duplicate processing
  "exclude": ["src/@fuse/**/*"]
}

For the serve target (so dev mode works too):

"options": {
  "browserTarget": "your-project-name:build",
  "tsConfig": "tsconfig.json",
  "additionalTsConfigs": ["tsconfig.fuse.json"],
  "exclude": ["src/@fuse/**/*"]
}

(Make sure to replace your-project-name with the actual name of your project in angular.json.)

3. Test it out

Run ng build or ng serve like you normally would. Now:

  • Your app code (src/app, src/assets, etc.) will use your strict tsconfig.json settings
  • The uneditable src/@fuse files will compile using the relaxed settings in tsconfig.fuse.json, no more strict-mode errors from the theme!

Quick note for older Angular versions

If additionalTsConfigs isn't available in your Angular CLI version (it's supported in Angular 10+), you can work around it by excluding src/@fuse from your main tsconfig.json, then adding the Fuse files directly in the files array of your angular.json build options, paired with the tsConfig pointing to tsconfig.fuse.json. But the additionalTsConfigs method is cleaner if you can use it.

内容的提问来源于stack exchange,提问作者Romain Deneau

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 07:22:57